[jboss-cvs] JBossAS SVN: r64938 - in trunk/ejb3: src/main/org/jboss/ejb3 and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 28 19:53:02 EDT 2007
Author: bdecoste
Date: 2007-08-28 19:53:02 -0400 (Tue, 28 Aug 2007)
New Revision: 64938
Added:
trunk/ejb3/src/resources/test-configs/statelesscreation/
trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/
trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3-connectors-service.xml
trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3-interceptors-aop.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/StatelessRemote.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/ThreadLocalPoolStatelessBean.java
Modified:
trunk/ejb3/build-test.xml
trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java
trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java
Log:
[EJBTHREE-1031] [EJBTHREE-1032] fix and test for stateless pool creation and consistent pool metrics
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-08-28 22:13:24 UTC (rev 64937)
+++ trunk/ejb3/build-test.xml 2007-08-28 23:53:02 UTC (rev 64938)
@@ -3605,7 +3605,7 @@
</copy>
</target>
- <target name="jars" depends="defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
+ <target name="jars" depends="statelesscreation, defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440,
ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921, ejbthree936,
ejbthree939,
@@ -4202,6 +4202,7 @@
<antcall target="invoker-test" inheritRefs="true"/>
<antcall target="iiop-tests" inheritRefs="true"/>
<antcall target="libdeployment-test" inheritRefs="true"/>
+ <antcall target="statelesscreation-test" inheritRefs="true"/>
<!--antcall target="multi-instance-localfromremote-test" inheritRefs="true"/-->
</target>
@@ -4821,6 +4822,27 @@
</antcall>
</target>
+
+ <target name="statelesscreation-test">
+ <create-config baseconf="all" newconf="statelesscreation">
+ <patternset>
+ <include name="conf/**"/>
+ <include name="deploy*/**"/>
+ <include name="lib/**"/>
+ </patternset>
+ </create-config>
+
+ <start-jboss conf="statelesscreation" host="${node0}" jvmargs="${ejb3.jboss.jvmargs}"/>
+ <wait-on-host/>
+
+ <antcall target="test-with-jvmargs" inheritRefs="true">
+ <param name="test" value="statelesscreation"/>
+ <param name="jvmargs" value=""/>
+ </antcall>
+
+ <stop-jboss url="${node0.jndi.url}" jboss.dist="${ejb3.dist}"/>
+ <wait-on-shutdown conf="all"/>
+ </target>
<target name="multi-instance-localfromremote-test">
<create-config baseconf="default" newconf="localfromremote1">
Modified: trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2007-08-28 22:13:24 UTC (rev 64937)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2007-08-28 23:53:02 UTC (rev 64938)
@@ -471,13 +471,15 @@
try
{
clientBindUrl = (String)kernelAbstraction.getAttribute(connectionON, "InvokerLocator");
+ if (clientBindUrl == null)
+ clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
}
catch (Exception e)
{
clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
}
}
-
+
return clientBindUrl;
}
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java 2007-08-28 22:13:24 UTC (rev 64937)
+++ trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java 2007-08-28 23:53:02 UTC (rev 64938)
@@ -33,7 +33,7 @@
public class StrictMaxPool
extends AbstractPool
{
- // Constants -----------------------------------------------------
+// Constants -----------------------------------------------------
public static final int DEFAULT_MAX_SIZE = 30;
public static final long DEFAULT_TIMEOUT = Long.MAX_VALUE;
@@ -53,7 +53,7 @@
/**
* The pool data structure
*/
- protected LinkedList<BeanContext<?>> pool = new LinkedList<BeanContext<?>>();
+ protected LinkedList pool = new LinkedList();
/**
* The maximum number of instances allowed in the pool
*/
@@ -81,17 +81,17 @@
public int getCurrentSize()
{
- return pool.size();
+ return getCreateCount() - getRemoveCount();
}
public int getAvailableCount()
{
- return maxSize - inUse;
+ return maxSize - inUse;
}
public int getMaxSize()
{
- return maxSize;
+ return maxSize;
}
public void setMaxSize(int maxSize)
@@ -100,18 +100,13 @@
this.strictMaxSize = new FIFOSemaphore(maxSize);
}
- public BeanContext<?> get()
- {
- return get(null, null);
- }
-
/**
* Get an instance without identity.
* Can be used by finders,create-methods, and activation
*
* @return Context /w instance
*/
- public BeanContext<?> get(Class[] initTypes, Object[] initValues)
+ public BeanContext get()
{
boolean trace = log.isTraceEnabled();
if (trace)
@@ -143,6 +138,42 @@
// Pool is empty, create an instance
++inUse;
+ return create();
+
+ }
+
+ public BeanContext get(Class[] initTypes, Object[] initValues)
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Get instance " + this + "#" + pool.size() + "#" + container.getBeanClass());
+
+ // Block until an instance is available
+ try
+ {
+ boolean acquired = strictMaxSize.attempt(strictTimeout);
+ if (trace)
+ log.trace("Acquired(" + acquired + ") strictMaxSize semaphore, remaining=" + strictMaxSize.permits());
+ if (acquired == false)
+ throw new EJBException("Failed to acquire the pool semaphore, strictTimeout=" + strictTimeout);
+ }
+ catch (InterruptedException e)
+ {
+ throw new EJBException("Pool strictMaxSize semaphore was interrupted");
+ }
+
+ synchronized (pool)
+ {
+ if (!pool.isEmpty())
+ {
+ BeanContext bean = (BeanContext) pool.removeFirst();
+ ++inUse;
+ return bean;
+ }
+ }
+
+ // Pool is empty, create an instance
+ ++inUse;
return create(initTypes, initValues);
}
@@ -187,6 +218,7 @@
catch (Exception ignored)
{
}
+
}
public void destroy()
@@ -238,6 +270,7 @@
}
pool.clear();
inUse = 0;
+
}
// Inner classes -------------------------------------------------
Modified: trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-08-28 22:13:24 UTC (rev 64937)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-08-28 23:53:02 UTC (rev 64938)
@@ -34,115 +34,151 @@
*/
public class ThreadlocalPool implements Pool
{
- private static final Logger log = Logger.getLogger(ThreadlocalPool.class);
+private static final Logger log = Logger.getLogger(ThreadlocalPool.class);
- protected Pool delegate = new InfinitePool();
+ protected Pool pool = new InfinitePool();
protected WeakThreadLocal<BeanContext> currentBeanContext = new WeakThreadLocal<BeanContext>();
-
+ private int inUse = 0;
+ private int maxSize = 30;
+
public ThreadlocalPool()
{
}
protected BeanContext create()
{
- return delegate.get();
+ return pool.get();
}
protected BeanContext create(Class[] initTypes, Object[] initValues)
{
- return delegate.get(initTypes, initValues);
+ return pool.get(initTypes, initValues);
}
public void discard(BeanContext obj)
{
- delegate.discard(obj);
+ pool.discard(obj);
+ --inUse;
}
public void destroy()
{
log.trace("destroying pool");
- delegate.destroy();
+ pool.destroy();
// This really serves little purpose, because we want the whole thread local map to die
currentBeanContext.remove();
+
+ inUse = 0;
}
- public BeanContext<?> get()
+ public BeanContext get()
{
- BeanContext ctx = currentBeanContext.get();
- if (ctx != null)
+ BeanContext ctx = null;
+
+ synchronized(pool)
{
- currentBeanContext.set(null);
- return ctx;
+ ctx = currentBeanContext.get();
+ if (ctx != null)
+ {
+ currentBeanContext.set(null);
+ ++inUse;
+ return ctx;
+ }
+
+ ctx = create();
+ ++inUse;
}
-
- ctx = create();
+
return ctx;
}
- public BeanContext<?> get(Class[] initTypes, Object[] initValues)
+ public BeanContext get(Class[] initTypes, Object[] initValues)
{
- BeanContext ctx = currentBeanContext.get();
- if (ctx != null)
+ BeanContext ctx = null;
+ synchronized(pool)
{
- currentBeanContext.set(null);
- return ctx;
+ ctx = currentBeanContext.get();
+ if (ctx != null)
+ {
+ currentBeanContext.set(null);
+ ++inUse;
+ return ctx;
+ }
+
+ ctx = create(initTypes, initValues);
+ ++inUse;
}
-
- ctx = create(initTypes, initValues);
+
return ctx;
}
public void initialize(Container container, int maxSize, long timeout)
{
- delegate.initialize(container, maxSize, timeout);
+ pool.initialize(container, maxSize, timeout);
+ this.maxSize = maxSize;
}
public void release(BeanContext ctx)
{
- if (currentBeanContext.get() != null)
- remove(ctx);
- else
- currentBeanContext.set(ctx);
+ synchronized(pool)
+ {
+ if (currentBeanContext.get() != null)
+ {
+ remove(ctx);
+ }
+ else
+ {
+ currentBeanContext.set(ctx);
+ }
+
+ --inUse;
+ }
}
public void remove(BeanContext ctx)
{
- delegate.remove(ctx);
+ pool.remove(ctx);
}
public int getCurrentSize()
{
- return -1;
+ int size;
+ synchronized (pool)
+ {
+ size = pool.getCreateCount() - pool.getRemoveCount();
+ }
+ return size;
}
public int getAvailableCount()
{
- return -1;
+ return maxSize - inUse;
}
public int getCreateCount()
{
- return delegate.getCreateCount();
+ return pool.getCreateCount();
}
public int getMaxSize()
{
- return -1;
+ return maxSize;
}
public int getRemoveCount()
{
- return delegate.getRemoveCount();
+ return pool.getRemoveCount();
}
public void setInjectors(Injector[] injectors)
{
- delegate.setInjectors(injectors);
+ pool.setInjectors(injectors);
}
public void setMaxSize(int maxSize)
{
+ this.maxSize = maxSize;
}
}
Added: trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3-connectors-service.xml
===================================================================
--- trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3-connectors-service.xml (rev 0)
+++ trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3-connectors-service.xml 2007-08-28 23:53:02 UTC (rev 64938)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss EJB3Deployer
+
+ $Id: jboss-service.xml 41488 2006-02-25 00:14:09Z dimitris $
+-->
+<server>
+ <mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
+ <attribute name="Configuration">
+ <config>
+ <invoker transport="socket">
+ <attribute name="numAcceptThreads">1</attribute>
+ <attribute name="maxPoolSize">20</attribute>
+ <attribute name="clientMaxPoolSize" isParam="true">50</attribute>
+ <attribute name="timeout" isParam="true">60000</attribute>
+ <attribute name="serverBindAddress">${jboss.bind.address}</attribute>
+ <attribute name="serverBindPort">3873</attribute>
+ <attribute name="backlog">20000</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+</server>
Added: trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3-interceptors-aop.xml
===================================================================
--- trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3-interceptors-aop.xml (rev 0)
+++ trunk/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3-interceptors-aop.xml 2007-08-28 23:53:02 UTC (rev 64938)
@@ -0,0 +1,367 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE aop PUBLIC
+ "-//JBoss//DTD JBOSS AOP 1.0//EN"
+ "http://labs.jboss.com/portal/jbossaop/dtd/jboss-aop_1_0.dtd">
+
+<aop>
+ <interceptor class="org.jboss.aspects.remoting.InvokeRemoteInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.aspects.security.SecurityClientInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.aspects.tx.ClientTxPropagationInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.remoting.IsLocalInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.aspects.remoting.ClusterChooserInterceptor" scope="PER_VM"/>
+
+ <interceptor class="org.jboss.aspects.tx.TxPropagationInterceptor" scope="PER_VM"/>
+
+ <stack name="ServiceClientInterceptors">
+ <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+ </stack>
+
+ <stack name="AsynchronousStatelessSessionClientInterceptors">
+ <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+ </stack>
+
+ <stack name="AsynchronousStatefulSessionClientInterceptors">
+ <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+ </stack>
+
+ <stack name="StatelessSessionClientInterceptors">
+ <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+ </stack>
+
+ <stack name="StatefulSessionClientInterceptors">
+ <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+ </stack>
+
+ <stack name="ClusteredStatelessSessionClientInterceptors">
+ <interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+ </stack>
+
+ <stack name="ClusteredStatefulSessionClientInterceptors">
+ <interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
+ </stack>
+
+ <interceptor class="org.jboss.ejb3.asynchronous.AsynchronousInterceptor" scope="PER_CLASS"/>
+ <interceptor class="org.jboss.ejb3.ENCPropagationInterceptor" scope="PER_VM"/>
+ <interceptor name="Basic Authorization" factory="org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor name="JACC Authorization" factory="org.jboss.ejb3.security.JaccAuthorizationInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor factory="org.jboss.ejb3.security.AuthenticationInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor factory="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor class="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.stateless.StatelessInstanceInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.stateful.StatefulInstanceInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.service.ServiceSingletonInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.cache.StatefulReplicationInterceptor" scope="PER_VM"/>
+ <interceptor factory="org.jboss.ejb3.stateful.StatefulRemoveFactory" scope="PER_CLASS_JOINPOINT"/>
+ <interceptor factory="org.jboss.ejb3.tx.TxInterceptorFactory" scope="PER_CLASS_JOINPOINT"/>
+ <interceptor factory="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory" scope="PER_CLASS_JOINPOINT"/>
+ <interceptor factory="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor class="org.jboss.ejb3.AllowedOperationsInterceptor" scope="PER_VM"/>
+ <interceptor factory="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory" scope="PER_CLASS"/>
+ <interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
+
+ <domain name="Stateless Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+ <interceptor-ref name="Basic Authorization"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+ <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+ @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=20, timeout=10000)
+ </annotation>
+ </domain>
+
+ <domain name="JACC Stateless Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+ <interceptor-ref name="JACC Authorization"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+ <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+ @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+ </annotation>
+ </domain>
+
+ <domain name="Base Stateful Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+ <interceptor-ref name="Basic Authorization"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->@javax.ejb.Remove(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateful.StatefulRemoveFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateful.StatefulInstanceInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ </bind>
+ <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
+ </bind>
+
+ <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..)) AND !execution(public * *->@javax.ejb.Remove(..))">
+ <interceptor-ref name="org.jboss.ejb3.cache.StatefulReplicationInterceptor"/>
+ </bind>
+
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+
+ <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+ @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+ </annotation>
+ </domain>
+
+ <domain name="Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
+ <!-- NON Clustered cache configuration -->
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND !class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.simple.SimpleStatefulCache.class)
+ </annotation>
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.PersistenceManager) AND !class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.simple.PersistenceManager (org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.class)
+ </annotation>
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.CacheConfig) AND !class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.simple.CacheConfig (maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
+ </annotation>
+
+ <!-- Clustered cache configuration -->
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.tree.StatefulTreeCache.class)
+ </annotation>
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.tree.CacheConfig) AND class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.tree.CacheConfig (name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
+ </annotation>
+ </domain>
+
+ <domain name="JACC Stateful Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+ <interceptor-ref name="JACC Authorization"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->@javax.ejb.Remove(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateful.StatefulRemoveFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateful.StatefulInstanceInterceptor"/>
+ <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ </bind>
+ <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+
+ <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..)) AND !execution(public * *->@javax.ejb.Remove(..))">
+ <interceptor-ref name="org.jboss.ejb3.cache.StatefulReplicationInterceptor"/>
+ </bind>
+ <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+ @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+ </annotation>
+
+ <!-- NON Clustered cache configuration -->
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND !class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.simple.SimpleStatefulCache.class)
+ </annotation>
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.PersistenceManager) AND !class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.simple.PersistenceManager (org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.class)
+ </annotation>
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.simple.CacheConfig) AND !class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.simple.CacheConfig (maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
+ </annotation>
+
+ <!-- Clustered cache configuration -->
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache) AND class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.tree.StatefulTreeCache.class)
+ </annotation>
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.tree.CacheConfig) AND class(@org.jboss.annotation.ejb.Clustered)">
+ @org.jboss.annotation.ejb.cache.tree.CacheConfig (name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300, removalTimeoutSeconds=0)
+ </annotation>
+ </domain>
+
+ <domain name="Embedded Stateful Bean" extends="Base Stateful Bean" inheritBindings="true">
+ <!-- NON Clustered cache configuration -->
+ <annotation expr="!class(@org.jboss.annotation.ejb.cache.Cache)">
+ @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.NoPassivationCache.class)
+ </annotation>
+
+ </domain>
+
+ <domain name="Message Driven Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <!-- TODO: Authorization? -->
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+ <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+ @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=15, timeout=10000)
+ </annotation>
+ </domain>
+
+ <domain name="Consumer Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..)) AND (has(* *->@org.jboss.annotation.ejb.CurrentMessage(..)) OR hasfield(* *->@org.jboss.annotation.ejb.CurrentMessage))">
+ <interceptor-ref name="org.jboss.ejb3.mdb.CurrentMessageInjectorInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+ <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
+ @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=15, timeout=10000)
+ </annotation>
+ </domain>
+
+ <domain name="Service Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+ </bind>
+ <bind pointcut="!execution(* *->create()) AND !execution(* *->start()) AND !execution(*->new(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+ <interceptor-ref name="Basic Authorization"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+ </domain>
+
+ <domain name="JACC Service Bean">
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
+ </bind>
+ <bind pointcut="!execution(* *->create()) AND !execution(* *->start()) AND !execution(*->new(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
+ <interceptor-ref name="Basic Authorization"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
+ <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
+ </bind>
+ <bind pointcut="execution(public * *->*(..)) AND !execution(* *->create()) AND !execution(* *->start())">
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
+ </bind>
+ </domain>
+
+
+</aop>
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java 2007-08-28 22:13:24 UTC (rev 64937)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java 2007-08-28 23:53:02 UTC (rev 64938)
@@ -34,7 +34,7 @@
*/
@Stateless
@Remote(DestroyRemote.class)
- at RemoteBinding(clientBindUrl="socket://0.0.0.0:3875")
+ at RemoteBinding(clientBindUrl="socket://0.0.0.0:3873")
public class DestroyStatelessBean implements DestroyRemote
{
private static final Logger log = Logger.getLogger(DestroyStatelessBean.class);
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/StatelessRemote.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/StatelessRemote.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/StatelessRemote.java 2007-08-28 23:53:02 UTC (rev 64938)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.statelesscreation;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatelessRemote
+{
+ void test();
+
+ void testException();
+
+ void delay() throws Exception;
+}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/ThreadLocalPoolStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/ThreadLocalPoolStatelessBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/ThreadLocalPoolStatelessBean.java 2007-08-28 23:53:02 UTC (rev 64938)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.statelesscreation;
+
+import javax.ejb.Stateless;
+import javax.ejb.Remote;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(StatelessRemote.class)
+public class ThreadLocalPoolStatelessBean implements StatelessRemote
+{
+ private static final Logger log = Logger.getLogger(ThreadLocalPoolStatelessBean.class);
+
+ public void test()
+ {
+ }
+
+ public void testException()
+ {
+ throw new RuntimeException();
+ }
+
+ public void delay() throws Exception
+ {
+ Thread.sleep(30 * 1000);
+ }
+}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java 2007-08-28 22:13:24 UTC (rev 64937)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java 2007-08-28 23:53:02 UTC (rev 64938)
@@ -26,16 +26,16 @@
import javax.naming.InitialContext;
import org.jboss.ejb3.test.statelesscreation.DestroyRemote;
+import org.jboss.ejb3.test.statelesscreation.StatelessRemote;
import org.jboss.logging.Logger;
import org.jboss.test.JBossTestCase;
import junit.framework.Test;
-
/**
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
*/
public class MetricsUnitTestCase
-extends JBossTestCase
+ extends JBossTestCase
{
@SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
@@ -85,27 +85,178 @@
MBeanServerConnection server = getServer();
ObjectName testerName = new ObjectName("jboss.j2ee:jar=statelesscreation-test.jar,name=DestroyStatelessBean,service=EJB3");
- int size = (Integer)server.getAttribute(testerName, "CurrentSize");
- System.out.println("CurrentSize=" + size);
+ int currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
+ System.out.println("CurrentSize=" + currentSize);
+ int availableCount = (Integer)server.getAttribute(testerName, "AvailableCount");
+ System.out.println("AvailableCount=" + availableCount);
+
+ int maxSize = (Integer)server.getAttribute(testerName, "MaxSize");
+ System.out.println("MaxSize=" + maxSize);
+
+ int removeCount = (Integer)server.getAttribute(testerName, "RemoveCount");
+ System.out.println("RemoveCount=" + removeCount);
+
+ int createCount = (Integer)server.getAttribute(testerName, "CreateCount");
+ System.out.println("CreateCount=" + createCount);
+
+
+ assertEquals(20, availableCount);
+ assertEquals(20, maxSize);
+ assertEquals(currentSize, createCount);
+ assertEquals(0, removeCount);
+
+ }
+
+ public void testThreadLocalPoolJmxMetrics() throws Exception
+ {
+ MBeanServerConnection server = getServer();
+ ObjectName testerName = new ObjectName("jboss.j2ee:jar=statelesscreation-test.jar,name=ThreadLocalPoolStatelessBean,service=EJB3");
+ int size = 0;
+
+ int currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
+ assertEquals(0, size);
+
+ size = (Integer)server.getAttribute(testerName, "CreateCount");
+ assertEquals(0, size);
+
+ StatelessRemote stateless = (StatelessRemote)getInitialContext().lookup("ThreadLocalPoolStatelessBean/remote");
+ assertNotNull(stateless);
+ stateless.test();
+
+ currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
+ assertEquals(1, currentSize);
+
size = (Integer)server.getAttribute(testerName, "AvailableCount");
- System.out.println("AvailableCount=" + size);
+ assertEquals(20, size);
size = (Integer)server.getAttribute(testerName, "MaxSize");
- System.out.println("MaxSize=" + size);
+ assertEquals(20, size);
- size = (Integer)server.getAttribute(testerName, "RemoveCount");
- System.out.println("RemoveCount=" + size);
-
size = (Integer)server.getAttribute(testerName, "CreateCount");
- System.out.println("CreateCount=" + size);
- assertEquals(30, size);
+ assertEquals(1, size);
+ runConcurrentTests(30, 1);
+
+ currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
+
+ checkMetrics(server, testerName, currentSize, 20, 20, currentSize, 0);
+
+ for (int i = 1 ; i <= 10 ; ++i)
+ {
+ try
+ {
+ stateless.testException();
+ fail("should have caught EJBException");
+ }
+ catch (javax.ejb.EJBException e)
+ {
+ int removeCount = (Integer)server.getAttribute(testerName, "RemoveCount");
+ System.out.println("RemoveCount=" + removeCount);
+ assertEquals(i, removeCount);
+ }
+ }
+
+ runConcurrentTests(30, 1);
+
+ currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
+
+ checkMetrics(server, testerName, currentSize, 20, 20, currentSize + 10, 10);
+
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ StatelessRemote stateless = (StatelessRemote)getInitialContext().lookup("ThreadLocalPoolStatelessBean/remote");
+ stateless.delay();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ new Thread(r).start();
+
+ Thread.sleep(10 * 1000);
+
+ int maxSize = (Integer)server.getAttribute(testerName, "MaxSize");
+ System.out.println("MaxSize=" + maxSize);
+
+ int availableCount = (Integer)server.getAttribute(testerName, "AvailableCount");
+ System.out.println("AvailableCount=" + availableCount);
+
+ assertEquals(maxSize - 1, availableCount);
}
+ protected void checkMetrics(MBeanServerConnection server, ObjectName testerName, int current, int available, int max, int create, int remove)
+ throws Exception
+ {
+
+ int currentSize = (Integer)server.getAttribute(testerName, "CurrentSize");
+ System.out.println("CurrentSize=" + currentSize);
+
+ int availableCount = (Integer)server.getAttribute(testerName, "AvailableCount");
+ System.out.println("AvailableCount=" + availableCount);
+
+ int maxSize = (Integer)server.getAttribute(testerName, "MaxSize");
+ System.out.println("MaxSize=" + maxSize);
+
+ int createCount = (Integer)server.getAttribute(testerName, "CreateCount");
+ System.out.println("CreateCount=" + createCount);
+
+ int removeCount = (Integer)server.getAttribute(testerName, "RemoveCount");
+ System.out.println("RemoveCount=" + removeCount);
+
+ if (availableCount != maxSize)
+ {
+ System.out.println("Waiting to stabilize ... " + availableCount + "<" + maxSize);
+ Thread.sleep(1 * 60 * 1000);
+ availableCount = (Integer)server.getAttribute(testerName, "AvailableCount");
+ }
+
+ assertEquals("CurrentSize", current, currentSize);
+ assertEquals("AvailableCount", available, availableCount);
+ assertEquals("MaxSize", max, maxSize);
+ assertEquals("CreateCount", create, createCount);
+ assertEquals("RemoveCount", remove, removeCount);
+
+ }
+
+ protected void runConcurrentTests(int numThreads, int sleepSecs) throws Exception
+ {
+ for (int i = 0 ; i < numThreads ; ++i)
+ {
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ StatelessRemote stateless = (StatelessRemote)getInitialContext().lookup("ThreadLocalPoolStatelessBean/remote");
+ for (int i = 0 ; i < 25 ; ++i)
+ {
+ stateless.test();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ new Thread(r).start();
+ }
+
+ Thread.sleep(sleepSecs * 60 * 1000);
+ }
+
public static Test suite() throws Exception
{
- return getDeploySetup(MetricsUnitTestCase.class, "statelesscreation-connectors-service.xml, statelesscreation-test.jar");
+ return getDeploySetup(MetricsUnitTestCase.class, "statelesscreation-test.jar");
}
-
}
More information about the jboss-cvs-commits
mailing list