Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x ef907c6a3 -> 961b73c9d


Adds FailOnUnknowActivationSpec flag on MdbContainer


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

Branch: refs/heads/tomee-1.7.x
Commit: 42c36c374e7f2bd32264acfadb29a18e85238abc
Parents: 75c645b
Author: Otavio Santana <[email protected]>
Authored: Wed Jul 5 16:13:55 2017 -0300
Committer: Otavio Santana <[email protected]>
Committed: Wed Jul 5 16:13:55 2017 -0300

----------------------------------------------------------------------
 .../apache/openejb/core/mdb/MdbContainer.java   | 26 +++++++++++++-------
 .../META-INF/org.apache.openejb/service-jar.xml |  4 +++
 2 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/42c36c37/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
index f7e485e..272d95f 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
@@ -104,8 +104,10 @@ public class MdbContainer implements RpcContainer {
     private final ConcurrentMap<Object, BeanContext> deployments = new 
ConcurrentHashMap<Object, BeanContext>();
     private final XAResourceWrapper xaResourceWrapper;
     private final InboundRecovery inboundRecovery;
+    private final boolean failOnUnknowActivationSpec;
 
-    public MdbContainer(final Object containerID, final SecurityService 
securityService, final ResourceAdapter resourceAdapter, final Class 
messageListenerInterface, final Class activationSpecClass, final int 
instanceLimit) {
+    public MdbContainer(final Object containerID, final SecurityService 
securityService, final ResourceAdapter resourceAdapter, final Class 
messageListenerInterface,
+                        final Class activationSpecClass, final int 
instanceLimit, final boolean failOnUnknowActivationSpec) {
         this.containerID = containerID;
         this.securityService = securityService;
         this.resourceAdapter = resourceAdapter;
@@ -114,6 +116,7 @@ public class MdbContainer implements RpcContainer {
         this.instanceLimit = instanceLimit;
         xaResourceWrapper = 
SystemInstance.get().getComponent(XAResourceWrapper.class);
         inboundRecovery = 
SystemInstance.get().getComponent(InboundRecovery.class);
+        this.failOnUnknowActivationSpec = failOnUnknowActivationSpec;
     }
 
     public BeanContext[] getBeanContexts() {
@@ -148,8 +151,8 @@ public class MdbContainer implements RpcContainer {
         final Object deploymentId = beanContext.getDeploymentID();
         if (!beanContext.getMdbInterface().equals(messageListenerInterface)) {
             throw new OpenEJBException("Deployment '" + deploymentId + "' has 
message listener interface " +
-                beanContext.getMdbInterface().getName() + " but this MDB 
container only supports " +
-                messageListenerInterface);
+                    beanContext.getMdbInterface().getName() + " but this MDB 
container only supports " +
+                    messageListenerInterface);
         }
 
         // create the activation spec
@@ -254,7 +257,12 @@ public class MdbContainer implements RpcContainer {
             unusedProperties.remove("destinationType");
             unusedProperties.remove("beanClass");
             if (!unusedProperties.isEmpty()) {
-                throw new IllegalArgumentException("No setter found for the 
activation spec properties: " + unusedProperties);
+                String text = "No setter found for the activation spec 
properties: " + unusedProperties;
+                if (failOnUnknowActivationSpec) {
+                    throw new IllegalArgumentException(text);
+                } else {
+                    logger.warning(text);
+                }
             }
 
 
@@ -406,7 +414,7 @@ public class MdbContainer implements RpcContainer {
 
         // verify the delivery method passed to beforeDeliver is the same 
method that was invoked
         if (!mdbCallContext.deliveryMethod.getName().equals(method.getName()) 
||
-            
!Arrays.deepEquals(mdbCallContext.deliveryMethod.getParameterTypes(), 
method.getParameterTypes())) {
+                
!Arrays.deepEquals(mdbCallContext.deliveryMethod.getParameterTypes(), 
method.getParameterTypes())) {
             throw new IllegalStateException("Delivery method specified in 
beforeDelivery is not the delivery method called");
         }
 
@@ -448,12 +456,12 @@ public class MdbContainer implements RpcContainer {
     }
 
     private Object _invoke(final Object instance, final Method runMethod, 
final Object[] args, final BeanContext beanContext, final InterfaceType 
interfaceType, final MdbCallContext mdbCallContext) throws SystemException,
-        ApplicationException {
+            ApplicationException {
         final Object returnValue;
         try {
             final List<InterceptorData> interceptors = 
beanContext.getMethodInterceptors(runMethod);
             final InterceptorStack interceptorStack = new 
InterceptorStack(((Instance) instance).bean, runMethod, interfaceType == 
InterfaceType.TIMEOUT ? Operation.TIMEOUT : Operation.BUSINESS,
-                interceptors, ((Instance) instance).interceptors);
+                    interceptors, ((Instance) instance).interceptors);
             returnValue = interceptorStack.invoke(args);
             return returnValue;
         } catch (Throwable e) {
@@ -600,7 +608,7 @@ public class MdbContainer implements RpcContainer {
         }
 
         public void start() throws ResourceException {
-            if (! started.compareAndSet(false, true)) {
+            if (!started.compareAndSet(false, true)) {
                 return;
             }
 
@@ -616,7 +624,7 @@ public class MdbContainer implements RpcContainer {
         }
 
         public void stop() {
-            if (! started.compareAndSet(true, false)) {
+            if (!started.compareAndSet(true, false)) {
                 return;
             }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/42c36c37/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
----------------------------------------------------------------------
diff --git 
a/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
 
b/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
index 35bc2f9..6cc9f8e 100644
--- 
a/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
+++ 
b/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
@@ -481,6 +481,10 @@
 
     InstanceLimit 10
 
+    # log a warning if true or throw an exception if false is an activation 
spec can't be respected
+
+    FailOnUnknowActivationSpec = true
+
   </ServiceProvider>
 
   <!--

Reply via email to