facebook

xdoclet generated interface superclasses [closed]

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #212966 Reply

    benr242
    Participant

    Hello, I’m having a problem with MyEclipse-generated interfaces. My EJB implementation class extends a class called AbstractStatelessSessionBean. When I run xdoclet, the generated Home and Remote interfaces extend AbstractStatelessSessionHome and AbstractStatelessSession, respectively. These 2 superclasses referenced are not real classes in my application, so I’m unsure of where these names come from. It looks like it just applied standard naming conventions to the superclass of my implementation bean, and made the results superclasses of the interfaces. I don’t want this to happen, however. I just want them to extend EJBHome and EJBObject.

    If I take the ‘extends’ clause out of the implementation class, then everything works fine. The interfaces extend EJBHome and EJBObject, as they should. With the exception of the correct ‘extends’ clause, these interfaces are identical to flawed ones generated from the implementation class which has the ‘extends’ clause.

    Is there any way I can override this behavior, and just have the interfaces extend the classes they normally do? Thanks for any help

    #213061 Reply

    Riyad Kalla
    Member

    I am asking our Xdoclet guy to look at this.

    #213083 Reply

    Greg
    Member

    I tried to recreate your issue but I didn’t understand why you say that AbstractStatelessSession and AbstractStatelessSessionHome aren’t real classes in your application. Are they not generated by Xdoclet? Here is what I did to recreate your scenerio.

    Created AbstractStatelessSessionBean for base class of session beans:

    
    package test.ejb;
    
    import javax.ejb.CreateException;
    import javax.ejb.EJBException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    
    /**
     * Session bean base class 
     */
    public abstract class AbstractStatelessSessionBean implements SessionBean {
    
        /** The SessionContext */
        private SessionContext context;
    
        /**
         * @ejb.create-method
         */
        public void ejbCreate() throws CreateException {
        }
    
        public void ejbActivate() throws EJBException {
        }
    
        public void ejbPassivate() throws EJBException {
        }
    
        public void ejbRemove() throws EJBException {
        }
    
        public void setSessionContext(SessionContext newContext)
                throws EJBException {
            context = newContext;
        }
    }

    Then I created a TestSessionBean that extends the abstract session bean:

    
    package test.ejb;
    
    import javax.ejb.CreateException;
    import javax.ejb.EJBException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    
    /**
     * @ejb.bean name = "TestSessionBean"
     *           type = "Stateless"
     *           display-name = "TestSessionBean"
     *           description = "TestSessionBean EJB"
     *           view-type = "remote"
     *           jndi-name = "ejb/TestSessionBeanHome"
     */
    public abstract class TestSessionBean extends AbstractStatelessSessionBean
            implements SessionBean {
    
        /** The SessionContext */
        private SessionContext context;
    
        /**
         * An example business method
         * @ejb.interface-method view-type = "remote"
         */
        public void replaceWithRealBusinessMethod() throws EJBException {
            // rename and start putting your business logic here
        }
    }

    Then after configuration XDoclet with “Standard EJB” configuration, I ran xdoclet and got the following files generated:

    I didn’t have a problem with the generated Home and remote classes extending the classes AbstractStatelessSessionHome and AbstractStatelessSession because they are available in the interfaces package.

    If this is not happening with your setup, please let us know what differs from what I have shown above so we can better help with your problem.

    #213939 Reply

    benr242
    Participant

    Hello Greg, what you have done is almost exactly what I was trying to do. The one thing I can see different, and I believe that it may be the source of my problem, is that I don’t actually use the source code for the AbstractStatelessSessionBean class. I use only the .class file in a jar. This, I assume, leads to the AbstractStatelessSession and AbstractStatelessSessionHome not being created. Since there are no business methods in the Abstract* classes, I didn’t think that my subclass interfaces would need to extend the Abstract* interfaces.

    I have tried including the source code for the AbstractStatelessSessionBean and marking it up with appropriate xdoclet code, and that works fine (exactly like what you did). So my problem is fixed, but I would prefer to not include the source for this class or create the Abstract interfaces. It appears also to be working if I just do it the way I was, and manually change my interfaces to extend EJBHome and EJBObject instead. Is there a way to specify which class an interface generated by xdoclet will extend?

    Either way, you’ve helped me enough that I can continue. Thank you very much, you guys are awesome.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: xdoclet generated interface superclasses [closed]

You must be logged in to post in the forum log in