3 Replies Latest reply on Nov 29, 2004 5:05 PM by Thomas Heute

    News Admin problem

    Phill J Newbie

      I've written a simple XML deployer.
      The implementation is in
      org.jboss.kernel.plugins.deployment.xml.XMLKernelDeployer

      It uses Alexey's new MappingObjectModel from JBossXB, very nice :-)

      You can define your parser in just a few lines of code;
      e.g. currently I have

       objectModelFactory = new MappingObjectModelFactory();
       objectModelFactory.mapElementToClass("deployment", AbstractKernelDeployment.class);
       objectModelFactory.mapElementToClass("beans", ArrayList.class);
       objectModelFactory.mapElementToClass("bean", AbstractBeanMetaData.class);
       objectModelFactory.mapElementToClass("constructorParams", ArrayList.class);
       objectModelFactory.mapElementToClass("dependency", AbstractDependencyValueMetaData.class);
       objectModelFactory.mapElementToField("dependentState", AbstractDependencyValueMetaData.class, "dependentState", StateConverter.instance);
       objectModelFactory.mapElementToClass("parameter", AbstractParameterMetaData.class);
       objectModelFactory.mapElementToField("dependency", AbstractParameterMetaData.class, "value", TypeConverter.STRING);
       objectModelFactory.mapElementToClass("value", StringValueMetaData.class);
       objectModelFactory.mapElementToClass("attributes", HashSet.class);
       objectModelFactory.mapElementToClass("attribute", AbstractAttributeMetaData.class);
       objectModelFactory.mapElementToField("dependency", AbstractAttributeMetaData.class, "value", TypeConverter.STRING);
       objectModelFactory.mapElementToClass("demands", HashSet.class);
       objectModelFactory.mapElementToClass("demand", AbstractDemandMetaData.class);
       objectModelFactory.mapElementToField("whenRequired", AbstractDemandMetaData.class, "whenRequired", StateConverter.instance);
       objectModelFactory.mapElementToClass("supplies", HashSet.class);
       objectModelFactory.mapElementToClass("supply", AbstractSupplyMetaData.class);
       objectModelFactory.mapElementToClass("interceptors", ArrayList.class);
       objectModelFactory.mapElementToClass("interceptor", AbstractInterceptorMetaData.class);
      


      There are some examples used by the tests in
      jboss-head/kernel/src/resources/test/org/jboss/test/kernel/xml/test

        • 1. Re: Simple XML deployer
          Phill J Newbie

          On a related note, the interface
          org.jboss.kernel.spi.deployment.KernelDeployment
          is the start of the M2 deployer code.

          The method KernelDeployment.getBeans()
          doesn't have to have a fixed list of BeanMetaData like in the abstract implementation.

          It can be "dynamically" generated from a more convenient metamodel like the
          ejb metadata or web metadata or some intermediate form.

          • 2. Re: News Admin problem
            Thomas Heute Master

            Hello Phill,

            You didn't do anything stupid. When you delete a topic it deletes the stories. There was a bug though, you probably have a version with it.

            May i know which version you are using ?

            (To fix it, i think you need to delete the stories in the database that have a NULL topicid)

            Thanks.

            • 3. Re: News Admin problem
              Thomas Heute Master

              Unfortunately it has been fixed just after.

              In news/src/main/org/jboss/nukes/addons/modules/news/ejb/StoryEJB.java
              You need to add:

              * cascade-delete = "yes"

              for the method getTopic().

              So your code should look like this:
               /**
               * get the topic associated w/ the story
               *
               * @return story's topic
               *
               * @ejb.interface-method
               * @ejb.relation
               * name = "Topic-Story"
               * role-name = "Story-belongsto-Topic"
               * cascade-delete = "yes"
               *
               * @jboss.relation
               * fk-column = "topic_id"
               * related-pk-field = "topicID"
               * sql-type = "INTEGER"
               * jdbc-type = "INTEGER"
               * @jboss.method-attributes
               * read-only = "true"
               */
               public abstract org.jboss.nukes.addons.modules.news.ejb.TopicEJBLocal getTopic();
              


              Then the easiest way for you is to relaunch the nukes-installer if you didn't put any data yet.
              (otherwise if will delete all the data, you just need to create the news table, so you can uncheck everything else but "delete news stories table" and "create news stories table")

              from what you said you did not enter any story yet so you are all fine with that method. Don't forget to uncheck everything else or you will loose data.