2.3.2.2. Singleton Session Bean Example

@Startup @Singleton public class ASingletonBean {

    // Injected reference to JNDI resource
    @Resource (lookup = "java:comp/env/jdbc/SomeDataSource") DataSource dataSource;

    // Method that is called after construction
    @PostConstruct
    public void myInitMethod () { ... }

    // Method that is called before destruction
    @PreDestroy
    public void myDoneMethod () { ... }

    // Some business methods ...
    public synchronized void myMethodOne (int iArgument) { ... }
    public synchronized int myMethodTwo (Object oArgument) { ... }
}

Container life cycle view.