[jboss-cvs] JBossAS SVN: r67042 - in trunk/ejb3/src: main/org/jboss/ejb3 and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 13 15:45:40 EST 2007
Author: ALRubinger
Date: 2007-11-13 15:45:39 -0500 (Tue, 13 Nov 2007)
New Revision: 67042
Added:
trunk/ejb3/src/main/org/jboss/annotation/ejb/Pool.java
trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/
trunk/ejb3/src/main/org/jboss/ejb3/pool/AbstractPool.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/Pool.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryNotRegisteredException.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryRegistry.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPool.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPoolFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPool.java
trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPoolFactory.java
Removed:
trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java
trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClassImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java
trunk/ejb3/src/main/org/jboss/ejb3/Pool.java
trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java
trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/Container.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java
trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
trunk/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessInstanceInterceptor.java
trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml
trunk/ejb3/src/resources/ejb3-interceptors-aop.xml
trunk/ejb3/src/resources/test/defaultremotebindings/default-ejb3-interceptors-aop.xml
trunk/ejb3/src/resources/test/interceptors2/META-INF/jboss.xml
trunk/ejb3/src/resources/test/strictpool/META-INF/jboss.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/aspectdomain/DeploymentDescriptorStatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/aspectdomain/StatefulBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors2/AnnotatedOnlySLSB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/JMSMDBBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/ExpirationTestMDB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/MismatchedQueueMDB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/OverrideTestMDB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/QueueTestMDB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateless/DefaultPoolStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/stateless/StrictMaxPoolStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/ThreadLocalPoolStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/BogusPool.java
trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/OverrideStrictlyPooledMDB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/OverrideStrictlyPooledSessionBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledMDB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledMDB2.java
trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledSessionBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java
trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java
Log:
Restructured @Pool to resolve API Leakage
Copied: trunk/ejb3/src/main/org/jboss/annotation/ejb/Pool.java (from rev 66997, trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/ejb/Pool.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/annotation/ejb/Pool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,42 @@
+/*
+ * 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.annotation.ejb;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation for specifying the pool class to manage thread pooling for a bean
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE})
+public @interface Pool
+{
+ String value();
+ int maxSize() default 30;
+ long timeout()default Long.MAX_VALUE;
+}
Property changes on: trunk/ejb3/src/main/org/jboss/annotation/ejb/Pool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -1,44 +0,0 @@
-/*
- * 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.annotation.ejb;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.jboss.ejb3.Pool;
-
-/**
- * Annotation for specifying the pool class to manage thread pooling for a bean
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
- at Retention(RetentionPolicy.RUNTIME)
- at Target({ElementType.TYPE})
-public @interface PoolClass
-{
- Class<? extends Pool> value();
- int maxSize() default 30;
- long timeout()default Long.MAX_VALUE;
-}
Deleted: trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClassImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClassImpl.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClassImpl.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -1,85 +0,0 @@
-/*
- * 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.annotation.ejb;
-
-import java.lang.annotation.Annotation;
-
-/**
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public class PoolClassImpl implements PoolClass
-{
- public Class value;
- public int maxSize = 30;
- public long timeout = Long.MAX_VALUE;
-
- public PoolClassImpl()
- {
- }
-
- public Class value()
- {
- return value;
- }
-
- public void setValue(Class value)
- {
- this.value = value;
- }
-
- public int maxSize()
- {
- return maxSize;
- }
-
- public void setMaxSize(int maxSize)
- {
- this.maxSize = maxSize;
- }
-
- public long timeout()
- {
- return timeout;
- }
-
- public void setTimeout(long timeout)
- {
- this.timeout = timeout;
- }
-
- public Class<? extends Annotation> annotationType()
- {
- return PoolClass.class;
- }
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer(100);
- sb.append("[PoolClassImpl:");
- sb.append("value=").append(value);
- sb.append(", maxSize=").append(maxSize);
- sb.append(", timeout=").append(timeout);
- sb.append("]");
- return sb.toString();
- }
-}
Copied: trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolImpl.java (from rev 67029, trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolClassImpl.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolImpl.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolImpl.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,85 @@
+/*
+ * 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.annotation.ejb;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class PoolImpl implements Pool
+{
+ public String value;
+ public int maxSize = 30;
+ public long timeout = Long.MAX_VALUE;
+
+ public PoolImpl()
+ {
+ }
+
+ public String value()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public int maxSize()
+ {
+ return maxSize;
+ }
+
+ public void setMaxSize(int maxSize)
+ {
+ this.maxSize = maxSize;
+ }
+
+ public long timeout()
+ {
+ return timeout;
+ }
+
+ public void setTimeout(long timeout)
+ {
+ this.timeout = timeout;
+ }
+
+ public Class<? extends Annotation> annotationType()
+ {
+ return Pool.class;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append("[PoolClassImpl:");
+ sb.append("value=").append(value);
+ sb.append(", maxSize=").append(maxSize);
+ sb.append(", timeout=").append(timeout);
+ sb.append("]");
+ return sb.toString();
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/annotation/ejb/PoolImpl.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -1,153 +0,0 @@
-/*
- * 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;
-
-import org.jboss.injection.Injector;
-import org.jboss.logging.Logger;
-
-/**
- * The base of all pool implementations.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision$
- */
-public abstract class AbstractPool implements Pool
-{
- @SuppressWarnings("unused")
- private static final Logger log = Logger.getLogger(AbstractPool.class);
-
- protected Injector[] injectors;
- protected Container container;
- protected int createCount = 0;
- protected int removeCount = 0;
-
- public AbstractPool()
- {
-
- }
-
- public int getCreateCount()
- {
- return createCount;
- }
-
- public int getRemoveCount()
- {
- return removeCount;
- }
-
- public void initialize(Container container, int maxSize, long timeout)
- {
- assert container != null : "container is null";
-
- this.container = container;
- }
-
- public abstract void setMaxSize(int maxSize);
-
- @Deprecated
- protected BeanContext<?> create()
- {
- return create(null, null);
- }
-
- protected BeanContext<?> create(Class[] initTypes, Object[] initValues)
- {
- BeanContext ctx;
- ctx = createBeanContext();
-// if (ctx instanceof StatefulBeanContext)
-// {
-// StatefulBeanContext sfctx = (StatefulBeanContext) ctx;
-// // Tell context how to handle replication
-// Advisor advisor = (Advisor) container;
-// CacheConfig config = (CacheConfig) advisor.resolveAnnotation(CacheConfig.class);
-// if (config != null)
-// {
-// sfctx.setReplicationIsPassivation(config.replicationIsPassivation());
-// }
-// // this is for propagated extended PC's
-// ctx = sfctx = sfctx.pushContainedIn();
-// }
- container.pushContext(ctx);
- try
- {
- if (injectors != null)
- {
- for (int i = 0; i < injectors.length; i++)
- {
- injectors[i].inject(ctx);
- }
- }
-
- ctx.initialiseInterceptorInstances();
-
- }
- finally
- {
- container.popContext();
-// if (ctx instanceof StatefulBeanContext)
-// {
-// // this is for propagated extended PC's
-// StatefulBeanContext sfctx = (StatefulBeanContext) ctx;
-// sfctx.popContainedIn();
-// }
- }
-
- container.invokePostConstruct(ctx, initValues);
-
- //TODO This needs to be reimplemented as replacement for create() on home interface
- container.invokeInit(ctx.getInstance(), initTypes, initValues);
-
- ++createCount;
-
- return ctx;
- }
-
- private BeanContext createBeanContext()
- {
- return container.createBeanContext();
- }
-
- public void remove(BeanContext ctx)
- {
- try
- {
- container.invokePreDestroy(ctx);
- }
- finally
- {
- ctx.remove();
- ++removeCount;
- }
- }
-
- public void discard(BeanContext<?> ctx)
- {
- remove(ctx);
- }
-
- public void setInjectors(Injector[] injectors)
- {
- this.injectors = injectors;
- }
-}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Container.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Container.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Container.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -27,6 +27,7 @@
import javax.naming.Context;
import javax.naming.InitialContext;
+import org.jboss.ejb3.pool.Pool;
import org.jboss.ejb3.statistics.InvocationStatistics;
/**
Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -56,7 +56,6 @@
import javax.naming.StringRefAddr;
import org.jboss.annotation.ejb.Clustered;
-import org.jboss.annotation.ejb.PoolClass;
import org.jboss.annotation.security.SecurityDomain;
import org.jboss.aop.AspectManager;
import org.jboss.aop.ClassContainer;
@@ -74,6 +73,7 @@
import org.jboss.ejb3.javaee.JavaEEComponent;
import org.jboss.ejb3.javaee.JavaEEComponentHelper;
import org.jboss.ejb3.javaee.JavaEEModule;
+import org.jboss.ejb3.pool.Pool;
import org.jboss.ejb3.security.JaccHelper;
import org.jboss.ejb3.security.SecurityDomainManager;
import org.jboss.ejb3.statistics.InvocationStatistics;
@@ -797,11 +797,11 @@
protected void initializePool() throws Exception
{
- PoolClass poolClass = (PoolClass) resolveAnnotation(PoolClass.class);
- Class<? extends Pool> poolClazz = poolClass.value();
- int maxSize = poolClass.maxSize();
- long timeout = poolClass.timeout();
- pool = poolClazz.newInstance();
+ org.jboss.annotation.ejb.Pool poolAnnotation = getAnnotation(org.jboss.annotation.ejb.Pool.class);
+ String registeredPoolName = poolAnnotation.value();
+ int maxSize = poolAnnotation.maxSize();
+ long timeout = poolAnnotation.timeout();
+ pool = this.deployment.getDeployer().getPoolFactoryRegistry().getPoolFactory(registeredPoolName).createPool();
pool.initialize(this, maxSize, timeout);
resolveInjectors();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -86,8 +86,8 @@
import org.jboss.annotation.ejb.ManagementImpl;
import org.jboss.annotation.ejb.MessageProperties;
import org.jboss.annotation.ejb.MessagePropertiesImpl;
-import org.jboss.annotation.ejb.PoolClass;
-import org.jboss.annotation.ejb.PoolClassImpl;
+import org.jboss.annotation.ejb.Pool;
+import org.jboss.annotation.ejb.PoolImpl;
import org.jboss.annotation.ejb.Producers;
import org.jboss.annotation.ejb.RemoteBinding;
import org.jboss.annotation.ejb.RemoteBindingImpl;
@@ -1300,10 +1300,10 @@
{
PoolConfigMetaData config = enterpriseBean.getPoolConfig();
- PoolClassImpl poolAnnotation = new PoolClassImpl();
+ PoolImpl poolAnnotation = new PoolImpl();
- if (config.getPoolClass() != null)
- poolAnnotation.setValue(di.getClassLoader().loadClass(config.getPoolClass()));
+ if (config.getValue() != null && !config.getValue().trim().equals(""))
+ poolAnnotation.setValue(config.getValue());
if (config.getMaxSize() != null)
poolAnnotation.setMaxSize(config.getMaxSize());
@@ -1311,7 +1311,7 @@
if (config.getTimeout() != null)
poolAnnotation.setTimeout(config.getTimeout());
- addClassAnnotation(container, PoolClass.class, poolAnnotation);
+ addClassAnnotation(container, Pool.class, poolAnnotation);
}
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -24,11 +24,13 @@
import java.util.LinkedList;
import java.util.List;
+import org.jboss.ejb3.pool.AbstractPool;
+
/**
* A pool that has no constraints.
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
*/
public class InfinitePool extends AbstractPool
{
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Pool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Pool.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Pool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -1,80 +0,0 @@
-/*
- * 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;
-
-import org.jboss.injection.Injector;
-
-/**
- * Minimally a pool acts as a factory for a bean. It will handle callbacks
- * to ejbCreate and ejbRemove as well.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface Pool
-{
- /**
- * Creates if no object is available in pool. ejbCreate will be called if created
- */
- BeanContext<?> get();
-
- BeanContext<?> get(Class[] initTypes, Object[] initValues);
-
- /**
- * Put bean back in pool
- */
- void release(BeanContext obj);
-
- /**
- * Destroy bean. ejbRemove callback is executed
- */
- void remove(BeanContext obj);
-
- /**
- * Discard the bean. Called in different context as remove. If there is a system exception this is
- * called.
- *
- * @param obj
- */
- void discard(BeanContext<?> obj);
-
- public void setInjectors(Injector[] injectors);
-
- void initialize(Container container, int maxSize, long timeout);
-
- int getCurrentSize();
-
- int getAvailableCount();
-
- int getMaxSize();
-
- void setMaxSize(int maxSize);
-
- int getCreateCount();
-
- int getRemoveCount();
-
- /**
- * Destroy the pool.
- */
- void destroy();
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -1,278 +0,0 @@
-/*
- * 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;
-
-import java.util.LinkedList;
-import javax.ejb.EJBException;
-import org.jboss.logging.Logger;
-import EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision$
- */
-public class StrictMaxPool
- extends AbstractPool
-{
-// Constants -----------------------------------------------------
- public static final int DEFAULT_MAX_SIZE = 30;
- public static final long DEFAULT_TIMEOUT = Long.MAX_VALUE;
-
- // Attributes ----------------------------------------------------
- /**
- * A FIFO semaphore that is set when the strict max size behavior is in effect.
- * When set, only maxSize instances may be active and any attempt to get an
- * instance will block until an instance is freed.
- */
- private FIFOSemaphore strictMaxSize;
- private int inUse = 0;
- /**
- * The time in milliseconds to wait for the strictMaxSize semaphore.
- */
- private long strictTimeout;
-
- /**
- * The pool data structure
- */
- protected LinkedList pool = new LinkedList();
- /**
- * The maximum number of instances allowed in the pool
- */
- protected int maxSize = 30;
-
- Logger log = Logger.getLogger(StrictMaxPool.class);
-
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- /**
- * super.initialize() must have been called in advance
- */
- public void initialize(Container container, int maxSize, long timeout)
- {
- super.initialize(container, maxSize, timeout);
- this.maxSize = maxSize;
- this.strictMaxSize = new FIFOSemaphore(maxSize);
- this.strictTimeout = timeout;
- }
-
- public int getCurrentSize()
- {
- return getCreateCount() - getRemoveCount();
- }
-
- public int getAvailableCount()
- {
- return maxSize - inUse;
- }
-
- public int getMaxSize()
- {
- return maxSize;
- }
-
- public void setMaxSize(int maxSize)
- {
- this.maxSize = maxSize;
- this.strictMaxSize = new FIFOSemaphore(maxSize);
- }
-
- /**
- * Get an instance without identity.
- * Can be used by finders,create-methods, and activation
- *
- * @return Context /w instance
- */
- public BeanContext get()
- {
- 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();
-
- }
-
- 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);
- }
-
- /**
- * Return an instance after invocation.
- * <p/>
- * Called in 2 cases:
- * a) Done with finder method
- * b) Just removed
- *
- * @param ctx
- */
- public void release(BeanContext ctx)
- {
- if (log.isTraceEnabled())
- {
- String msg = pool.size() + "/" + maxSize + " Free instance:" + this
- + "#" + container.getBeanClass();
- log.trace(msg);
- }
-
- try
- {
- // Add the unused context back into the pool
- boolean removeIt = false;
- synchronized (pool)
- {
- if (pool.size() < maxSize)
- {
- pool.addFirst(ctx);
- }
- else
- {
- removeIt = true;
- }
- }
- if (removeIt) remove(ctx);
- // If we block when maxSize instances are in use, invoke release on strictMaxSize
- strictMaxSize.release();
- --inUse;
- }
- catch (Exception ignored)
- {
- }
-
- }
-
- public void destroy()
- {
- freeAll();
- }
-
- public void discard(BeanContext ctx)
- {
- if (log.isTraceEnabled())
- {
- String msg = "Discard instance:" + this + "#" + ctx
- + "#" + container.getBeanClass();
- log.trace(msg);
- }
-
- // If we block when maxSize instances are in use, invoke release on strictMaxSize
- strictMaxSize.release();
- --inUse;
-
- // Throw away, unsetContext()
- super.discard(ctx);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
- /*
- protected void destroy() throws Exception
- {
- freeAll();
- this.container = null;
- }
- */
-
- // Private -------------------------------------------------------
-
- /**
- * At undeployment we want to free completely the pool.
- */
- private void freeAll()
- {
- LinkedList clone = (LinkedList) pool.clone();
- for (int i = 0; i < clone.size(); i++)
- {
- BeanContext bc = (BeanContext) clone.get(i);
- // Clear TX so that still TX entity pools get killed as well
- discard(bc);
- }
- pool.clear();
- inUse = 0;
-
- }
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -1,184 +0,0 @@
-/*
- * 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;
-
-import org.jboss.injection.Injector;
-import org.jboss.lang.ref.WeakThreadLocal;
-import org.jboss.logging.Logger;
-
-
-/**
- * Pools EJBs within a ThreadLocal.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class ThreadlocalPool implements Pool
-{
-private static final Logger log = Logger.getLogger(ThreadlocalPool.class);
-
- 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 pool.get();
- }
-
- protected BeanContext create(Class[] initTypes, Object[] initValues)
- {
- return pool.get(initTypes, initValues);
- }
-
- public void discard(BeanContext obj)
- {
- pool.discard(obj);
- --inUse;
- }
-
- public void destroy()
- {
- log.trace("destroying pool");
-
- pool.destroy();
-
- // This really serves little purpose, because we want the whole thread local map to die
- currentBeanContext.remove();
-
- inUse = 0;
- }
-
- public BeanContext get()
- {
- BeanContext ctx = null;
-
- synchronized(pool)
- {
- ctx = currentBeanContext.get();
- if (ctx != null)
- {
- currentBeanContext.set(null);
- ++inUse;
- return ctx;
- }
-
- ctx = create();
- ++inUse;
- }
-
- return ctx;
- }
-
- public BeanContext get(Class[] initTypes, Object[] initValues)
- {
- BeanContext ctx = null;
- synchronized(pool)
- {
- ctx = currentBeanContext.get();
- if (ctx != null)
- {
- currentBeanContext.set(null);
- ++inUse;
- return ctx;
- }
-
- ctx = create(initTypes, initValues);
- ++inUse;
- }
-
- return ctx;
- }
-
- public void initialize(Container container, int maxSize, long timeout)
- {
- pool.initialize(container, maxSize, timeout);
- this.maxSize = maxSize;
- }
-
- public void release(BeanContext ctx)
- {
- synchronized(pool)
- {
- if (currentBeanContext.get() != null)
- {
- remove(ctx);
- }
- else
- {
- currentBeanContext.set(ctx);
- }
-
- --inUse;
- }
- }
-
- public void remove(BeanContext ctx)
- {
- pool.remove(ctx);
- }
-
- public int getCurrentSize()
- {
- int size;
- synchronized (pool)
- {
- size = pool.getCreateCount() - pool.getRemoveCount();
- }
- return size;
- }
-
- public int getAvailableCount()
- {
- return maxSize - inUse;
- }
-
- public int getCreateCount()
- {
- return pool.getCreateCount();
- }
-
- public int getMaxSize()
- {
- return maxSize;
- }
-
- public int getRemoveCount()
- {
- return pool.getRemoveCount();
- }
-
- public void setInjectors(Injector[] injectors)
- {
- pool.setInjectors(injectors);
- }
-
- public void setMaxSize(int maxSize)
- {
- this.maxSize = maxSize;
- }
-}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -25,7 +25,7 @@
import javax.ejb.EJBException;
import javax.ejb.NoSuchEJBException;
import org.jboss.ejb3.Container;
-import org.jboss.ejb3.Pool;
+import org.jboss.ejb3.pool.Pool;
import org.jboss.ejb3.stateful.StatefulBeanContext;
/**
Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -34,8 +34,8 @@
import org.jboss.aop.Advisor;
import org.jboss.ejb3.Container;
import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Pool;
import org.jboss.ejb3.cache.StatefulCache;
+import org.jboss.ejb3.pool.Pool;
import org.jboss.ejb3.stateful.StatefulBeanContext;
import org.jboss.logging.Logger;
Modified: trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -52,8 +52,8 @@
import org.jboss.cache.notifications.event.NodePassivatedEvent;
import org.jboss.ejb3.Container;
import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Pool;
import org.jboss.ejb3.cache.ClusteredStatefulCache;
+import org.jboss.ejb3.pool.Pool;
import org.jboss.ejb3.stateful.NestedStatefulBeanContext;
import org.jboss.ejb3.stateful.ProxiedStatefulBeanContext;
import org.jboss.ejb3.stateful.StatefulBeanContext;
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -35,6 +35,9 @@
import org.jboss.ejb3.cache.CacheFactoryRegistry;
import org.jboss.ejb3.cache.Ejb3CacheFactory;
import org.jboss.ejb3.cache.StatefulCache;
+import org.jboss.ejb3.pool.Pool;
+import org.jboss.ejb3.pool.PoolFactory;
+import org.jboss.ejb3.pool.PoolFactoryRegistry;
import org.jboss.kernel.Kernel;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.virtual.VirtualFile;
@@ -63,6 +66,8 @@
private CacheFactoryRegistry<Ejb3CacheFactory<StatefulCache>> cacheFactoryRegistry;
+ private PoolFactoryRegistry<PoolFactory<Pool>> poolFactoryRegistry;
+
public Ejb3Deployer()
{
// TODO: when the annotation scanner deployer comes on, we will always have JBossMetaData
@@ -162,6 +167,16 @@
this.cacheFactoryRegistry = cacheFactoryRegistry;
}
+ public PoolFactoryRegistry<PoolFactory<Pool>> getPoolFactoryRegistry()
+ {
+ return poolFactoryRegistry;
+ }
+
+ public void setPoolFactoryRegistry(PoolFactoryRegistry<PoolFactory<Pool>> poolFactoryRegistry)
+ {
+ this.poolFactoryRegistry = poolFactoryRegistry;
+ }
+
private boolean hasAllowedSuffix(String name)
{
if(allowedSuffixes == null)
Copied: trunk/ejb3/src/main/org/jboss/ejb3/pool/AbstractPool.java (from rev 66997, trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/AbstractPool.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/AbstractPool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,155 @@
+/*
+ * 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.pool;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.injection.Injector;
+import org.jboss.logging.Logger;
+
+/**
+ * The base of all pool implementations.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPool implements Pool
+{
+ @SuppressWarnings("unused")
+ private static final Logger log = Logger.getLogger(AbstractPool.class);
+
+ protected Injector[] injectors;
+ protected Container container;
+ protected int createCount = 0;
+ protected int removeCount = 0;
+
+ public AbstractPool()
+ {
+
+ }
+
+ public int getCreateCount()
+ {
+ return createCount;
+ }
+
+ public int getRemoveCount()
+ {
+ return removeCount;
+ }
+
+ public void initialize(Container container, int maxSize, long timeout)
+ {
+ assert container != null : "container is null";
+
+ this.container = container;
+ }
+
+ public abstract void setMaxSize(int maxSize);
+
+ @Deprecated
+ protected BeanContext<?> create()
+ {
+ return create(null, null);
+ }
+
+ protected BeanContext<?> create(Class[] initTypes, Object[] initValues)
+ {
+ BeanContext ctx;
+ ctx = createBeanContext();
+// if (ctx instanceof StatefulBeanContext)
+// {
+// StatefulBeanContext sfctx = (StatefulBeanContext) ctx;
+// // Tell context how to handle replication
+// Advisor advisor = (Advisor) container;
+// CacheConfig config = (CacheConfig) advisor.resolveAnnotation(CacheConfig.class);
+// if (config != null)
+// {
+// sfctx.setReplicationIsPassivation(config.replicationIsPassivation());
+// }
+// // this is for propagated extended PC's
+// ctx = sfctx = sfctx.pushContainedIn();
+// }
+ container.pushContext(ctx);
+ try
+ {
+ if (injectors != null)
+ {
+ for (int i = 0; i < injectors.length; i++)
+ {
+ injectors[i].inject(ctx);
+ }
+ }
+
+ ctx.initialiseInterceptorInstances();
+
+ }
+ finally
+ {
+ container.popContext();
+// if (ctx instanceof StatefulBeanContext)
+// {
+// // this is for propagated extended PC's
+// StatefulBeanContext sfctx = (StatefulBeanContext) ctx;
+// sfctx.popContainedIn();
+// }
+ }
+
+ container.invokePostConstruct(ctx, initValues);
+
+ //TODO This needs to be reimplemented as replacement for create() on home interface
+ container.invokeInit(ctx.getInstance(), initTypes, initValues);
+
+ ++createCount;
+
+ return ctx;
+ }
+
+ private BeanContext createBeanContext()
+ {
+ return container.createBeanContext();
+ }
+
+ public void remove(BeanContext ctx)
+ {
+ try
+ {
+ container.invokePreDestroy(ctx);
+ }
+ finally
+ {
+ ctx.remove();
+ ++removeCount;
+ }
+ }
+
+ public void discard(BeanContext<?> ctx)
+ {
+ remove(ctx);
+ }
+
+ public void setInjectors(Injector[] injectors)
+ {
+ this.injectors = injectors;
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/AbstractPool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/ejb3/src/main/org/jboss/ejb3/pool/Pool.java (from rev 66997, trunk/ejb3/src/main/org/jboss/ejb3/Pool.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/Pool.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/Pool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,82 @@
+/*
+ * 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.pool;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.injection.Injector;
+
+/**
+ * Minimally a pool acts as a factory for a bean. It will handle callbacks
+ * to ejbCreate and ejbRemove as well.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public interface Pool
+{
+ /**
+ * Creates if no object is available in pool. ejbCreate will be called if created
+ */
+ BeanContext<?> get();
+
+ BeanContext<?> get(Class<?>[] initTypes, Object[] initValues);
+
+ /**
+ * Put bean back in pool
+ */
+ void release(BeanContext<?> obj);
+
+ /**
+ * Destroy bean. ejbRemove callback is executed
+ */
+ void remove(BeanContext<?> obj);
+
+ /**
+ * Discard the bean. Called in different context as remove. If there is a system exception this is
+ * called.
+ *
+ * @param obj
+ */
+ void discard(BeanContext<?> obj);
+
+ public void setInjectors(Injector[] injectors);
+
+ void initialize(Container container, int maxSize, long timeout);
+
+ int getCurrentSize();
+
+ int getAvailableCount();
+
+ int getMaxSize();
+
+ void setMaxSize(int maxSize);
+
+ int getCreateCount();
+
+ int getRemoveCount();
+
+ /**
+ * Destroy the pool.
+ */
+ void destroy();
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/Pool.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactory.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactory.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.pool;
+
+/**
+ * Defines contract for an EJB3 Pool Factory
+ *
+ * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @version $Revision: $
+ */
+public interface PoolFactory<T extends Pool>
+{
+ T createPool();
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryNotRegisteredException.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryNotRegisteredException.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryNotRegisteredException.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.pool;
+
+/**
+ * CacheFactoryNotRegisteredException
+ *
+ * Thrown when attempting to retrieve a cache factory with
+ * unrecognized name from the registry
+ *
+ * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @version $Revision: $
+ */
+public class PoolFactoryNotRegisteredException extends Exception
+{
+
+ // Class Members
+ private static final long serialVersionUID = -881723607135494483L;
+
+ // Constructors
+
+ public PoolFactoryNotRegisteredException()
+ {
+ super();
+ }
+
+ public PoolFactoryNotRegisteredException(String message)
+ {
+ super(message);
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryNotRegisteredException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryRegistry.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryRegistry.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryRegistry.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.pool;
+
+import java.util.Map;
+
+
+/**
+ * Registry for all configured Pool Factory implementations
+ *
+ * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @version $Revision: $
+ */
+public class PoolFactoryRegistry<T extends PoolFactory<Pool>>
+{
+ // Instance Members
+ private Map<String, Class<T>> factories;
+
+ // Accessors / Mutators
+
+ public Map<String, Class<T>> getFactories()
+ {
+ return factories;
+ }
+
+ public void setFactories(Map<String, Class<T>> factories)
+ {
+ this.factories = factories;
+ }
+
+ // Functional Methods
+
+ /**
+ * Obtains the Pool Factory with the specified registered name
+ *
+ * @param name The registered name of the pool factory to retrieve
+ * @return The Pool Factory
+ */
+ public T getPoolFactory(String name) throws PoolFactoryNotRegisteredException
+ {
+ // Obtain cache factory
+ Class<T> poolFactory = this.factories.get(name);
+
+ // Ensure registered
+ if (poolFactory == null)
+ {
+ throw new PoolFactoryNotRegisteredException("Pool Factory with name " + name + " is not registered.");
+ }
+
+ try
+ {
+ // Return
+ return poolFactory.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException("Error in instanciating pool factory " + poolFactory.getName(), e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/PoolFactoryRegistry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPool.java (from rev 66997, trunk/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPool.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,281 @@
+/*
+ * 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.pool;
+
+import java.util.LinkedList;
+import javax.ejb.EJBException;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.logging.Logger;
+import EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class StrictMaxPool
+ extends AbstractPool
+{
+// Constants -----------------------------------------------------
+ public static final int DEFAULT_MAX_SIZE = 30;
+ public static final long DEFAULT_TIMEOUT = Long.MAX_VALUE;
+
+ // Attributes ----------------------------------------------------
+ /**
+ * A FIFO semaphore that is set when the strict max size behavior is in effect.
+ * When set, only maxSize instances may be active and any attempt to get an
+ * instance will block until an instance is freed.
+ */
+ private FIFOSemaphore strictMaxSize;
+ private int inUse = 0;
+ /**
+ * The time in milliseconds to wait for the strictMaxSize semaphore.
+ */
+ private long strictTimeout;
+
+ /**
+ * The pool data structure
+ */
+ protected LinkedList pool = new LinkedList();
+ /**
+ * The maximum number of instances allowed in the pool
+ */
+ protected int maxSize = 30;
+
+ Logger log = Logger.getLogger(StrictMaxPool.class);
+
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * super.initialize() must have been called in advance
+ */
+ public void initialize(Container container, int maxSize, long timeout)
+ {
+ super.initialize(container, maxSize, timeout);
+ this.maxSize = maxSize;
+ this.strictMaxSize = new FIFOSemaphore(maxSize);
+ this.strictTimeout = timeout;
+ }
+
+ public int getCurrentSize()
+ {
+ return getCreateCount() - getRemoveCount();
+ }
+
+ public int getAvailableCount()
+ {
+ return maxSize - inUse;
+ }
+
+ public int getMaxSize()
+ {
+ return maxSize;
+ }
+
+ public void setMaxSize(int maxSize)
+ {
+ this.maxSize = maxSize;
+ this.strictMaxSize = new FIFOSemaphore(maxSize);
+ }
+
+ /**
+ * Get an instance without identity.
+ * Can be used by finders,create-methods, and activation
+ *
+ * @return Context /w instance
+ */
+ public BeanContext get()
+ {
+ 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();
+
+ }
+
+ 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);
+ }
+
+ /**
+ * Return an instance after invocation.
+ * <p/>
+ * Called in 2 cases:
+ * a) Done with finder method
+ * b) Just removed
+ *
+ * @param ctx
+ */
+ public void release(BeanContext ctx)
+ {
+ if (log.isTraceEnabled())
+ {
+ String msg = pool.size() + "/" + maxSize + " Free instance:" + this
+ + "#" + container.getBeanClass();
+ log.trace(msg);
+ }
+
+ try
+ {
+ // Add the unused context back into the pool
+ boolean removeIt = false;
+ synchronized (pool)
+ {
+ if (pool.size() < maxSize)
+ {
+ pool.addFirst(ctx);
+ }
+ else
+ {
+ removeIt = true;
+ }
+ }
+ if (removeIt) remove(ctx);
+ // If we block when maxSize instances are in use, invoke release on strictMaxSize
+ strictMaxSize.release();
+ --inUse;
+ }
+ catch (Exception ignored)
+ {
+ }
+
+ }
+
+ public void destroy()
+ {
+ freeAll();
+ }
+
+ public void discard(BeanContext ctx)
+ {
+ if (log.isTraceEnabled())
+ {
+ String msg = "Discard instance:" + this + "#" + ctx
+ + "#" + container.getBeanClass();
+ log.trace(msg);
+ }
+
+ // If we block when maxSize instances are in use, invoke release on strictMaxSize
+ strictMaxSize.release();
+ --inUse;
+
+ // Throw away, unsetContext()
+ super.discard(ctx);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+ /*
+ protected void destroy() throws Exception
+ {
+ freeAll();
+ this.container = null;
+ }
+ */
+
+ // Private -------------------------------------------------------
+
+ /**
+ * At undeployment we want to free completely the pool.
+ */
+ private void freeAll()
+ {
+ LinkedList clone = (LinkedList) pool.clone();
+ for (int i = 0; i < clone.size(); i++)
+ {
+ BeanContext bc = (BeanContext) clone.get(i);
+ // Clear TX so that still TX entity pools get killed as well
+ discard(bc);
+ }
+ pool.clear();
+ inUse = 0;
+
+ }
+
+ // Inner classes -------------------------------------------------
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPoolFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPoolFactory.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPoolFactory.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.pool;
+
+/**
+ * Factory for obtaining StrictMaxPool instances
+ *
+ * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @version $Revision: $
+ */
+public class StrictMaxPoolFactory implements PoolFactory<Pool>
+{
+
+ public Pool createPool()
+ {
+ return new StrictMaxPool();
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/StrictMaxPoolFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPool.java (from rev 66997, trunk/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPool.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,187 @@
+/*
+ * 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.pool;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.InfinitePool;
+import org.jboss.injection.Injector;
+import org.jboss.lang.ref.WeakThreadLocal;
+import org.jboss.logging.Logger;
+
+
+/**
+ * Pools EJBs within a ThreadLocal.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class ThreadlocalPool implements Pool
+{
+private static final Logger log = Logger.getLogger(ThreadlocalPool.class);
+
+ 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 pool.get();
+ }
+
+ protected BeanContext create(Class[] initTypes, Object[] initValues)
+ {
+ return pool.get(initTypes, initValues);
+ }
+
+ public void discard(BeanContext obj)
+ {
+ pool.discard(obj);
+ --inUse;
+ }
+
+ public void destroy()
+ {
+ log.trace("destroying pool");
+
+ pool.destroy();
+
+ // This really serves little purpose, because we want the whole thread local map to die
+ currentBeanContext.remove();
+
+ inUse = 0;
+ }
+
+ public BeanContext get()
+ {
+ BeanContext ctx = null;
+
+ synchronized(pool)
+ {
+ ctx = currentBeanContext.get();
+ if (ctx != null)
+ {
+ currentBeanContext.set(null);
+ ++inUse;
+ return ctx;
+ }
+
+ ctx = create();
+ ++inUse;
+ }
+
+ return ctx;
+ }
+
+ public BeanContext get(Class[] initTypes, Object[] initValues)
+ {
+ BeanContext ctx = null;
+ synchronized(pool)
+ {
+ ctx = currentBeanContext.get();
+ if (ctx != null)
+ {
+ currentBeanContext.set(null);
+ ++inUse;
+ return ctx;
+ }
+
+ ctx = create(initTypes, initValues);
+ ++inUse;
+ }
+
+ return ctx;
+ }
+
+ public void initialize(Container container, int maxSize, long timeout)
+ {
+ pool.initialize(container, maxSize, timeout);
+ this.maxSize = maxSize;
+ }
+
+ public void release(BeanContext ctx)
+ {
+ synchronized(pool)
+ {
+ if (currentBeanContext.get() != null)
+ {
+ remove(ctx);
+ }
+ else
+ {
+ currentBeanContext.set(ctx);
+ }
+
+ --inUse;
+ }
+ }
+
+ public void remove(BeanContext ctx)
+ {
+ pool.remove(ctx);
+ }
+
+ public int getCurrentSize()
+ {
+ int size;
+ synchronized (pool)
+ {
+ size = pool.getCreateCount() - pool.getRemoveCount();
+ }
+ return size;
+ }
+
+ public int getAvailableCount()
+ {
+ return maxSize - inUse;
+ }
+
+ public int getCreateCount()
+ {
+ return pool.getCreateCount();
+ }
+
+ public int getMaxSize()
+ {
+ return maxSize;
+ }
+
+ public int getRemoveCount()
+ {
+ return pool.getRemoveCount();
+ }
+
+ public void setInjectors(Injector[] injectors)
+ {
+ pool.setInjectors(injectors);
+ }
+
+ public void setMaxSize(int maxSize)
+ {
+ this.maxSize = maxSize;
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPool.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPoolFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPoolFactory.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPoolFactory.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, 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.pool;
+
+/**
+ * Factory for obtaining ThreadlocalPool instances
+ *
+ * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @version $Revision: $
+ */
+public class ThreadlocalPoolFactory implements PoolFactory<Pool>
+{
+
+ public Pool createPool()
+ {
+ return new ThreadlocalPool();
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/pool/ThreadlocalPoolFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessInstanceInterceptor.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessInstanceInterceptor.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessInstanceInterceptor.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -24,6 +24,7 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.ejb3.*;
+import org.jboss.ejb3.pool.Pool;
import org.jboss.ejb3.stateful.StatefulInstanceInterceptor;
import org.jboss.ejb3.tx.Ejb3TxPolicy;
import org.jboss.logging.Logger;
Modified: trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml
===================================================================
--- trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml 2007-11-13 20:45:39 UTC (rev 67042)
@@ -15,6 +15,7 @@
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
<property name="defaultPersistenceProperties"><inject bean="DefaultPersistenceProperties" property="properties"/></property>
<property name="cacheFactoryRegistry"><inject bean="EJB3CacheFactoryRegistry" /></property>
+ <property name="poolFactoryRegistry"><inject bean="EJB3PoolFactoryRegistry" /></property>
<!--
@@ -164,6 +165,26 @@
</entry>
</map>
</property>
+ </bean>
+
+ <!-- EJB3 Pool Factory Registry -->
+ <bean name="EJB3PoolFactoryRegistry" class="org.jboss.ejb3.pool.PoolFactoryRegistry">
+ <property name="factories">
+ <!-- Define each of the registered factories -->
+ <map class="java.util.HashMap" keyClass="java.lang.String"
+ valueClass="java.lang.Class">
+ <!-- ThreadlocalPool -->
+ <entry>
+ <key>ThreadlocalPool</key>
+ <value>org.jboss.ejb3.pool.ThreadlocalPoolFactory</value>
+ </entry>
+ <!-- StrictMaxPool -->
+ <entry>
+ <key>StrictMaxPool</key>
+ <value>org.jboss.ejb3.pool.StrictMaxPoolFactory</value>
+ </entry>
+ </map>
+ </property>
</bean>
<bean name="JNDIKernelRegistryPlugin" class="org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin"/>
Modified: trunk/ejb3/src/resources/ejb3-interceptors-aop.xml
===================================================================
--- trunk/ejb3/src/resources/ejb3-interceptors-aop.xml 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/resources/ejb3-interceptors-aop.xml 2007-11-13 20:45:39 UTC (rev 67042)
@@ -107,8 +107,8 @@
<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 expr="!class(@org.jboss.annotation.ejb.Pool)">
+ @org.jboss.annotation.ejb.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
</annotation>
<annotation expr="!class(@org.jboss.annotation.ejb.JndiBindingPolicy)">
@org.jboss.annotation.ejb.JndiBindingPolicy (policy=org.jboss.ejb3.jndipolicy.PackagingBasedJndiBindingPolicy.class)
@@ -138,8 +138,8 @@
<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 expr="!class(@org.jboss.annotation.ejb.Pool)">
+ @org.jboss.annotation.ejb.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
</annotation>
<annotation expr="!class(@org.jboss.annotation.ejb.JndiBindingPolicy)">
@org.jboss.annotation.ejb.JndiBindingPolicy (policy=org.jboss.ejb3.jndipolicy.PackagingBasedJndiBindingPolicy.class)
@@ -186,8 +186,8 @@
<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 expr="!class(@org.jboss.annotation.ejb.Pool)">
+ @org.jboss.annotation.ejb.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
</annotation>
<annotation expr="!class(@org.jboss.annotation.ejb.JndiBindingPolicy)">
@org.jboss.annotation.ejb.JndiBindingPolicy (policy=org.jboss.ejb3.jndipolicy.PackagingBasedJndiBindingPolicy.class)
@@ -251,8 +251,8 @@
<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 expr="!class(@org.jboss.annotation.ejb.Pool)">
+ @org.jboss.annotation.ejb.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
</annotation>
<annotation expr="!class(@org.jboss.annotation.ejb.JndiBindingPolicy)">
@org.jboss.annotation.ejb.JndiBindingPolicy (policy=org.jboss.ejb3.jndipolicy.PackagingBasedJndiBindingPolicy.class)
@@ -302,8 +302,8 @@
<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 expr="!class(@org.jboss.annotation.ejb.Pool)">
+ @org.jboss.annotation.ejb.Pool (value="StrictMaxPool", maxSize=15, timeout=10000)
</annotation>
<annotation expr="!class(@org.jboss.annotation.ejb.JndiBindingPolicy)">
@org.jboss.annotation.ejb.JndiBindingPolicy (policy=org.jboss.ejb3.jndipolicy.PackagingBasedJndiBindingPolicy.class)
@@ -326,8 +326,8 @@
<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 expr="!class(@org.jboss.annotation.ejb.Pool)">
+ @org.jboss.annotation.ejb.Pool (value="StrictMaxPool", maxSize=15, timeout=10000)
</annotation>
<annotation expr="!class(@org.jboss.annotation.ejb.JndiBindingPolicy)">
@org.jboss.annotation.ejb.JndiBindingPolicy (policy=org.jboss.ejb3.jndipolicy.PackagingBasedJndiBindingPolicy.class)
Modified: trunk/ejb3/src/resources/test/defaultremotebindings/default-ejb3-interceptors-aop.xml
===================================================================
--- trunk/ejb3/src/resources/test/defaultremotebindings/default-ejb3-interceptors-aop.xml 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/resources/test/defaultremotebindings/default-ejb3-interceptors-aop.xml 2007-11-13 20:45:39 UTC (rev 67042)
@@ -42,8 +42,8 @@
<annotation expr="!class(@org.jboss.annotation.ejb.JndiBindingPolicy)">
@org.jboss.annotation.ejb.JndiBindingPolicy (policy=org.jboss.ejb3.jndipolicy.PackagingBasedJndiBindingPolicy.class)
</annotation>
- <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
- @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+ <annotation expr="!class(@org.jboss.annotation.ejb.Pool)">
+ @org.jboss.annotation.ejb.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
</annotation>
<annotation expr="!class(@org.jboss.annotation.ejb.RemoteBinding)">
@org.jboss.annotation.ejb.RemoteBinding (jndiBinding="DefaultedStateless", factory = org.jboss.ejb3.remoting.RemoteProxyFactory.class, interceptorStack="", clientBindUrl = "")
Modified: trunk/ejb3/src/resources/test/interceptors2/META-INF/jboss.xml
===================================================================
--- trunk/ejb3/src/resources/test/interceptors2/META-INF/jboss.xml 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/resources/test/interceptors2/META-INF/jboss.xml 2007-11-13 20:45:39 UTC (rev 67042)
@@ -11,7 +11,7 @@
<!-- The default is ThreadlocalPool, which could lead to new constructs. Same goes for maxSize. -->
<pool-config>
- <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-value>StrictMaxPool</pool-value>
<pool-max-size>1</pool-max-size>
</pool-config>
</session>
Modified: trunk/ejb3/src/resources/test/strictpool/META-INF/jboss.xml
===================================================================
--- trunk/ejb3/src/resources/test/strictpool/META-INF/jboss.xml 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/resources/test/strictpool/META-INF/jboss.xml 2007-11-13 20:45:39 UTC (rev 67042)
@@ -9,11 +9,11 @@
<session>
<ejb-name>OverrideStrictlyPooledSessionBean</ejb-name>
<annotation>
- <annotation-class>org.jboss.annotation.ejb.PoolClass</annotation-class>
- <annotation-implementation-class>org.jboss.annotation.ejb.PoolClassImpl</annotation-implementation-class>
+ <annotation-class>org.jboss.annotation.ejb.Pool</annotation-class>
+ <annotation-implementation-class>org.jboss.annotation.ejb.PoolImpl</annotation-implementation-class>
<property>
<property-name>value</property-name>
- <property-value>org.jboss.ejb3.StrictMaxPool</property-value>
+ <property-value>StrictMaxPool</property-value>
</property>
<property>
<property-name>maxSize</property-name>
@@ -25,7 +25,7 @@
</property>
</annotation>
<!--pool-config>
- <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-value>StrictMaxPool</pool-value>
<pool-max-size>5</pool-max-size>
<pool-timeout>10000</pool-timeout>
</pool-config-->
@@ -49,7 +49,7 @@
</property>
</annotation-->
<pool-config>
- <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
+ <pool-value>StrictMaxPool</pool-value>
<pool-max-size>5</pool-max-size>
<pool-timeout>10000</pool-timeout>
</pool-config>
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/aspectdomain/DeploymentDescriptorStatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/aspectdomain/DeploymentDescriptorStatefulBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/aspectdomain/DeploymentDescriptorStatefulBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -24,7 +24,7 @@
import javax.ejb.Remote;
import javax.ejb.Stateful;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.annotation.ejb.RemoteBinding;
import org.jboss.annotation.ejb.cache.Cache;
import org.jboss.annotation.ejb.cache.CacheConfig;
@@ -39,7 +39,7 @@
@Stateful(name="DeploymentDescriptorStateful")
@Remote(org.jboss.ejb3.test.aspectdomain.Stateful.class)
@RemoteBinding(jndiBinding = "DeploymentDescriptorStateful")
- at PoolClass(value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+ at Pool(value="ThreadlocalPool", maxSize=30, timeout=10000)
@Cache("StatefulTreeCache")
@CacheConfig(name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300)
public class DeploymentDescriptorStatefulBean
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/aspectdomain/StatefulBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/aspectdomain/StatefulBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/aspectdomain/StatefulBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -25,7 +25,7 @@
import javax.ejb.Stateful;
import org.jboss.annotation.ejb.AspectDomain;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.annotation.ejb.RemoteBinding;
import org.jboss.annotation.ejb.cache.Cache;
import org.jboss.annotation.ejb.cache.CacheConfig;
@@ -41,7 +41,7 @@
@Remote(org.jboss.ejb3.test.aspectdomain.Stateful.class)
@RemoteBinding(jndiBinding = "Stateful")
@AspectDomain("Test Aspect Domain")
- at PoolClass(value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
+ at Pool(value="ThreadlocalPool", maxSize=30, timeout=10000)
@Cache("StatefulTreeCache")
@CacheConfig(name="jboss.cache:service=EJB3SFSBClusteredCache", maxSize=100000, idleTimeoutSeconds=300)
public class StatefulBean
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/cachepassivation/MockBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -27,11 +27,10 @@
import javax.ejb.PrePassivate;
import javax.ejb.SessionContext;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.annotation.ejb.cache.Cache;
import org.jboss.annotation.ejb.cache.CacheConfig;
import org.jboss.annotation.ejb.cache.simple.PersistenceManager;
-import org.jboss.ejb3.ThreadlocalPool;
/**
* Comment
@@ -42,7 +41,7 @@
@Cache("SimpleStatefulCache")
@PersistenceManager(MyStatefulSessionFilePersistenceManager.class)
@CacheConfig(idleTimeoutSeconds=1)
- at PoolClass(value=ThreadlocalPool.class)
+ at Pool("ThreadlocalPool")
public class MockBean implements Mock
{
public static Object notification = new Object();
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors2/AnnotatedOnlySLSB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors2/AnnotatedOnlySLSB.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/interceptors2/AnnotatedOnlySLSB.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -21,19 +21,18 @@
*/
package org.jboss.ejb3.test.interceptors2;
-import javax.ejb.EJB;
import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
import javax.interceptor.AroundInvoke;
import javax.interceptor.ExcludeClassInterceptors;
import javax.interceptor.ExcludeDefaultInterceptors;
import javax.interceptor.Interceptors;
import javax.interceptor.InvocationContext;
-import javax.annotation.PreDestroy;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import org.jboss.annotation.ejb.PoolClass;
-import org.jboss.ejb3.StrictMaxPool;
+import org.jboss.annotation.ejb.Pool;
/**
*
@@ -45,7 +44,7 @@
@Interceptors(AnnotatedClassInterceptor.class)
@ExcludeDefaultInterceptors
// The default is ThreadlocalPool, which could lead to new constructs. Same goes for maxSize.
- at PoolClass(value=StrictMaxPool.class, maxSize=1)
+ at Pool(value="StrictMaxPool", maxSize=1)
public class AnnotatedOnlySLSB implements AnnotatedOnlySLSBRemote
{
@EJB
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/JMSMDBBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/JMSMDBBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/JMSMDBBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -21,15 +21,15 @@
*/
package org.jboss.ejb3.test.jca.inflowmdb;
-import org.jboss.logging.Logger;
-import org.jboss.annotation.ejb.PoolClass;
-import org.jboss.annotation.ejb.ResourceAdapter;
-
+import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
-import javax.ejb.ActivationConfigProperty;
import javax.jms.Message;
import javax.jms.MessageListener;
+import org.jboss.annotation.ejb.Pool;
+import org.jboss.annotation.ejb.ResourceAdapter;
+import org.jboss.logging.Logger;
+
/**
*
* @version <tt>$Revision$</tt>
@@ -41,7 +41,7 @@
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/inflowmdbtest"),
@ActivationConfigProperty(propertyName="maxSession", propertyValue="1")
})
- at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)
+ at Pool(value="StrictMaxPool", maxSize=1, timeout=10000)
@ResourceAdapter("jms-ra.rar")
public class
JMSMDBBean implements MessageListener
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/ExpirationTestMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/ExpirationTestMDB.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/ExpirationTestMDB.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -26,7 +26,7 @@
import javax.jms.Message;
import javax.jms.MessageListener;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
/**
* Comment
@@ -39,7 +39,7 @@
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/expirationmdbtest")
})
- at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1)
+ at Pool(value="StrictMaxPool", maxSize=1)
public class ExpirationTestMDB implements MessageListener
{
public void onMessage(Message message)
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/MismatchedQueueMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/MismatchedQueueMDB.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/MismatchedQueueMDB.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -27,7 +27,7 @@
import javax.jms.MessageListener;
import javax.jms.TextMessage;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.logging.Logger;
/**
@@ -39,7 +39,7 @@
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/mismatchedmdbtest"),
@ActivationConfigProperty(propertyName="maxSession", propertyValue="100")
})
- at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)
+ at Pool(value="StrictMaxPool", maxSize=1, timeout=10000)
public class MismatchedQueueMDB
implements MessageListener
{
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/OverrideTestMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/OverrideTestMDB.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/OverrideTestMDB.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -28,7 +28,7 @@
import javax.jms.MessageListener;
import javax.annotation.Resource;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.logging.Logger;
/**
@@ -40,7 +40,7 @@
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Bogus"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/bogus")
})
- at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=100, timeout=10000)
+ at Pool(value="StrictMaxPool", maxSize=100, timeout=10000)
public class OverrideTestMDB implements MessageListener
{
private static final Logger log = Logger.getLogger(OverrideTestMDB.class);
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/QueueTestMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/QueueTestMDB.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/QueueTestMDB.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -36,7 +36,7 @@
import javax.annotation.security.RunAs;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.annotation.security.SecurityDomain;
import org.jboss.logging.Logger;
@@ -51,7 +51,7 @@
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/mdbtest")
})
- at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)
+ at Pool(value="StrictMaxPool", maxSize=1, timeout=10000)
@RunAs("TestRole")
@SecurityDomain(value="other",unauthenticatedPrincipal="nobody")
public class QueueTestMDB implements MessageListener
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -28,7 +28,7 @@
import javax.jms.Message;
import javax.jms.MessageListener;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.annotation.ejb.TransactionTimeout;
import org.jboss.logging.Logger;
@@ -45,7 +45,7 @@
@TransactionTimeout(1)
// Not allowed on a MDB
//@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) // if we specify a tx timeout, we must start the tx
- at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)
+ at Pool(value="StrictMaxPool", maxSize=1, timeout=10000)
public class TransactionQueueTestMDB implements MessageListener
{
private static final Logger log = Logger.getLogger(TransactionQueueTestMDB.class);
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/stateless/DefaultPoolStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateless/DefaultPoolStatelessBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateless/DefaultPoolStatelessBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -24,8 +24,8 @@
import javax.ejb.Stateless;
import javax.ejb.Remote;
-import org.jboss.annotation.ejb.PoolClass;
-import org.jboss.ejb3.StrictMaxPool;
+import org.jboss.annotation.ejb.Pool;
+import org.jboss.ejb3.pool.StrictMaxPool;
import org.jboss.logging.Logger;
/**
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/stateless/StrictMaxPoolStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/stateless/StrictMaxPoolStatelessBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/stateless/StrictMaxPoolStatelessBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -24,8 +24,8 @@
import javax.ejb.Stateless;
import javax.ejb.Remote;
-import org.jboss.annotation.ejb.PoolClass;
-import org.jboss.ejb3.StrictMaxPool;
+import org.jboss.annotation.ejb.Pool;
+import org.jboss.ejb3.pool.StrictMaxPool;
import org.jboss.logging.Logger;
/**
@@ -33,7 +33,7 @@
*/
@Stateless
@Remote(StatelessRemote.class)
- at PoolClass (value=StrictMaxPool.class, maxSize=3, timeout=1000)
+ at Pool (value="StrictMaxPool", maxSize=3, timeout=1000)
public class StrictMaxPoolStatelessBean implements StatelessRemote
{
private static final Logger log = Logger.getLogger(StrictMaxPoolStatelessBean.class);
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/DestroyStatelessBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -23,12 +23,11 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
-import javax.ejb.Stateless;
import javax.ejb.Remote;
+import javax.ejb.Stateless;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.annotation.ejb.RemoteBinding;
-import org.jboss.ejb3.ThreadlocalPool;
import org.jboss.logging.Logger;
/**
@@ -37,7 +36,7 @@
@Stateless
@Remote(DestroyRemote.class)
@RemoteBinding(clientBindUrl="socket://0.0.0.0:3875")
- at PoolClass(value=ThreadlocalPool.class, maxSize=20, timeout=10000)
+ at Pool(value="ThreadlocalPool", maxSize=20, timeout=10000)
public class DestroyStatelessBean implements DestroyRemote
{
private static final Logger log = Logger.getLogger(DestroyStatelessBean.class);
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/ThreadLocalPoolStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/ThreadLocalPoolStatelessBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/statelesscreation/ThreadLocalPoolStatelessBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -21,12 +21,11 @@
*/
package org.jboss.ejb3.test.statelesscreation;
-import javax.ejb.Stateless;
import javax.ejb.Remote;
+import javax.ejb.Stateless;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.annotation.ejb.RemoteBinding;
-import org.jboss.ejb3.ThreadlocalPool;
import org.jboss.logging.Logger;
/**
@@ -35,7 +34,7 @@
@Stateless
@Remote(StatelessRemote.class)
@RemoteBinding(clientBindUrl="socket://0.0.0.0:3875")
- at PoolClass(value=ThreadlocalPool.class, maxSize=20, timeout=10000)
+ at Pool(value="ThreadlocalPool", maxSize=20, timeout=10000)
public class ThreadLocalPoolStatelessBean implements StatelessRemote
{
private static final Logger log = Logger.getLogger(ThreadLocalPoolStatelessBean.class);
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/BogusPool.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/BogusPool.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/BogusPool.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -21,9 +21,9 @@
*/
package org.jboss.ejb3.test.strictpool;
-import org.jboss.ejb3.AbstractPool;
import org.jboss.ejb3.BeanContext;
import org.jboss.ejb3.Container;
+import org.jboss.ejb3.pool.AbstractPool;
/**
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/OverrideStrictlyPooledMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/OverrideStrictlyPooledMDB.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/OverrideStrictlyPooledMDB.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -37,8 +37,7 @@
import javax.jms.TextMessage;
import javax.naming.InitialContext;
-import org.jboss.annotation.ejb.PoolClass;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
/**
* @version <tt>$Revision$</tt>
@@ -52,7 +51,7 @@
@ActivationConfigProperty(propertyName="minSession", propertyValue="10"),
@ActivationConfigProperty(propertyName="maxSession", propertyValue="10")
})
- at PoolClass (value=org.jboss.ejb3.test.strictpool.BogusPool.class, maxSize=0, timeout=0)
+ at Pool (value="BogusPool", maxSize=0, timeout=0)
public class OverrideStrictlyPooledMDB implements MessageListener
{
/** The class wide max count of instances allows */
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/OverrideStrictlyPooledSessionBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/OverrideStrictlyPooledSessionBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/OverrideStrictlyPooledSessionBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -26,15 +26,16 @@
import javax.ejb.Remote;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
+
/**
* @version <tt>$Revision$</tt>
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
*/
@Stateless
- at PoolClass(value=org.jboss.ejb3.test.strictpool.BogusPool.class, maxSize=0, timeout=0)
+ at Pool(value="BogusPoo", maxSize=0, timeout=0)
@Remote(StrictlyPooledSession.class)
public class OverrideStrictlyPooledSessionBean implements StrictlyPooledSession
{
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledMDB.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledMDB.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -38,8 +38,7 @@
import javax.jms.TextMessage;
import javax.naming.InitialContext;
-import org.jboss.annotation.ejb.PoolClass;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
import org.jboss.logging.Logger;
/**
@@ -55,7 +54,7 @@
@ActivationConfigProperty(propertyName="minSession", propertyValue="10"),
@ActivationConfigProperty(propertyName="maxSession", propertyValue="10")
})
- at PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=StrictlyPooledMDB.maxActiveCount, timeout=10000)
+ at Pool (value="StrictMaxPool", maxSize=StrictlyPooledMDB.maxActiveCount, timeout=10000)
public class StrictlyPooledMDB implements MessageListener
{
private static final Logger log = Logger.getLogger(StrictlyPooledMDB.class);
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledMDB2.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledMDB2.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledMDB2.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -21,14 +21,14 @@
*/
package org.jboss.ejb3.test.strictpool;
-import org.jboss.annotation.ejb.PoolClass;
-import org.jboss.logging.Logger;
-
+import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
-import javax.ejb.ActivationConfigProperty;
+import javax.jms.Message;
import javax.jms.MessageListener;
-import javax.jms.Message;
+import org.jboss.annotation.ejb.Pool;
+import org.jboss.logging.Logger;
+
/**
* Comment
*
@@ -40,7 +40,7 @@
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="queue/queueC")
})
- at PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=500)
+ at Pool (value="StrictMaxPool", maxSize=1, timeout=500)
public class StrictlyPooledMDB2 implements MessageListener
{
private static final Logger log = Logger.getLogger(StrictlyPooledMDB2.class);
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledSessionBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledSessionBean.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/strictpool/StrictlyPooledSessionBean.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -26,16 +26,17 @@
import javax.ejb.Remote;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
-import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.Pool;
+
/**
* Adapted from the EJB 2.1 tests (org.jboss.test.cts.ejb.StrictlyPooledSessionBean)
* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
* @version $Revision$
*/
@Stateless
- at PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=StrictlyPooledSessionBean.maxActiveCount, timeout=10000)
+ at Pool (value="StrictMaxPool", maxSize=StrictlyPooledSessionBean.maxActiveCount, timeout=10000)
@Remote(StrictlyPooledSession.class)
public class StrictlyPooledSessionBean implements StrictlyPooledSession
{
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/MockContainer.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -31,14 +31,14 @@
import org.jboss.ejb3.BeanContext;
import org.jboss.ejb3.Container;
import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.Pool;
+import org.jboss.ejb3.pool.Pool;
import org.jboss.ejb3.statistics.InvocationStatistics;
/**
* Comment
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
*/
public class MockContainer implements Container
{
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java 2007-11-13 20:42:27 UTC (rev 67041)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/threadlocal/unit/ThreadLocalPoolUnitTestCase.java 2007-11-13 20:45:39 UTC (rev 67042)
@@ -21,20 +21,19 @@
*/
package org.jboss.ejb3.test.threadlocal.unit;
+import junit.framework.TestCase;
+
import org.jboss.ejb3.BeanContext;
import org.jboss.ejb3.Container;
-import org.jboss.ejb3.ThreadlocalPool;
+import org.jboss.ejb3.pool.ThreadlocalPool;
import org.jboss.ejb3.test.threadlocal.MockBean;
-import org.jboss.ejb3.test.threadlocal.MockBeanContext;
import org.jboss.ejb3.test.threadlocal.MockContainer;
-import junit.framework.TestCase;
-
/**
* Comment
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
*/
public class ThreadLocalPoolUnitTestCase extends TestCase
{
More information about the jboss-cvs-commits
mailing list