aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes ejbCreate in MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejbCreate in MDB" Watch "ejbCreate in MDB" New topic
Author

ejbCreate in MDB

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Hi,
I was just wondering why ejbCreate is not a part of MessageDrivenBean interface.
It is quite understanable why it is not put inside SessionBean and EntiyBean interface.
Thanks


Groovy
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The javax.ejb.SessionBean interface doesn't list ejbCreate() either and still the EJB specification requires it and the EJB container calls it. Why it isn't part of the interface, beats me.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

For SessionBean , I guess it is because there are 2 types : stateful and stateless. Stateless requires a no -arg ejbCreate and stateful may make use of ejbCreate with different parameters and this may not include a no-arg ejbCreate and this cannot be enforced at compile time.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Well, the specification authors could've separated the interface into two if they would've wanted compile-time enforcement on the stateless beans' no-arg ejbCreate(); "javax.ejb.StatefulSessionBean" and "javax.ejb.StatelessSessionBean"...
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by Lasse Koskela:
Well, the specification authors could've separated the interface into two if they would've wanted compile-time enforcement on the stateless beans' no-arg ejbCreate(); "javax.ejb.StatefulSessionBean" and "javax.ejb.StatelessSessionBean"...

It does solve the problem for stateless session bean but what about stateful session bean. The create methods cannot be enforced at the complie time because the bean providers are free to choose their own parameters to ejbCreate.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Yes, that's why I explicitly said "stateless session beans". However, we should keep in mind that the container can check for all kinds of constraints at deployment-time so it's not really a problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejbCreate in MDB