Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

For Stateful, Stateless, and MessageDriven, the syntax is as follows:

  • @PostConstruct <any-scope> void <method-name>()
  • @PreDestroy <any-scope> void <method-name>()
  • @PrePassivate <any-scope> void <method-name>()
  • @PostActivate <any-scope> void <method-name>()

For an Interceptor, the syntax includes InvocationContext as follows:

  • @PostConstruct <any-scope> void <method-name>(InvocationContext)
  • @PreDestroy <any-scope> void <method-name>(InvocationContext)
  • @PrePassivate <any-scope> void <method-name>(InvocationContext)
  • @PostActivate <any-scope> void <method-name>(InvocationContext)

The AroundInvoke syntax for an EJB or Interceptor is the same:

  • @AroundInvoke <any-scope> Object <method-name>(InvocationContext) throws Exception

Stateless

Code Block
import javax.ejb.Stateless;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;

@Stateless
public class MyStatelessBean implements  MyBusinessInterface  {

    @PostConstruct
    public void constructed(){

    }

    @PreDestroy
    public void destroy(){

    }

    @AroundInvoke
    public Object invoke(InvocationContext invocationContext) throws Exception {
        return invocationContext.proceed();
    }
}

...