3.5.1.4. Session Bean Class Example (EJB 3)

@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 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);
  }
}