Author: rmannibucau
Date: Sun Aug 19 16:58:30 2012
New Revision: 1374794
URL: http://svn.apache.org/viewvc?rev=1374794&view=rev
Log:
TOMEE-382 config of asynch pool
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/InheritedAppExceptionTest.java
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/AuthorBean.java
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BookBean.java
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java?rev=1374794&r1=1374793&r2=1374794&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java
Sun Aug 19 16:58:30 2012
@@ -16,6 +16,8 @@
*/
package org.apache.openejb;
+import org.apache.openejb.assembler.classic.ServiceInfo;
+import org.apache.openejb.assembler.classic.util.ServiceInfos;
import org.apache.openejb.core.WebContext;
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.util.DaemonThreadFactory;
@@ -41,6 +43,14 @@ import java.util.concurrent.TimeUnit;
* @version $Rev$ $Date$
*/
public class AppContext extends DeploymentContext {
+ public static final String DEFAULT_ASYNCHRONOUS_POOL_ID =
"asynchronous-pool";
+ public static final String ASYNCHRONOUS_POOL_CORE_SIZE =
DEFAULT_ASYNCHRONOUS_POOL_ID + ".core-size";
+ public static final String ASYNCHRONOUS_POOL_MAX_SIZE =
DEFAULT_ASYNCHRONOUS_POOL_ID + ".max-size";
+ public static final String ASYNCHRONOUS_POOL_KEEP_ALIVE =
DEFAULT_ASYNCHRONOUS_POOL_ID + ".keep-alive";
+
+ private static final int DEFAULT_CORE_POOL_SIZE = 10;
+ private static final int DEFAULT_MAX_POOL_SIZE = 20;
+ private static final int DEFAULT_KEEP_ALIVE = 60;
private final SystemInstance systemInstance;
private final ClassLoader classLoader;
@@ -59,7 +69,7 @@ public class AppContext extends Deployme
private final List<BeanContext> beanContexts = new
ArrayList<BeanContext>();
private final List<WebContext> webContexts = new ArrayList<WebContext>();
- public AppContext(String id, SystemInstance systemInstance, ClassLoader
classLoader, Context globalJndiContext, Context appJndiContext, boolean
standaloneModule) {
+ public AppContext(String id, SystemInstance systemInstance, ClassLoader
classLoader, Context globalJndiContext, Context appJndiContext, boolean
standaloneModule, Collection<ServiceInfo> configuration) {
super(id, systemInstance.getOptions());
this.classLoader = classLoader;
this.systemInstance = systemInstance;
@@ -67,7 +77,32 @@ public class AppContext extends Deployme
this.appJndiContext = appJndiContext;
this.standaloneModule = standaloneModule;
this.blockingQueue = new LinkedBlockingQueue<Runnable>();
- this.asynchPool = new ThreadPoolExecutor(10, 20, 60, TimeUnit.SECONDS,
blockingQueue, new DaemonThreadFactory("@Asynch", id));
+
+ // pool config
+ int corePoolSize = DEFAULT_CORE_POOL_SIZE;
+ int maxPoolSize = DEFAULT_MAX_POOL_SIZE;
+ int keepAlive = DEFAULT_KEEP_ALIVE;
+
+ ServiceInfo appConfig = ServiceInfos.find(configuration, id);
+ if (appConfig != null) {
+ corePoolSize =
Integer.parseInt(appConfig.properties.getProperty(ASYNCHRONOUS_POOL_CORE_SIZE,
Integer.toString(corePoolSize)).trim());
+ maxPoolSize =
Integer.parseInt(appConfig.properties.getProperty(ASYNCHRONOUS_POOL_MAX_SIZE,
Integer.toString(maxPoolSize)).trim());
+ keepAlive =
Integer.parseInt(appConfig.properties.getProperty(ASYNCHRONOUS_POOL_KEEP_ALIVE,
Integer.toString(keepAlive)).trim());
+ } else {
+ appConfig = ServiceInfos.find(configuration,
DEFAULT_ASYNCHRONOUS_POOL_ID);
+ if (appConfig != null) {
+ int l = DEFAULT_ASYNCHRONOUS_POOL_ID.length() + 1;
+ corePoolSize =
Integer.parseInt(appConfig.properties.getProperty(ASYNCHRONOUS_POOL_CORE_SIZE.substring(l),
Integer.toString(corePoolSize)).trim());
+ maxPoolSize =
Integer.parseInt(appConfig.properties.getProperty(ASYNCHRONOUS_POOL_MAX_SIZE.substring(l),
Integer.toString(maxPoolSize)).trim());
+ keepAlive =
Integer.parseInt(appConfig.properties.getProperty(ASYNCHRONOUS_POOL_KEEP_ALIVE.substring(l),
Integer.toString(keepAlive)).trim());
+ }
+ }
+
+ corePoolSize = getOptions().get(ASYNCHRONOUS_POOL_CORE_SIZE,
corePoolSize);
+ maxPoolSize = getOptions().get(ASYNCHRONOUS_POOL_MAX_SIZE,
maxPoolSize);
+ keepAlive = getOptions().get(ASYNCHRONOUS_POOL_KEEP_ALIVE, keepAlive);
+
+ this.asynchPool = new ThreadPoolExecutor(corePoolSize, maxPoolSize,
keepAlive, TimeUnit.SECONDS, blockingQueue, new DaemonThreadFactory("@Asynch",
id));
}
public Collection<Injection> getInjections() {
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1374794&r1=1374793&r2=1374794&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
Sun Aug 19 16:58:30 2012
@@ -43,7 +43,6 @@ import org.apache.openejb.assembler.clas
import org.apache.openejb.assembler.monitoring.JMXContainer;
import org.apache.openejb.cdi.CdiAppContextsService;
import org.apache.openejb.cdi.CdiBuilder;
-import org.apache.openejb.cdi.CdiPlugin;
import org.apache.openejb.cdi.CdiResourceInjectionService;
import org.apache.openejb.cdi.CdiScanner;
import org.apache.openejb.cdi.CustomELAdapter;
@@ -578,7 +577,7 @@ public class Assembler extends Assembler
classLoader = ClassLoaderUtil.createClassLoader(appInfo.path,
new URL[]{generatedJar.toURI().toURL()}, classLoader);
}
- final AppContext appContext = new AppContext(appInfo.appId,
SystemInstance.get(), classLoader, globalJndiContext, appJndiContext,
appInfo.standaloneModule);
+ final AppContext appContext = new AppContext(appInfo.appId,
SystemInstance.get(), classLoader, globalJndiContext, appJndiContext,
appInfo.standaloneModule, appInfo.services);
appContext.getInjections().addAll(injections);
appContext.getBindings().putAll(globalBindings);
appContext.getBindings().putAll(appBindings);
Modified:
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/InheritedAppExceptionTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/InheritedAppExceptionTest.java?rev=1374794&r1=1374793&r2=1374794&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/InheritedAppExceptionTest.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/InheritedAppExceptionTest.java
Sun Aug 19 16:58:30 2012
@@ -20,6 +20,7 @@
package org.apache.openejb.core;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Properties;
@@ -56,7 +57,7 @@ public class InheritedAppExceptionTest {
@Test
public void testRollback() throws Exception {
SystemInstance.init(new Properties());
- BeanContext cdi = new BeanContext("foo", null, new
ModuleContext("foo",null, "bar", new AppContext("foo", SystemInstance.get(),
null, null, null, false), null), Object.class, null, new HashMap<String,
String>());
+ BeanContext cdi = new BeanContext("foo", null, new
ModuleContext("foo",null, "bar", new AppContext("foo", SystemInstance.get(),
null, null, null, false, Collections.EMPTY_LIST), null), Object.class, null,
new HashMap<String, String>());
cdi.addApplicationException(AE1.class, true, true);
cdi.addApplicationException(AE3.class, true, false);
cdi.addApplicationException(AE6.class, false, true);
Modified:
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/AuthorBean.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/AuthorBean.java?rev=1374794&r1=1374793&r2=1374794&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/AuthorBean.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/AuthorBean.java
Sun Aug 19 16:58:30 2012
@@ -29,6 +29,7 @@ import org.apache.openejb.loader.SystemI
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
+import java.util.Collections;
import java.util.Set;
import java.util.HashSet;
@@ -36,7 +37,7 @@ public class AuthorBean implements Entit
public static Object deploymentInfo;
static {
try {
- deploymentInfo = new BeanContext("author", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(),
Author.class.getClassLoader(), new IvmContext(), new IvmContext(), false), new
IvmContext()),
+ deploymentInfo = new BeanContext("author", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(),
Author.class.getClassLoader(), new IvmContext(), new IvmContext(), false,
Collections.EMPTY_LIST), new IvmContext()),
AuthorBean.class,
null,
null,
Modified:
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BookBean.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BookBean.java?rev=1374794&r1=1374793&r2=1374794&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BookBean.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/core/cmp/jpa/BookBean.java
Sun Aug 19 16:58:30 2012
@@ -29,6 +29,7 @@ import org.apache.openejb.loader.SystemI
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -36,7 +37,7 @@ public class BookBean implements EntityB
public static Object deploymentInfo;
static {
try {
- deploymentInfo = new BeanContext("book", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(),
Book.class.getClassLoader(), new IvmContext(), new IvmContext(), false), new
IvmContext()),
+ deploymentInfo = new BeanContext("book", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(),
Book.class.getClassLoader(), new IvmContext(), new IvmContext(), false,
Collections.EMPTY_LIST), new IvmContext()),
BookBean.class,
null,
null,