• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbCreate in MDB

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic