Can i use inheritance in EJBs.If yes,How can i ensure that the super class object is created before i call a Child EJB's method? Any pointers for the same will also be helpful. Thanks in advance
I've used inheritance with stateless session beans and you'll be fine if you keep the following in mind: Bean Class: The child bean class must extend the parent bean class. Make sure you call super.setSessionContext(ctx) in the childs setSessionContext() method if you are performing any initialization in the parent method. Remote Interface: Make sure the child remote interface extends the parent remote interface. The child interaface automatically inherits the parents remote methods, so there is no need to define them in the child remote interface, unless you plan to override, just like regular inheritance, there really is no difference. Home interface: The child home interface does NOT extend the parent home interface; it simple extends EJBHome. Deployment descriptor: If you will be accessing the child bean from your client code, then you only need specify the child EJB classes and JNDI name in the descriptor. There is no need to specify anything regarding the parent bean. Hope it helps, Raffi
Sure you can. Common use is for example to create AbstractSession with EJB specific code: public javax.ejb.SessionContext getSessionContext() { return mySessionCtx; } /** * setSessionContext */ public void setSessionContext(javax.ejb.SessionContext ctx) { mySessionCtx = ctx; } /** * ejbCreate */ public void ejbCreate() throws javax.ejb.CreateException { } /** * ejbActivate */ public void ejbActivate() { } /** * ejbPassivate */ public void ejbPassivate() { } /** * ejbRemove */ public void ejbRemove() { }
and then you implement your own class which extends AbstractSession class. Answer to second part is that everything is one object. So don't worry about that. But be carefull if you use it in Entity beans.
Vladimir Ergovic
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.