This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes How can I create singleton session bean in EJB3.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How can I create singleton session bean in EJB3.0" Watch "How can I create singleton session bean in EJB3.0" New topic
Author

How can I create singleton session bean in EJB3.0

Prateek Kumar Singh
Greenhorn

Joined: Jan 21, 2011
Posts: 29

Hi guys,

I have a requirement to implement Singleton session bean with EJB3.0 and JBOSS6.0. (please post with an example) ?
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

Hi Prateek,
Singleton has been introduced in EJB 3.1 and not in 3.0. You can read about it in our EJB-FAQ

The above FAQ page provides a link to this page which explains the Singleton annotation.

You can also check out the JEE 6 tutorial page to find info about Singleton.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Prateek Kumar Singh
Greenhorn

Joined: Jan 21, 2011
Posts: 29

Hi Ranganathan,

Here idea behind singleton session bean in EJB is We will have a pool of bean instances and that pool will maintain only one bean instance.On each request that bean instance will return to user and get back to pool once job completed. all requests to the singleton will be routed to the single instance of the Singleton bean instance.
A singleton EJB ensures there is only one instance of an EJB in a application. There will be many instances of a stateful session bean (one per session) in a n application.

To maintain the concurrency in your application If you are using container managed concurrency the container may lock on read or write access (or both). So for synchronization programmer need to implement there own logic in application.

In Jboss 6.0 we can create a pool of instance by using @pool annotation. -



this annotation can be applied to a stateless or message driven bean class.

Pool in JBOSS 6.0
Hope this link will help you.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How can I create singleton session bean in EJB3.0
 
Similar Threads
java.sql.SQLException: You cannot set autocommit during a managed transaction!
Session Beans in EJB2.0 and EJB3.0
EJB2.0 or EJB3.0?
Need to use a bean inside static block of another bean
singleton stateless session bean