Author: rmannibucau
Date: Sun Aug 19 17:53:55 2012
New Revision: 1374810
URL: http://svn.apache.org/viewvc?rev=1374810&view=rev
Log:
respect of dependency constraints we have between info tree and runtime objects
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
openejb/trunk/openejb/container/openejb-junit/src/main/java/org/apache/openejb/junit/LocalClientRunner.java
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/BasicClusterableRequestHandlerTest.java
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.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=1374810&r1=1374809&r2=1374810&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 17:53:55 2012
@@ -16,8 +16,6 @@
*/
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;
@@ -43,15 +41,6 @@ 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;
private final Context globalJndiContext;
@@ -69,7 +58,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, Collection<ServiceInfo> configuration) {
+ public AppContext(String id, SystemInstance systemInstance, ClassLoader
classLoader, Context globalJndiContext, Context appJndiContext, boolean
standaloneModule, int corePoolSize, int maxPoolSize, int keepAlive) {
super(id, systemInstance.getOptions());
this.classLoader = classLoader;
this.systemInstance = systemInstance;
@@ -78,30 +67,6 @@ public class AppContext extends Deployme
this.standaloneModule = standaloneModule;
this.blockingQueue = new LinkedBlockingQueue<Runnable>();
- // 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));
}
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=1374810&r1=1374809&r2=1374810&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 17:53:55 2012
@@ -40,6 +40,7 @@ import org.apache.openejb.assembler.clas
import
org.apache.openejb.assembler.classic.event.AssemblerBeforeApplicationDestroyed;
import org.apache.openejb.assembler.classic.event.AssemblerCreated;
import org.apache.openejb.assembler.classic.event.AssemblerDestroyed;
+import org.apache.openejb.assembler.classic.util.ServiceInfos;
import org.apache.openejb.assembler.monitoring.JMXContainer;
import org.apache.openejb.cdi.CdiAppContextsService;
import org.apache.openejb.cdi.CdiBuilder;
@@ -179,6 +180,15 @@ public class Assembler extends Assembler
public static final String OPENEJB_JPA_DEPLOY_TIME_ENHANCEMENT_PROP =
"openejb.jpa.deploy-time-enhancement";
+ 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 static final String GLOBAL_UNIQUE_ID = "global";
Messages messages = new Messages(Assembler.class.getPackage().getName());
@@ -577,7 +587,31 @@ 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, appInfo.services);
+
+ // async pool config
+ int corePoolSize = DEFAULT_CORE_POOL_SIZE;
+ int maxPoolSize = DEFAULT_MAX_POOL_SIZE;
+ int keepAlive = DEFAULT_KEEP_ALIVE;
+ ServiceInfo appConfig = ServiceInfos.find(appInfo.services,
appInfo.appId);
+ 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(appInfo.services,
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 =
SystemInstance.get().getOptions().get(ASYNCHRONOUS_POOL_CORE_SIZE,
corePoolSize);
+ maxPoolSize =
SystemInstance.get().getOptions().get(ASYNCHRONOUS_POOL_MAX_SIZE, maxPoolSize);
+ keepAlive =
SystemInstance.get().getOptions().get(ASYNCHRONOUS_POOL_KEEP_ALIVE, keepAlive);
+
+ final AppContext appContext = new AppContext(appInfo.appId,
SystemInstance.get(), classLoader, globalJndiContext, appJndiContext,
appInfo.standaloneModule, corePoolSize, maxPoolSize, keepAlive);
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=1374810&r1=1374809&r2=1374810&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 17:53:55 2012
@@ -57,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, Collections.EMPTY_LIST), 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, 10, 20, 60), 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=1374810&r1=1374809&r2=1374810&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 17:53:55 2012
@@ -37,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,
Collections.EMPTY_LIST), new IvmContext()),
+ deploymentInfo = new BeanContext("author", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(),
Author.class.getClassLoader(), new IvmContext(), new IvmContext(), false, 10,
20, 60), 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=1374810&r1=1374809&r2=1374810&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 17:53:55 2012
@@ -37,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,
Collections.EMPTY_LIST), new IvmContext()),
+ deploymentInfo = new BeanContext("book", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(),
Book.class.getClassLoader(), new IvmContext(), new IvmContext(), false, 10, 20,
60), new IvmContext()),
BookBean.class,
null,
null,
Modified:
openejb/trunk/openejb/container/openejb-junit/src/main/java/org/apache/openejb/junit/LocalClientRunner.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-junit/src/main/java/org/apache/openejb/junit/LocalClientRunner.java?rev=1374810&r1=1374809&r2=1374810&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-junit/src/main/java/org/apache/openejb/junit/LocalClientRunner.java
(original)
+++
openejb/trunk/openejb/container/openejb-junit/src/main/java/org/apache/openejb/junit/LocalClientRunner.java
Sun Aug 19 17:53:55 2012
@@ -16,17 +16,17 @@
*/
package org.apache.openejb.junit;
+import org.apache.openejb.AppContext;
import org.apache.openejb.BeanContext;
import org.apache.openejb.BeanType;
+import org.apache.openejb.ModuleContext;
import org.apache.openejb.SystemException;
-import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.core.ThreadContext;
-import org.apache.openejb.AppContext;
-import org.apache.openejb.ModuleContext;
+import org.apache.openejb.core.ivm.naming.IvmContext;
import org.apache.openejb.core.transaction.JtaTransactionPolicyFactory;
-import org.apache.openejb.core.transaction.TransactionType;
import org.apache.openejb.core.transaction.TransactionPolicy;
-import org.apache.openejb.core.ivm.naming.IvmContext;
+import org.apache.openejb.core.transaction.TransactionType;
+import org.apache.openejb.loader.SystemInstance;
import org.junit.internal.runners.model.ReflectiveCallable;
import org.junit.internal.runners.statements.Fail;
import org.junit.runners.BlockJUnit4ClassRunner;
@@ -34,11 +34,10 @@ import org.junit.runners.model.Framework
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
-import javax.transaction.TransactionManager;
import javax.interceptor.Interceptors;
+import javax.transaction.TransactionManager;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.util.Collections;
/**
* @version $Rev$ $Date$
@@ -108,7 +107,7 @@ public class LocalClientRunner extends B
private BeanContext createDeployment(Class<?> testClass) {
try {
- return new BeanContext(null, new IvmContext(), new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(),
testClass.getClassLoader(), new IvmContext(), new IvmContext(), false,
Collections.EMPTY_LIST), new IvmContext()), testClass, null, null, null, null,
null, null, null, null, null, BeanType.MANAGED, false);
+ return new BeanContext(null, new IvmContext(), new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(),
testClass.getClassLoader(), new IvmContext(), new IvmContext(), false, 10, 20,
60), new IvmContext()), testClass, null, null, null, null, null, null, null,
null, null, BeanType.MANAGED, false);
} catch (SystemException e) {
throw new IllegalStateException(e);
}
Modified:
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/BasicClusterableRequestHandlerTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/BasicClusterableRequestHandlerTest.java?rev=1374810&r1=1374809&r2=1374810&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/BasicClusterableRequestHandlerTest.java
(original)
+++
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/BasicClusterableRequestHandlerTest.java
Sun Aug 19 17:53:55 2012
@@ -16,22 +16,20 @@
*/
package org.apache.openejb.server.ejbd;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Collections;
-
+import com.agical.rmock.core.describe.ExpressionDescriber;
+import com.agical.rmock.core.match.operator.AbstractExpression;
+import com.agical.rmock.extension.junit.RMockTestCase;
+import org.apache.openejb.AppContext;
import org.apache.openejb.BeanContext;
-import org.apache.openejb.ModuleContext;
import org.apache.openejb.ClusteredRPCContainer;
-import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.ModuleContext;
import org.apache.openejb.client.ClusterableRequest;
import org.apache.openejb.client.ClusterableResponse;
import org.apache.openejb.client.ServerMetaData;
-import org.apache.openejb.AppContext;
+import org.apache.openejb.loader.SystemInstance;
-import com.agical.rmock.core.describe.ExpressionDescriber;
-import com.agical.rmock.core.match.operator.AbstractExpression;
-import com.agical.rmock.extension.junit.RMockTestCase;
+import java.io.IOException;
+import java.net.URI;
public class BasicClusterableRequestHandlerTest extends RMockTestCase {
@@ -48,7 +46,7 @@ public class BasicClusterableRequestHand
request = (ClusterableRequest) mock(ClusterableRequest.class);
response = (ClusterableResponse) mock(ClusterableResponse.class);
clusteredContainer = (ClusteredRPCContainer)
mock(ClusteredRPCContainer.class);
- beanContext = new BeanContext("aDeploymentId", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null,
null, null, false, Collections.EMPTY_LIST), null),
BasicClusterableRequestHandlerTest.class, null, null, null, null, null, null,
null, null, null, null, false);
+ beanContext = new BeanContext("aDeploymentId", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null,
null, null, false, 10, 20, 60), null),
BasicClusterableRequestHandlerTest.class, null, null, null, null, null, null,
null, null, null, null, false);
}
public void testNoOpWhenNotAClusteredContainer() throws Exception {
Modified:
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java?rev=1374810&r1=1374809&r2=1374810&view=diff
==============================================================================
---
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java
(original)
+++
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/DeploymentIndexTest.java
Sun Aug 19 17:53:55 2012
@@ -16,21 +16,20 @@
*/
package org.apache.openejb.server.ejbd;
-import java.lang.reflect.Method;
-import java.rmi.RemoteException;
-import java.util.Collections;
-
+import org.apache.openejb.AppContext;
import org.apache.openejb.BeanContext;
import org.apache.openejb.ModuleContext;
import org.apache.openejb.SystemException;
-import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.client.EJBMetaDataImpl;
import org.apache.openejb.client.EJBRequest;
import org.apache.openejb.client.InterfaceType;
-import org.apache.openejb.AppContext;
+import org.apache.openejb.loader.SystemInstance;
import org.junit.Before;
import org.junit.Test;
+import java.lang.reflect.Method;
+import java.rmi.RemoteException;
+
public class DeploymentIndexTest {
private Method method;
@@ -40,7 +39,7 @@ public class DeploymentIndexTest {
@Before
public void setUp() throws SystemException {
method = Method.class.getMethods()[0];
- beanContext = new BeanContext("aDeploymentId", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null,
null, null, false, Collections.EMPTY_LIST), null), DeploymentIndexTest.class,
null, null, null, null, null, null, null, null, null, null, false);
+ beanContext = new BeanContext("aDeploymentId", null, new
ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null,
null, null, false, 10, 20, 60), null), DeploymentIndexTest.class, null, null,
null, null, null, null, null, null, null, null, false);
deploymentIndex = new DeploymentIndex(new BeanContext[] {beanContext,
beanContext});
}