@Stateful public class ASessionBean implements ABusinessInterface { // Injected reference to standard session context object @Resource public SessionContext sessionContext; // Method that is called after construction or activation @PostConstruct @PostActivate public void myInitMethod () { ... } // Method that is called before passivation or destruction @PreDestroy @PrePassivate public void myDoneMethod () { ... } // Some business methods ... public void myMethodOne (int iArgument) { ... } public int myMethodTwo (Object oArgument) { ... } // Business method with asynchronous interface @Asynchronous public Future<String> myAsynchronousMethod (String sArgument) { ... } // Business method that removes the bean instance @Remove public void myRemovalMethod () { ... } // Interceptor method that can also be in separate interceptor class @AroundInvoke public Object myInterceptor (InvocationContext inv) throws Exception { ... Object result = inv.proceed (); ... return (result); } }
method invocations serialized by the container
asynchronous method invocations handled by the container
business interface can be accessed both locally and remotely
references obtained through dependency injection or JNDI lookup
Client life cycle view.
accessible when reference first obtained
removed through explicit removal method
Container life cycle view.
instance may be passivated and activated