[jboss-cvs] JBossAS SVN: r64713 - in branches/JBPAPP_4_2/ejb3: src/main/org/jboss/ejb3 and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 20 14:43:01 EDT 2007
Author: bdecoste
Date: 2007-08-20 14:43:01 -0400 (Mon, 20 Aug 2007)
New Revision: 64713
Added:
branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/InfinitePool.java
branches/JBPAPP_4_2/ejb3/src/resources/test-configs/statelesscreation/
branches/JBPAPP_4_2/ejb3/src/resources/test-configs/statelesscreation/deploy/
branches/JBPAPP_4_2/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3.deployer/
branches/JBPAPP_4_2/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3.deployer/META-INF/
branches/JBPAPP_4_2/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3.deployer/META-INF/jboss-service.xml
branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/
branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java
branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/
branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java
Modified:
branches/JBPAPP_4_2/ejb3/build-test.xml
branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
Log:
[EJBTHREE-1031] merged Carlo's ThreadLocalPool changes for runaway SLSB instance creation
Modified: branches/JBPAPP_4_2/ejb3/build-test.xml
===================================================================
--- branches/JBPAPP_4_2/ejb3/build-test.xml 2007-08-20 18:31:52 UTC (rev 64712)
+++ branches/JBPAPP_4_2/ejb3/build-test.xml 2007-08-20 18:43:01 UTC (rev 64713)
@@ -2759,6 +2759,19 @@
<copy file="${build.lib}/stateless-test.jar" tofile="${build.lib}/stateless-test.ejb3"/>
</target>
+ <target name="statelesscreation"
+ description="Builds all jar files."
+ depends="compile-classes">
+
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/statelesscreation-test.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/statelesscreation/*.class"/>
+ </fileset>
+ </jar>
+ </target>
+
<target name="defaultremotebindings"
description="Builds all jar files."
depends="compile-classes">
@@ -3272,7 +3285,7 @@
</copy>
</target>
- <target name="jars" depends="defaultremotebindings, localfromremote, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
+ <target name="jars" depends="statelesscreation, defaultremotebindings, localfromremote, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440,
ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921,
ejbthree959, ejbthree963,
@@ -3555,6 +3568,7 @@
<antcall target="arjuna-test" inheritRefs="true"/>
<antcall target="libdeployment-test" inheritRefs="true"/>
<antcall target="multi-instance-localfromremote-test" inheritRefs="true"/>
+ <antcall target="statelesscreation-test" inheritRefs="true"/>
</target>
<target name="no-start-jboss-tests" depends="init" description="Execute all tests">
@@ -4129,6 +4143,26 @@
</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}"/>
+ </target>
+
<target name="multi-instance-localfromremote-test">
<create-config baseconf="default" newconf="localfromremote1">
<patternset>
Added: branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/InfinitePool.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/InfinitePool.java (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/InfinitePool.java 2007-08-20 18:43:01 UTC (rev 64713)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * A pool that has no constraints.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class InfinitePool extends AbstractPool
+{
+ private List<BeanContext> active = new LinkedList<BeanContext>();
+
+ public void destroy()
+ {
+ for(BeanContext ctx : active)
+ {
+ // call super.remove or else get concurrent modification
+ super.remove(ctx);
+ }
+ active = null;
+ }
+
+ public BeanContext get()
+ {
+ BeanContext ctx = create();
+ synchronized(active)
+ {
+ active.add(ctx);
+ }
+ return ctx;
+ }
+
+ public BeanContext get(Class[] initTypes, Object[] initValues)
+ {
+ BeanContext ctx = create(initTypes, initValues);
+ synchronized(active)
+ {
+ active.add(ctx);
+ }
+ return ctx;
+ }
+
+ public int getAvailableCount()
+ {
+ return -1;
+ }
+
+ public int getCurrentSize()
+ {
+ return active.size();
+ }
+
+ public int getMaxSize()
+ {
+ return -1;
+ }
+
+ public void release(BeanContext ctx)
+ {
+ remove(ctx);
+ }
+
+ public void remove(BeanContext ctx)
+ {
+ synchronized(active)
+ {
+ active.remove(ctx);
+ }
+
+ super.remove(ctx);
+ }
+
+ public void setMaxSize(int maxSize)
+ {
+ }
+
+}
Modified: branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-08-20 18:31:52 UTC (rev 64712)
+++ branches/JBPAPP_4_2/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-08-20 18:43:01 UTC (rev 64713)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3;
+import org.jboss.injection.Injector;
import org.jboss.lang.ref.WeakThreadLocal;
import org.jboss.logging.Logger;
@@ -33,28 +34,48 @@
*/
public class ThreadlocalPool extends AbstractPool
{
- private static final Logger log = Logger.getLogger(ThreadlocalPool.class);
+private static final Logger log = Logger.getLogger(ThreadlocalPool.class);
- protected WeakThreadLocal<BeanContext> pool = new WeakThreadLocal<BeanContext>();
+ protected Pool delegate = new InfinitePool();
+ protected WeakThreadLocal<BeanContext> currentBeanContext = new WeakThreadLocal<BeanContext>();
+
+ private int count = 0;
public ThreadlocalPool()
{
}
+ protected BeanContext create()
+ {
+ return delegate.get();
+ }
+
+ protected BeanContext create(Class[] initTypes, Object[] initValues)
+ {
+ return delegate.get(initTypes, initValues);
+ }
+
+ public void discard(BeanContext obj)
+ {
+ delegate.discard(obj);
+ }
+
public void destroy()
{
log.trace("destroying pool");
+ delegate.destroy();
+
// This really serves little purpose, because we want the whole thread local map to die
- pool.remove();
+ currentBeanContext.remove();
}
public BeanContext get()
{
- BeanContext ctx = pool.get();
+ BeanContext ctx = currentBeanContext.get();
if (ctx != null)
{
- pool.set(null);
+ currentBeanContext.set(null);
return ctx;
}
@@ -64,10 +85,10 @@
public BeanContext get(Class[] initTypes, Object[] initValues)
{
- BeanContext ctx = pool.get();
+ BeanContext ctx = currentBeanContext.get();
if (ctx != null)
{
- pool.set(null);
+ currentBeanContext.set(null);
return ctx;
}
@@ -75,29 +96,54 @@
return ctx;
}
+ public void initialize(Container container, Class contextClass, Class beanClass, int maxSize, long timeout)
+ {
+ delegate.initialize(container, contextClass, beanClass, maxSize, timeout);
+ }
+
public void release(BeanContext ctx)
{
- if (pool.get() != null)
+ if (currentBeanContext.get() != null)
remove(ctx);
else
- pool.set(ctx);
+ currentBeanContext.set(ctx);
}
+ public void remove(BeanContext ctx)
+ {
+ delegate.remove(ctx);
+ }
+
public int getCurrentSize()
{
- return -1;
+ return -1;
}
public int getAvailableCount()
{
- return -1;
+ return -1;
}
+ public int getCreateCount()
+ {
+ return delegate.getCreateCount();
+ }
+
public int getMaxSize()
{
- return -1;
+ return -1;
}
+ public int getRemoveCount()
+ {
+ return delegate.getRemoveCount();
+ }
+
+ public void setInjectors(Injector[] injectors)
+ {
+ delegate.setInjectors(injectors);
+ }
+
public void setMaxSize(int maxSize)
{
}
Added: branches/JBPAPP_4_2/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3.deployer/META-INF/jboss-service.xml
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3.deployer/META-INF/jboss-service.xml (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/resources/test-configs/statelesscreation/deploy/ejb3.deployer/META-INF/jboss-service.xml 2007-08-20 18:43:01 UTC (rev 64713)
@@ -0,0 +1,312 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss EJB3Deployer
+
+ $Id: jboss-service.xml 63100 2007-05-16 18:02:32Z bdecoste $
+-->
+<server>
+
+ <!--mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
+ <depends>jboss.aop:service=AspectDeployer</depends>
+ <attribute name="InvokerLocator">socket://${jboss.bind.address}:3873</attribute>
+ <attribute name="Configuration">
+ <handlers>
+ <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
+ </handlers>
+ </attribute>
+ </mbean-->
+
+ <!-- The following is sample configuration for modifying the Connector -->
+ <mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
+ <depends>jboss.aop:service=AspectDeployer</depends>
+ <attribute name="Configuration">
+ <config>
+ <invoker transport="socket">
+ <attribute name="numAcceptThreads">1</attribute>
+ <attribute name="maxPoolSize">30</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">200</attribute>
+ </invoker>
+ <handlers>
+ <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.ejb3.JarsIgnoredForScanning" name="jboss.ejb3:service=JarsIgnoredForScanning">
+ <attribute name="IgnoredJars">
+ snmp-adaptor.jar,
+ otherimages.jar,
+ applet.jar,
+ jcommon.jar,
+ console-mgr-classes.jar,
+ jfreechart.jar,
+ juddi-service.jar,
+ wsdl4j.jar,
+ commons-collections.jar,
+ commons-pool.jar,
+ juddi.jar,
+ commons-discovery.jar,
+ uddi4j.jar,
+ axis.jar,
+ commons-dbcp.jar,
+ jboss-juddiaxis.jar,
+ trove.jar,
+ javassist.jar,
+ jboss-aop-jdk50.jar,
+ jboss-aspect-library-jdk50.jar,
+ ejb3-persistence.jar,
+ commons-validator-1.1.3.jar,
+ commons-collections.jar,
+ commons-fileupload.jar,
+ commons-pool.jar,
+ hibernate-entitymanager.jar,
+ jboss-ejb3x.jar,
+ commons-digester-1.6.jar,
+ cglib-2.1.1.jar,
+ commons-discovery.jar,
+ jboss-annotations-ejb3.jar,
+ jaxen-1.1-beta-4.jar,
+ hibernate-annotations.jar,
+ commons-httpclient.jar,
+ commons-logging.jar,
+ commons-vfs.jar,
+ hibernate3.jar,
+ commons-logging-api.jar,
+ asm.jar,
+ asm-attrs.jar,
+ commons-lang-2.0.jar,
+ commons-beanutils.jar,
+ jboss-ejb3.jar,
+ dom4j.jar,
+ commons-codec-1.2.jar,
+ wsdl4j.jar,
+ xmlsec.jar,
+ jbossws.jar,
+ jboss-bean-deployer.jar,
+ jboss-microcontainer.jar,
+ jboss-dependency.jar,
+ jboss-container.jar,
+ tomcat-coyote.jar,
+ commons-collections.jar,
+ myfaces.jar,
+ jstl.jar,
+ commons-digester-1.6.jar,
+ myfaces-impl.jar,
+ commons-beanutils.jar,
+ myfaces-jsf-api.jar,
+ commons-codec-1.2.jar,
+ catalina-optional.jar,
+ tomcat-util.jar,
+ jasper-compiler.jar,
+ commons-el.jar,
+ jasper-compiler-jdt.jar,
+ tomcat-http.jar,
+ catalina-manager.jar,
+ jasper-runtime.jar,
+ tomcat55-service.jar,
+ servlets-invoker.jar,
+ catalina.jar,
+ naming-resources.jar,
+ servlets-default.jar,
+ tomcat-ajp.jar,
+ commons-modeler.jar,
+ tomcat-apr.jar,
+ servlets-webdav.jar
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.ejb3.EJB3Deployer" name="jboss.ejb3:service=EJB3Deployer" xmbean-dd="">
+
+ <attribute name="DeployEjb3ExtensionOnly">false</attribute>
+
+ <!-- Inline XMBean Descriptor BEGIN -->
+ <xmbean>
+ <description>The EJB3Deployer responsible for ejb3 deployment</description>
+ <descriptors>
+ <interceptors>
+ <!-- comment out DynamicInterceptor to disable dynamic addition of interceptors -->
+ <interceptor code="org.jboss.mx.interceptor.DynamicInterceptor"/>
+ </interceptors>
+ </descriptors>
+ <class>org.jboss.ejb3.EJB3Deployer</class>
+
+ <!-- ServiceMBean attributes -->
+ <attribute access="read-only" getMethod="getName">
+ <description>The class name of the MBean</description>
+ <name>Name</name>
+ <type>java.lang.String</type>
+ </attribute>
+
+ <attribute access="read-only" getMethod="getState">
+ <description>The status of the MBean</description>
+ <name>State</name>
+ <type>int</type>
+ </attribute>
+
+ <attribute access="read-only" getMethod="getStateString">
+ <description>The status of the MBean in text form</description>
+ <name>StateString</name>
+ <type>java.lang.String</type>
+ </attribute>
+
+ <!-- SubDeployerMBean attributes -->
+ <attribute access="read-only" getMethod="getServiceName">
+ <description>The ObjectName of the Subdeployer</description>
+ <name>ServiceName</name>
+ <type>javax.management.ObjectName</type>
+ </attribute>
+
+ <attribute access="read-write" getMethod="getSuffixes" setMethod="setSuffixes">
+ <description>The suffixes of interest to this deployer</description>
+ <name>Suffixes</name>
+ <type>[Ljava.lang.String;</type>
+ </attribute>
+
+ <attribute access="read-write" getMethod="getRelativeOrder" setMethod="setRelativeOrder">
+ <description>The relative order of the suffixes in the global suffixes list</description>
+ <name>RelativeOrder</name>
+ <type>int</type>
+ </attribute>
+
+ <!-- EJB3DeployerMBean attributes -->
+ <attribute access="read-only" getMethod="getDefaultProperties">
+ <name>DefaultProperties</name>
+ <type>java.util.Properties</type>
+ </attribute>
+
+ <attribute access="read-write" getMethod="getDeployEjb3ExtensionOnly" setMethod="setDeployEjb3ExtensionOnly">
+ <description>If true, .jars will not be examined for annotations, 3.0 descriptors</description>
+ <name>DeployEjb3ExtensionOnly</name>
+ <type>boolean</type>
+ </attribute>
+
+ <attribute access="write-only" setMethod="setJarsIgnoredForScanning">
+ <description>mbean that has list of jars to ignore</description>
+ <name>JarsIgnoredForScanning</name>
+ <type>org.jboss.ejb3.JarsIgnoredForScanningMBean</type>
+ </attribute>
+
+ <!-- ServiceMBean operations -->
+ <operation>
+ <description>Standard MBean lifecycle method</description>
+ <name>create</name>
+ </operation>
+
+ <operation>
+ <description>The start lifecycle operation</description>
+ <name>start</name>
+ </operation>
+
+ <operation>
+ <description>The stop lifecycle operation</description>
+ <name>stop</name>
+ </operation>
+
+ <operation>
+ <description>The destroy lifecycle operation</description>
+ <name>destroy</name>
+ </operation>
+
+ <operation>
+ <description>The detyped lifecycle operation (for internal use only)</description>
+ <name>jbossInternalLifecycle</name>
+ <parameter>
+ <description>The lifecycle operation</description>
+ <name>method</name>
+ <type>java.lang.String</type>
+ </parameter>
+ <return-type>void</return-type>
+ </operation>
+
+ <!-- SubDeployerMBean operations -->
+ <operation>
+ <description>Accept a module for deployment</description>
+ <name>accepts</name>
+ <parameter>
+ <name>info</name>
+ <type>org.jboss.deployment.DeploymentInfo</type>
+ </parameter>
+ <return-type>boolean</return-type>
+ </operation>
+
+ <operation>
+ <description>Initialize deployment step</description>
+ <name>init</name>
+ <parameter>
+ <name>info</name>
+ <type>org.jboss.deployment.DeploymentInfo</type>
+ </parameter>
+ </operation>
+
+ <operation>
+ <description>Create deployment step</description>
+ <name>create</name>
+ <parameter>
+ <name>info</name>
+ <type>org.jboss.deployment.DeploymentInfo</type>
+ </parameter>
+ </operation>
+
+ <operation>
+ <description>Start deployment step</description>
+ <name>start</name>
+ <parameter>
+ <name>info</name>
+ <type>org.jboss.deployment.DeploymentInfo</type>
+ </parameter>
+ </operation>
+
+ <operation>
+ <description>Stop deployment step</description>
+ <name>stop</name>
+ <parameter>
+ <name>info</name>
+ <type>org.jboss.deployment.DeploymentInfo</type>
+ </parameter>
+ </operation>
+
+ <operation>
+ <description>Destroy deployment step</description>
+ <name>destroy</name>
+ <parameter>
+ <name>info</name>
+ <type>org.jboss.deployment.DeploymentInfo</type>
+ </parameter>
+ </operation>
+
+ <!-- Interceptable operations -->
+ <operation>
+ <description>Add dynamically an operation interceptor</description>
+ <name>addOperationInterceptor</name>
+ <parameter>
+ <description>The Interceptor</description>
+ <name>interceptor</name>
+ <type>org.jboss.mx.interceptor.Interceptor</type>
+ </parameter>
+ </operation>
+
+ <operation>
+ <description>Remove dynamically an operation interceptor</description>
+ <name>removeOperationInterceptor</name>
+ <parameter>
+ <description>The Interceptor</description>
+ <name>interceptor</name>
+ <type>org.jboss.mx.interceptor.Interceptor</type>
+ </parameter>
+ </operation>
+ </xmbean>
+ <!-- Inline XMBean Descriptor END -->
+
+ <depends>jboss.aop:service=AspectDeployer</depends>
+ <depends>jboss.ejb:service=EJBDeployer</depends>
+ <depends optional-attribute-name="JarsIgnoredForScanning" proxy-type="org.jboss.ejb3.JarsIgnoredForScanningMBean">jboss.ejb3:service=JarsIgnoredForScanning</depends>
+ </mbean>
+
+</server>
Added: branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyRemote.java 2007-08-20 18:43:01 UTC (rev 64713)
@@ -0,0 +1,30 @@
+/*
+ * 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 DestroyRemote
+{
+ int getBeanCount();
+}
Added: branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java 2007-08-20 18:43:01 UTC (rev 64713)
@@ -0,0 +1,57 @@
+/*
+ * 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.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+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(DestroyRemote.class)
+public class DestroyStatelessBean implements DestroyRemote
+{
+ private static final Logger log = Logger.getLogger(DestroyStatelessBean.class);
+
+ private static int beanCount = 0;
+
+ public int getBeanCount()
+ {
+ return beanCount;
+ }
+
+ @PostConstruct
+ public void construct()
+ {
+ ++beanCount;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ --beanCount;
+ }
+}
Added: branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java (rev 0)
+++ branches/JBPAPP_4_2/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/unit/MetricsUnitTestCase.java 2007-08-20 18:43:01 UTC (rev 64713)
@@ -0,0 +1,105 @@
+/*
+ * 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.unit;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.test.statelesscreation.DestroyRemote;
+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
+{
+ private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
+
+ public MetricsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSLSBCount() throws Exception
+ {
+ DestroyRemote slsb = (DestroyRemote)getInitialContext().lookup("DestroyStatelessBean/remote");
+ assertNotNull(slsb);
+ assertEquals(1, slsb.getBeanCount());
+
+ for (int i = 0 ; i < 50 ; ++i)
+ {
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ DestroyRemote slsb = (DestroyRemote)getInitialContext().lookup("DestroyStatelessBean/remote");
+ for (int i = 0 ; i < 100 ; ++i)
+ {
+ slsb.getBeanCount();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ new Thread(r).start();
+ }
+
+ Thread.sleep(1 * 60 * 1000);
+
+ 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);
+
+ size = (Integer)server.getAttribute(testerName, "AvailableCount");
+ System.out.println("AvailableCount=" + size);
+
+ size = (Integer)server.getAttribute(testerName, "MaxSize");
+ System.out.println("MaxSize=" + 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);
+
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(MetricsUnitTestCase.class, "statelesscreation-test.jar");
+ }
+
+}
More information about the jboss-cvs-commits
mailing list