views:

381

answers:

4

I wan to check if my stateful bean is passivated/activated and the corresponding callbacks are called properly.

For that I want to configure the containers GlassFish and/or JBOSS to limit the number of instances of the bean.

Is it possible ? If yes, how ?

+1  A: 

In JBoss, the configuration file you want to look at is conf/standardjboss.xml

It looks intimidating (and it is), but look for a container-configuration element called "Standard Stateful SessionBean". Towards the end of this element you'll see the container-pool-conf section, which defines the maximum number of instances for this configuration. This file can be modified, or you can define your own configurations, although I'm not too clear how to go about that. I suspect it goes inside the META-INF/jboss.xml file.

Once you've defined a configuration as you want it, you need to configure the EJB itself to use it. Under EJB 2, you'd use the META-INF/jboss.xml, but in the wonderful descriptor-free world of EJB3, I'm not sure.

So the answer likely lies in an appriately configured META-INF/jboss.xml file. Sorry I can't be more exact, but at least know you know where to look.

skaffman
A: 

Thanks for pointing me to the right direction.

For JBOSS, found the annotation org.jboss.ejb3.annotation.CacheConfig with parameters maxSize and idleTimeoutSeconds as parameters.

Here the documentation link for someone searching... http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Administration_And_Configuration_Guide/5/html/clustering-session-sfsb30.html

Though, I don't yet know, how to configure this with xml without using the annotations.

rangalo
A: 

For the Glassfish platform, you can do the same following the information here:

http://docs.sun.com/app/docs/doc/819-3673/beaqm?a=view

Look to the bottom of the page for some examples.

To track when specific beans are instantiated or GC'd, I add some logging methods and annotate them with @PostConstruct and @PreDestroy.

feicipet
A: 

Hi, I have been devloping EJB3 applications in JBOSS5.1. For the EJB's i created an init method and annotated with @PostConstruct and provide some logging information inside it. But the interesting fact i noticed is the PostConstrcut method is not being called at deployment time.But when we look up the EJB tha calls are being made.is this mean that JBOSS5.1 is not doing Bean pooling at all. Regards Hari

hari