GeeCON Prague 2014*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes how many PrePassivate methods we can have in an stateful session bean ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "how many PrePassivate methods we can have in an stateful session bean ?" Watch "how many PrePassivate methods we can have in an stateful session bean ?" New topic
Author

how many PrePassivate methods we can have in an stateful session bean ?

Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
how many PrePassivate methods we can have in an stateful session bean ?
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
same number as SB (SLSB) can have postActivate.
I have not tried more than one in single SB.
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
only one.


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
Marcos Serrano
Ranch Hand

Joined: Jul 13, 2006
Posts: 46
Only one...plus several lifecycle callback methods can be used in one single method.

@PrePassivate
@PreRemove
public void cleanUp()


toutes les jours
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

If you decide to define lifecycle events interceptors in different classes (not directly in the bean), the spec says :
Lifecycle callback interceptor methods may be defined on superclasses of the bean class or interceptor classes. However, a given class may not have more than one lifecycle callback interceptor method for the same lifecycle event. Any subset or combination of lifecycle callback annotations may be specified on a given class.


Anyway, what would be the use of defining several PrePassivate methods ?


[My Blog]
All roads lead to JavaRanch
Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
lets keep it simple. How many method(s) I can annot with @PrePassivate in a statefull session bean ? Many places I have seen the answer is "ONE".
I have tested this in JBoss 5, JBoss did PERMIT me to have two methods with @PrePassivate annotation. It did not throw any spec vilocation error/exception ? Does the JBoss not follow the spec ? or we can have more than one @PrePassivate method inside the bean. (Not talking about interceptors at all).
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

My answer is "one". And don't trust what JBoss allows you to do, it's not a reference implementation. (even so-called reference implementation are sometimes doubtful).
Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
Thanks Christophe.
 
GeeCON Prague 2014
 
subject: how many PrePassivate methods we can have in an stateful session bean ?