[jboss-user] [Beginner's Corner] - Re: Singletons in a J2EE application server

Bernd Eckenfels do-not-reply at jboss.com
Thu Sep 22 07:06:00 EDT 2011

Bernd Eckenfels [http://community.jboss.org/people/b.eckenfels] created the discussion

"Re: Singletons in a J2EE application server"

To view the discussion, visit: http://community.jboss.org/message/627987#627987

According to the Java EE 6 and EJB 3.1 Specification a Stateless Session Bean with the @Singleton Annotation is created once for an Application. If the Application is deployed on multiple VMs (in a Cluster) you have one Instance for each VM.

Of courxe you can have multiple different Singleton Beans.

If the locking and processing of a singleton bean is a problem for application performance, it could make sense to have multiple. But strictly speaking you wont have a real singleton anymore. This would be more like Statefull Session Beans. It is not addressed by the spec, but you could implement it conformant with the Spec by having multiple Singletons (same class, different name). In that case you would have to care for pooling andsynchronizing yourself.

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110922/fef6f7f8/attachment.html 

More information about the jboss-user mailing list