File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes How many instances will create Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How many instances will create" Watch "How many instances will create" New topic
Author

How many instances will create

Sanju
Ranch Hand

Joined: Jul 15, 2002
Posts: 53
HI Every body,
In EJB how to create the instances. How many instances will create for application. Suppose if 10 users will access any bean it will create 10 instances or one instance(I think one instance means it will come single ton. EJB not supporting single ton extensively) for any bean like Session or Entity beans.

Advancedly Thanks,
Sanju.


Thank you,<br />Sanju
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Sanju,


HI Every body,
In EJB how to create the instances. How many instances will create for application. Suppose if 10 users will access any bean it will create 10 instances or one instance

Usually developers do not control the way bean instances are created into the pool. All they can do is to define the initial number and the maximum number of bean instances in the pool. The container will create more and more instances as needed up to the specified maximum value; all incoming client requests will block after that waiting for instances to become available. If the transaction timeout is exceeded the container will throw an exception.

I think one instance means it will come single ton. EJB not supporting single ton extensively)

You right singleton are not supported. However there is a work around: define the initial number of instances = max number of instances = 1. This way you�ll have exactly one bean instance (kind of singleton). However this paradigm will brake in a clustered environment.
Regards.


I think, therefore I exist -- Rene Descartes
Sanju
Ranch Hand

Joined: Jul 15, 2002
Posts: 53
Hi Valentin Tanase ,
first Thank you for your valid information.

I have one doubt again,Is it possible to declare instances in server level? if not, who will declare , it is based on server vendor or ? do you have any idea abt what is the min and max instances declaration for any server or (how many for weblogic,Jboss).
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
If you don�t specify any values for the initial-beans-in-free-pool or max-beans-in-free-pool configuration parameters, then the container will use some default values. WebLogic for example will default the first parameter to 0 and the second to 1000 for entity ejbs. The rule is little bit more complicated for SLSB. The first parameter still defaults to 0, but the second one depends upon the available memory and the number of execute threads.
Regards.
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

As far i know it really costly and troubling giving if u use Singleton Dsgn Pattern....it is almost like creating a servlet which extends Single thread Model...

coming to Num of instsnces...

in Weblogic we have option for creating instances for both Max ...when used with struts frameworm u make use of plugin so that as soon as ur app is UP it will create instance it sis some thing like u r creating ur own Pool manager..

we have a provision for max instances... so if instances exceeds web app wich will poll the instances (actiovation / p assivvation)....

g r gowtham
grgowtham_cse@yahoo.com
gowtham@capricornsys-global.com....


Thanks, Ganesh Gowtham
http://ganesh.gowtham.googlepages.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How many instances will create