Singleton Session EJB: Difference between revisions
Line 13: | Line 13: | ||
The container invokes <tt>newInstance()</tt> method on the Singleton bean class, creating the instance. Then the container performs any dependency injection. Then the container calls [[EJB_Annotations#.40javax.annotation.PostConstruct|@PostConstruct]] methods. | The container invokes <tt>newInstance()</tt> method on the Singleton bean class, creating the instance. Then the container performs any dependency injection. Then the container calls [[EJB_Annotations#.40javax.annotation.PostConstruct|@PostConstruct]] methods. | ||
Once instantiated, the Singleton bean instance lives for the duration of the application. | Once instantiated according to the previous sequence, the Singleton bean instance lives for the duration of the application. | ||
When the application is shutting down, the container invokes [[EJB_Annotations#.40javax.annotation.PreDestroy|@PreDestroy]] methods, and this ends the life of the instance. | |||
==Dependencies between Singletons== | ==Dependencies between Singletons== |
Revision as of 18:52, 27 April 2017
Internal
Concepts
Overview
A singleton session bean is a component that is instantiated once per application. For distributed applications that span multiple VMs, each application will have on singleton session bean instance per JVM. The instances are intended to be shard, and must support concurrent access. The Singleton bean instances maintain state between invocations, but the state is not required to survive container shutdown or crash.
Lifecycle
The container invokes newInstance() method on the Singleton bean class, creating the instance. Then the container performs any dependency injection. Then the container calls @PostConstruct methods.
Once instantiated according to the previous sequence, the Singleton bean instance lives for the duration of the application.
When the application is shutting down, the container invokes @PreDestroy methods, and this ends the life of the instance.
Dependencies between Singletons
Transactional Behavior
Concurrency
Also see
Interceptors
Restrictions
Singleton beans must not implement javax.ejb.SessionSychronization interface or use the session synchronization annotations.