You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2014/06/12 17:28:29 UTC

svn commit: r1602203 - in /tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful: StatefulContainer.java StatefulContainerFactory.java

Author: rmannibucau
Date: Thu Jun 12 15:28:28 2014
New Revision: 1602203

URL: http://svn.apache.org/r1602203
Log:
adding PreventExtendedEntityManagerSerialization to stateful container

Modified:
    tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java
    tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainerFactory.java

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java?rev=1602203&r1=1602202&r2=1602203&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainer.java Thu Jun 12 15:28:28 2014
@@ -84,6 +84,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 
@@ -105,20 +106,23 @@ public class StatefulContainer implement
     protected final Map<Object, BeanContext> deploymentsById = new HashMap<Object, BeanContext>();
 
     protected final Cache<Object, Instance> cache;
-    private final ConcurrentHashMap<Object, Instance> checkedOutInstances = new ConcurrentHashMap<Object, Instance>();
+    private final ConcurrentMap<Object, Instance> checkedOutInstances = new ConcurrentHashMap<Object, Instance>();
     private final SessionContext sessionContext;
+    private final boolean preventExtendedEntityManagerSerialization;
 
     public StatefulContainer(final Object id, final SecurityService securityService, final Cache<Object, Instance> cache) {
-        this(id, securityService, cache, new Duration(-1, TimeUnit.MILLISECONDS));
+        this(id, securityService, cache, new Duration(-1, TimeUnit.MILLISECONDS), true);
     }
 
-    public StatefulContainer(final Object id, final SecurityService securityService, final Cache<Object, Instance> cache, final Duration accessTimeout) {
+    public StatefulContainer(final Object id, final SecurityService securityService, final Cache<Object, Instance> cache,
+                             final Duration accessTimeout, final boolean preventExtendedEntityManagerSerialization) {
         this.containerID = id;
         this.securityService = securityService;
         this.cache = cache;
         cache.setListener(new StatefulCacheListener());
         this.accessTimeout = accessTimeout;
         sessionContext = new StatefulContext(this.securityService, new StatefulUserTransaction(new EjbUserTransaction(), entityManagerRegistry));
+        this.preventExtendedEntityManagerSerialization = preventExtendedEntityManagerSerialization;
     }
 
     private Map<Method, MethodType> getLifecycleMethodsOfInterface(final BeanContext beanContext) {
@@ -362,7 +366,10 @@ public class StatefulContainer implement
         }
     }
 
-    private static boolean containsExtendedPersistenceContext(final BeanContext beanContext) {
+    private boolean containsExtendedPersistenceContext(final BeanContext beanContext) {
+        if (preventExtendedEntityManagerSerialization) {
+            return false;
+        }
         final Index<EntityManagerFactory, Map> factories = beanContext.getExtendedEntityManagerFactories();
         return factories != null && factories.size() > 0;
     }

Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainerFactory.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainerFactory.java?rev=1602203&r1=1602202&r2=1602203&view=diff
==============================================================================
--- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainerFactory.java (original)
+++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulContainerFactory.java Thu Jun 12 15:28:28 2014
@@ -88,7 +88,11 @@ public class StatefulContainerFactory {
     public void setFrequency(final String s) {
         properties.put("Frequency", s);
     }
-    
+
+    public void setPreventExtendedEntityManagerSerialization(final boolean preventExtendedEntityManagerSerialization) {
+        properties.put("PreventExtendedEntityManagerSerialization", Boolean.toString(preventExtendedEntityManagerSerialization));
+    }
+
     public Properties getProperties() {
         return properties;
     }
@@ -103,7 +107,7 @@ public class StatefulContainerFactory {
             buildCache();
         }
         cache.init();
-        return new StatefulContainer(id, securityService, cache, accessTimeout);
+        return new StatefulContainer(id, securityService, cache, accessTimeout, properties.containsKey("PreventExtendedEntityManagerSerialization"));
     }
 
     private void buildCache() throws Exception {