adding mdb pooling properties: StrictPooling, MaxAge, IdleTimeout, 
SweepInterval, ReplaceAged, ReplaceFlushed, GarbageCollection and MaxAgeOffset


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/ea22ace2
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/ea22ace2
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/ea22ace2

Branch: refs/heads/fb_tomee8
Commit: ea22ace2fc699831dc54c0d36b86cda19aad6a2e
Parents: 71cc683
Author: Thiago Veronezi <thi...@veronezi.org>
Authored: Thu Jan 4 16:32:45 2018 -0500
Committer: Thiago Veronezi <thi...@veronezi.org>
Committed: Thu Jan 4 16:32:45 2018 -0500

----------------------------------------------------------------------
 .../openejb/core/mdb/MdbContainerFactory.java   | 45 ++++++++++++++++++++
 .../openejb/core/mdb/MdbPoolContainer.java      | 10 +++--
 .../openejb/core/mdb/PoolEndpointHandler.java   | 11 +++--
 3 files changed, 58 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ea22ace2/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainerFactory.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainerFactory.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainerFactory.java
index c511e02..3298028 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainerFactory.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainerFactory.java
@@ -85,8 +85,21 @@ public class MdbContainerFactory {
         return instanceLimit;
     }
 
+    /**
+     * @deprecated use MaxSize
+     */
+    @Deprecated
     public void setInstanceLimit(int instanceLimit) {
+        setMaxSize(instanceLimit);
+    }
+
+    public void setMaxSize(final int max) {
         this.instanceLimit = instanceLimit;
+        this.poolBuilder.setPoolSize(max);
+    }
+
+    public void setMinSize(final int min) {
+        this.poolBuilder.setMinSize(min);
     }
 
     public boolean isFailOnUnknownActivationSpec() {
@@ -145,6 +158,38 @@ public class MdbContainerFactory {
         this.evictionThreads = evictionThreads;
     }
 
+    public void setStrictPooling(final boolean strict) {
+        poolBuilder.setStrictPooling(strict);
+    }
+
+    public void setMaxAge(final Duration maxAge) {
+        poolBuilder.setMaxAge(maxAge);
+    }
+
+    public void setIdleTimeout(final Duration idleTimeout) {
+        poolBuilder.setIdleTimeout(idleTimeout);
+    }
+
+    public void setSweepInterval(final Duration interval) {
+        poolBuilder.setSweepInterval(interval);
+    }
+
+    public void setReplaceAged(final boolean replaceAged) {
+        poolBuilder.setReplaceAged(replaceAged);
+    }
+
+    public void setReplaceFlushed(final boolean replaceFlushed) {
+        poolBuilder.setReplaceFlushed(replaceFlushed);
+    }
+
+    public void setGarbageCollection(final boolean garbageCollection) {
+        poolBuilder.setGarbageCollection(garbageCollection);
+    }
+
+    public void setMaxAgeOffset(final double maxAgeOffset) {
+        poolBuilder.setMaxAgeOffset(maxAgeOffset);
+    }
+
     public boolean isPool() {
         return pool;
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/ea22ace2/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbPoolContainer.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbPoolContainer.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbPoolContainer.java
index 72ca5b6..df51dcf 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbPoolContainer.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbPoolContainer.java
@@ -457,10 +457,12 @@ public class MdbPoolContainer implements RpcContainer, 
BaseMdbContainer {
                 } catch (final Exception e) {
                     logger.error("error while releasing message endpoint", e);
                 } finally {
-                    try {
-                        instanceManager.poolInstance(callContext, instance);
-                    } catch (OpenEJBException e){
-                        logger.error("error while releasing message endpoint", 
e);
+                    if(instance != null) {
+                        try {
+                            instanceManager.poolInstance(callContext, 
instance);
+                        } catch (OpenEJBException e){
+                            logger.error("error while releasing message 
endpoint", e);
+                        }
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/tomee/blob/ea22ace2/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/PoolEndpointHandler.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/PoolEndpointHandler.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/PoolEndpointHandler.java
index 99bce83..1e5ef82 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/PoolEndpointHandler.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/PoolEndpointHandler.java
@@ -114,10 +114,13 @@ public class PoolEndpointHandler extends 
AbstractEndpointHandler {
         try {
             container.release(deployment, instance);
         } finally {
-            try {
-                instanceManager.poolInstance(new ThreadContext(deployment, 
null), instance);
-            } catch (OpenEJBException e) {
-                LOGGER.error("Unable to add instance back to the pool", e);
+            if (instance != null) {
+                try {
+
+                    instanceManager.poolInstance(new ThreadContext(deployment, 
null), instance);
+                } catch (OpenEJBException e) {
+                    LOGGER.error("Unable to add instance back to the pool", e);
+                }
             }
             instance = null;
         }

Reply via email to