@Stateful(name="mySessionBean")
public class SessionBean implements SessionRemote {
@PostConstruct
//ejbCreate()
public void init(){
System.out.println("init called");
}
//business method
public void getResult() {
System.out.println("getResult called");
}
@PreDestroy
public void cleanup()throws Exception{
System.out.println("cleanup called");
}
@PostActivate
//ejbActivate()
public void activate(){
System.out.println("activate called");
}
@PrePassivate
//ejbPassivate()
public void passivate()throws Exception{
System.out.println("passivate called");
}
@Remove
//ejbRemove()
public void remove(){
System.out.println("remove called");
}
}
@Remote
public interface SessionRemote {
void getResult();
void remove();
}
//Client
public static void main(String[] args)throws Exception {
sessionBean.getResult();
sessionBean.remove();
}
I have EJB2 background.In above code i am not able to find difference between PreDestroy and Remove callback methods.
Output of this bean is as follows
init called
getResult called
remove called
cleanup called
According me the remove method should be called as last method i.e output should be as follows
init called
getResult called
cleanup called
remove called
Thanks