aspose file tools*
The moose likes JBoss/WildFly and the fly likes Max. Bean instances... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Max. Bean instances..." Watch "Max. Bean instances..." New topic
Author

Max. Bean instances...

Gurumurthy Ramamurthy
Ranch Hand

Joined: Feb 13, 2003
Posts: 273
Guys,



I am using jboss.xml for configuring the container to hold a max. of 10 bean instances.



jboss.xml



<?xml version="1.0" encoding="UTF-8"?>

<jboss>

<enterprise-beans>



<session>

<ejb-name>Count</ejb-name>

<jndi-name>Count</jndi-name> <!-- This is JNDI nick name -->

</session>

</enterprise-beans>



<cotainer-configurations>

<container-cache-conf>



<cache-policy>

<![CDATA[org.jboss.ejb.plugins.LRUStatefulContextCachePolicy]]>

</cache-policy>



<cache-policy-conf>

<max-capacity>10</max-capacity>

<max-bean-age>2</max-bean-age>

<overager-period>2</overager-period>

</cache-policy-conf>



</container-cache-conf>

</cotainer-configurations>

</jboss>



I am using the following test clients, where I am creating 20 instances. What I am expecting is that after the 10th instantiation, the container should call ejbPassivate() method´┐Ż



CounterClient.java:

import javax.naming.Context;

import javax.naming.InitialContext;

import java.util.Hashtable;

public class CountClient

{



public static void main( String [] args )

{



Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

env.put(Context.PROVIDER_URL, "localhost:1099");

env.put("java.naming.factory.url.pkgs", "org.jboss.naming rg.jnp.interfaces");

Count count[]=new Count[20];

int intVal=0;

try

{

Context ctx = new InitialContext(env);

Object obj = ctx.lookup( "Count" );

CountHome home = (CountHome)javax.rmi.PortableRemoteObject.narrow( obj, CountHome.class );

for (int i=0;i<20 ;i++ )

{

count[i]=home.create(intVal);

intVal=count[i].count();

System.out.println("intVal..."+intVal);

Thread.sleep(500);

}





System.out.println("Now calling the count() methods");

for (int i=0;i<20;i++)

{

intVal=count[i].count();

System.out.println("2nd: "+intVal);

Thread.sleep(500);

}





System.out.println("Removing beans");

for (int i=0;i<20;i++)

{

count[i].remove();

}





}

catch ( Exception e )

{



e.printStackTrace();

System.out.println( "Exception: " + e.getMessage() );

}

}

}



But I am not getting, this program creates 20 instances´┐Ż.How to make the ejbPassivate() to be called by container?



Thanks,

Guru
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Max. Bean instances...