tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r1021879 - /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
Date Tue, 12 Oct 2010 18:39:02 GMT
Author: rickmcguire
Date: Tue Oct 12 18:39:01 2010
New Revision: 1021879

URL: http://svn.apache.org/viewvc?rev=1021879&view=rev
Log:
OPENEJB-1368 ActivationSpec instances should be validated using bean validation. 

Base support.  This is dependent upon OPENEJB-1352 to setup up the Validator and ValidatorFactory
JNDI entries. 


Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java?rev=1021879&r1=1021878&r2=1021879&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
Tue Oct 12 18:39:01 2010
@@ -55,6 +55,10 @@ import javax.resource.spi.UnavailableExc
 import javax.resource.ResourceException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
+import javax.naming.NamingException;
+import javax.validation.ConstraintViolation; 
+import javax.validation.ConstraintViolationException; 
+import javax.validation.Validator; 
 import java.lang.reflect.Method;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.management.ManagementFactory;
@@ -219,6 +223,17 @@ public class MdbContainer implements Rpc
             } catch (UnsupportedOperationException uoe) {
                 logger.info("ActivationSpec does not support validate. Implementation of
validate is optional");
             }
+            // also try validating using Bean Validation if there is a Validator available
in the context.
+            try {
+                Validator validator = (Validator)beanContext.getJndiContext().lookup("comp/Validator");
+
+                Set generalSet = validator.validate(activationSpec);
+                if (!generalSet.isEmpty()) {
+                    throw new ConstraintViolationException("Constraint violation for ActivationSpec
" + activationSpecClass.getName(), generalSet); 
+                }
+            } catch (NamingException e) {
+                logger.debug("No Validator bound to JNDI context");
+            }
 
 
             // set the resource adapter into the activation spec



Mime
View raw message