@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) { ... }
}
concurrent method invocations possible
Container life cycle view.
construction timing determined by container
eager construction can be requested through annotation