tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlmonte...@apache.org
Subject svn commit: r1101405 [1/2] - in /openejb/branches/openejb-3.2.x: ./ assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/assemb...
Date Tue, 10 May 2011 11:19:48 GMT
Author: jlmonteiro
Date: Tue May 10 11:19:47 2011
New Revision: 1101405

URL: http://svn.apache.org/viewvc?rev=1101405&view=rev
Log:
OPENEJB-1352 Bean Validation support. Porting changes to 3.2.x. Thanks again Romain.

Added:
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfo.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfoObject.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorFactoryWrapper.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/test/java/org/apache/openejb/bval/
    openejb/branches/openejb-3.2.x/container/openejb-core/src/test/java/org/apache/openejb/bval/BeanValidationTest.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/AnnotationType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/BeanType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ClassType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintDefinitionType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintMappingsType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ElementType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/FieldType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/GetterType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/GroupSequenceType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/GroupsType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ObjectFactory.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/PayloadType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/PropertyType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ValidatedByType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ValidationConfigType.java
    openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/package-info.java
Modified:
    openejb/branches/openejb-3.2.x/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
    openejb/branches/openejb-3.2.x/container/openejb-core/pom.xml
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
    openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
    openejb/branches/openejb-3.2.x/pom.xml

Modified: openejb/branches/openejb-3.2.x/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java (original)
+++ openejb/branches/openejb-3.2.x/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java Tue May 10 11:19:47 2011
@@ -344,6 +344,9 @@ public class TomcatWebAppBuilder impleme
 
             // add context to WebDeploymentInfo
             for (WebAppInfo webAppInfo : contextInfo.appInfo.webApps) {
+                // Bean Validation
+                standardContext.getServletContext().setAttribute("javax.faces.validator.beanValidator.ValidatorFactory", openejbContext.lookup(Assembler.VALIDATOR_FACTORY_NAMING_CONTEXT + webAppInfo.moduleId));
+
                 if (("/" + webAppInfo.contextRoot).equals(standardContext.getPath()) || isRootApplication(standardContext)) {
                     CoreWebDeploymentInfo webDeploymentInfo = (CoreWebDeploymentInfo) getContainerSystem().getWebDeploymentInfo(webAppInfo.moduleId);
                     if (webDeploymentInfo != null) {

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/pom.xml
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/pom.xml?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/pom.xml (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/pom.xml Tue May 10 11:19:47 2011
@@ -205,6 +205,14 @@
   </build>
   <dependencies>
     <dependency>
+      <groupId>org.apache.bval</groupId>
+      <artifactId>bval-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.bval</groupId>
+      <artifactId>bval-jsr303</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.openejb</groupId>
       <artifactId>javaee-api</artifactId>
       <version>6.0-SNAPSHOT</version>

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java Tue May 10 11:19:47 2011
@@ -28,6 +28,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -45,6 +46,7 @@ import javax.naming.InitialContext;
 import javax.naming.NameAlreadyBoundException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.validation.ValidatorFactory;
 import javax.persistence.EntityManagerFactory;
 import javax.resource.spi.BootstrapContext;
 import javax.resource.spi.ConnectionManager;
@@ -115,7 +117,10 @@ public class Assembler extends Assembler
 
     public static final String JAVA_OPENEJB_NAMING_CONTEXT = "openejb/";
 
-    public static final String PERSISTENCE_UNIT_NAMING_CONTEXT = "openejb/PersistenceUnit/";
+    public static final String PERSISTENCE_UNIT_NAMING_CONTEXT = JAVA_OPENEJB_NAMING_CONTEXT + "PersistenceUnit/";
+
+    public static final String VALIDATOR_FACTORY_NAMING_CONTEXT = JAVA_OPENEJB_NAMING_CONTEXT + "ValidatorFactory/";
+    public static final String VALIDATOR_NAMING_CONTEXT = JAVA_OPENEJB_NAMING_CONTEXT + "Validator/";
 
     private static final String OPENEJB_URL_PKG_PREFIX = "org.apache.openejb.core.ivm.naming";
 
@@ -132,6 +137,7 @@ public class Assembler extends Assembler
     protected OpenEjbConfigurationFactory configFactory;
     private final Map<String, AppInfo> deployedApplications = new HashMap<String, AppInfo>();
     private final List<DeploymentListener> deploymentListeners = new ArrayList<DeploymentListener>();
+    private final Set<String> uniqueIds = new HashSet<String>();
 
 
     public org.apache.openejb.spi.ContainerSystem getContainerSystem() {
@@ -482,6 +488,43 @@ public class Assembler extends Assembler
                 classLoader = ClassLoaderUtil.createClassLoader(appInfo.jarPath, new URL []{generatedJar.toURI().toURL()}, classLoader);
             }
 
+            Context containerSystemContext = containerSystem.getJNDIContext();
+
+            // Bean Validation
+            // ValidatorFactory needs to be put in the map sent to the entity manager factory
+            // so it has to be constructed before
+            Map<String, ValidatorFactory> validatorFactories = new HashMap<String, ValidatorFactory>();
+            //geronimo will handle the bean validator by itself
+            if (!SystemInstance.get().hasProperty("openejb.geronimo")){
+                for (ClientInfo clientInfo : appInfo.clients) {
+                    validatorFactories.put(clientInfo.uniqueId, ValidatorBuilder.buildFactory(classLoader, clientInfo.validationInfo));
+                }
+                for (ConnectorInfo connectorInfo : appInfo.connectors) {
+                    validatorFactories.put(connectorInfo.uniqueId, ValidatorBuilder.buildFactory(classLoader, connectorInfo.validationInfo));
+                }
+                for (EjbJarInfo ejbJarInfo : appInfo.ejbJars) {
+                    validatorFactories.put(ejbJarInfo.uniqueId, ValidatorBuilder.buildFactory(classLoader, ejbJarInfo.validationInfo));
+                }
+                for (WebAppInfo webAppInfo : appInfo.webApps) {
+                    validatorFactories.put(webAppInfo.uniqueId, ValidatorBuilder.buildFactory(classLoader, webAppInfo.validationInfo));
+                }
+                uniqueIds.addAll(validatorFactories.keySet());
+
+                // validators bindings
+                for (Map.Entry<String, ValidatorFactory> validatorFactory : validatorFactories.entrySet()) {
+                    String id = validatorFactory.getKey();
+                    ValidatorFactory factory = validatorFactory.getValue();
+                    try {
+                        containerSystemContext.bind(VALIDATOR_FACTORY_NAMING_CONTEXT + id, factory);
+                        containerSystemContext.bind(VALIDATOR_NAMING_CONTEXT + id, factory.usingContext().getValidator());
+                    } catch (NameAlreadyBoundException e) {
+                        throw new OpenEJBException("ValidatorFactory already exists for module " + id);
+                    } catch (Exception e) {
+                        throw new OpenEJBException(e);
+                    }
+                }
+            }
+
             // JPA - Persistence Units MUST be processed first since they will add ClassFileTransformers
             // to the class loader which must be added before any classes are loaded
             PersistenceBuilder persistenceBuilder = new PersistenceBuilder(persistenceClassLoaderHandler);
@@ -616,7 +659,7 @@ public class Assembler extends Assembler
                 List<Injection> injections = injectionBuilder.buildInjections(clientInfo.jndiEnc);
 
                 // build the enc
-                JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(clientInfo.jndiEnc, injections, "Bean", clientInfo.moduleId, classLoader);
+                JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(clientInfo.jndiEnc, injections, "Bean", clientInfo.moduleId, clientInfo.uniqueId, classLoader);
                 // if there is at least a remote client classes
                 // or if there is no local client classes
                 // then, we can set the client flag
@@ -907,6 +950,17 @@ public class Assembler extends Assembler
             }
         }
 
+        for (String id : uniqueIds) {
+        try {
+                globalContext.unbind(VALIDATOR_FACTORY_NAMING_CONTEXT + id);
+                globalContext.unbind(VALIDATOR_NAMING_CONTEXT + id);
+            } catch (NamingException e) {
+                undeployException.getCauses().add(new Exception("validator: " + id + ": " + e.getMessage(), e));
+            }
+        }
+        uniqueIds.clear();
+
+
         try {
             if (globalContext instanceof IvmContext) {
                 IvmContext ivmContext = (IvmContext) globalContext;

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ClientInfo.java Tue May 10 11:19:47 2011
@@ -21,7 +21,7 @@ import java.util.ArrayList;
 import java.util.Set;
 import java.util.TreeSet;
 
-public class ClientInfo extends InfoObject {
+public class ClientInfo extends ValidationInfoObject {
 
     public String codebase;
     public String description;

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ConnectorInfo.java Tue May 10 11:19:47 2011
@@ -22,7 +22,7 @@ import java.util.ArrayList;
 import java.util.Set;
 import java.util.TreeSet;
 
-public class ConnectorInfo extends InfoObject {
+public class ConnectorInfo extends ValidationInfoObject {
 
     public String codebase;
     public String description;

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java Tue May 10 11:19:47 2011
@@ -48,7 +48,7 @@ public class EjbJarBuilder {
 
         for (EnterpriseBeanInfo ejbInfo : ejbJar.enterpriseBeans) {
             try {
-                EnterpriseBeanBuilder deploymentBuilder = new EnterpriseBeanBuilder(classLoader, ejbInfo, ejbJar.moduleId, new ArrayList<String>());
+                EnterpriseBeanBuilder deploymentBuilder = new EnterpriseBeanBuilder(classLoader, ejbInfo, ejbJar.moduleId, ejbJar.uniqueId, new ArrayList<String>());
                 CoreDeploymentInfo deployment = (CoreDeploymentInfo) deploymentBuilder.build();
 
                 interceptorBindingBuilder.build(deployment, ejbInfo);

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarInfo.java Tue May 10 11:19:47 2011
@@ -22,7 +22,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.TreeSet;
 
-public class EjbJarInfo extends InfoObject {
+public class EjbJarInfo extends ValidationInfoObject {
     public final Properties properties = new Properties();
 
     public String moduleId;

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanBuilder.java Tue May 10 11:19:47 2011
@@ -46,14 +46,16 @@ class EnterpriseBeanBuilder {
     protected static final Messages messages = new Messages("org.apache.openejb.util.resources");
     private final EnterpriseBeanInfo bean;
     private final String moduleId;
+    private final String uniqueId;
     private final List<String> defaultInterceptors;
     private final BeanType ejbType;
     private final ClassLoader cl;
     private List<Exception> warnings = new ArrayList<Exception>();
 
-    public EnterpriseBeanBuilder(ClassLoader cl, EnterpriseBeanInfo bean, String moduleId, List<String> defaultInterceptors) {
+    public EnterpriseBeanBuilder(ClassLoader cl, EnterpriseBeanInfo bean, String moduleId, String uniqueId, List<String> defaultInterceptors) {
         this.bean = bean;
         this.moduleId = moduleId;
+        this.uniqueId = uniqueId;
         this.defaultInterceptors = defaultInterceptors;
 
         if (bean.type == EnterpriseBeanInfo.STATEFUL) {
@@ -122,7 +124,7 @@ class EnterpriseBeanBuilder {
         List<Injection> injections = injectionBuilder.buildInjections(bean.jndiEnc);
 
         // build the enc
-        JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(bean.jndiEnc, injections, transactionType, moduleId, cl);
+        JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(bean.jndiEnc, injections, transactionType, moduleId, uniqueId, cl);
         Context root = jndiEncBuilder.build();
 
         DeploymentContext deploymentContext = new DeploymentContext(bean.ejbDeploymentId, cl, root);
@@ -198,7 +200,7 @@ class EnterpriseBeanBuilder {
 
                     try {
                         ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
-                        Object o = containerSystem.getJNDIContext().lookup("openejb/PersistenceUnit/" + info.unitId);
+                        Object o = containerSystem.getJNDIContext().lookup(PersistenceBuilder.getOpenEJBJndiName(info.unitId));
                         extendedEntityManagerFactories.put((EntityManagerFactory) o, info.properties);
                     } catch (NamingException e) {
                         throw new OpenEJBException("PersistenceUnit '" + info.unitId + "' not found for EXTENDED ref '" + info.referenceName + "'");

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java Tue May 10 11:19:47 2011
@@ -53,6 +53,8 @@ import javax.naming.NamingException;
 import javax.persistence.EntityManagerFactory;
 import javax.transaction.TransactionManager;
 import javax.transaction.UserTransaction;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceContext;
 import java.net.MalformedURLException;
@@ -78,17 +80,18 @@ public class JndiEncBuilder {
     private final boolean beanManagedTransactions;
     private final JndiEncInfo jndiEnc;
     private final URI moduleUri;
+    private final String uniqueId;
     private final List<Injection> injections;
     private final ClassLoader classLoader;
 
     private boolean useCrossClassLoaderRef = true;
     private boolean client = false;
 
-    public JndiEncBuilder(JndiEncInfo jndiEnc, List<Injection> injections, String moduleId, ClassLoader classLoader) throws OpenEJBException {
-        this(jndiEnc, injections, null, moduleId, classLoader);
+    public JndiEncBuilder(JndiEncInfo jndiEnc, List<Injection> injections, String moduleId, String uniqueId, ClassLoader classLoader) throws OpenEJBException {
+        this(jndiEnc, injections, null, moduleId, uniqueId, classLoader);
     }
 
-    public JndiEncBuilder(JndiEncInfo jndiEnc, List<Injection> injections, String transactionType, String moduleId, ClassLoader classLoader) throws OpenEJBException {
+    public JndiEncBuilder(JndiEncInfo jndiEnc, List<Injection> injections, String transactionType, String moduleId, String uniqueId, ClassLoader classLoader) throws OpenEJBException {
         this.jndiEnc = jndiEnc;
         this.injections = injections;
         beanManagedTransactions = transactionType != null && transactionType.equalsIgnoreCase("Bean");
@@ -98,6 +101,7 @@ public class JndiEncBuilder {
         } catch (URISyntaxException e) {
             throw new OpenEJBException(e);
         }
+        this.uniqueId = uniqueId;
         this.classLoader = classLoader;
     }
 
@@ -136,6 +140,14 @@ public class JndiEncBuilder {
         bindings.put("java:comp/ORB", new SystemComponentReference(ORB.class));
         bindings.put("java:comp/HandleDelegate", new SystemComponentReference(HandleDelegate.class));
 
+        // bind bean validation objects
+        String moduleId = null;
+        if (moduleUri != null) {
+            moduleId = moduleUri.toString();
+        }
+        bindings.put("java:comp/ValidatorFactory", new IntraVmJndiReference(Assembler.VALIDATOR_FACTORY_NAMING_CONTEXT + uniqueId));
+        bindings.put("java:comp/Validator", new IntraVmJndiReference(Assembler.VALIDATOR_NAMING_CONTEXT + uniqueId));
+
         // get JtaEntityManagerRegistry
         JtaEntityManagerRegistry jtaEntityManagerRegistry = SystemInstance.get().getComponent(JtaEntityManagerRegistry.class);
 
@@ -237,6 +249,12 @@ public class JndiEncBuilder {
                 } else {
                     reference = new URLReference(referenceInfo.resourceID);
                 }
+            } else if (ValidatorFactory.class.getName().equals(referenceInfo.referenceType)) {
+                String jndiName = Assembler.VALIDATOR_FACTORY_NAMING_CONTEXT + uniqueId;
+                reference = new IntraVmJndiReference(jndiName);
+            } else if (Validator.class.getName().equals(referenceInfo.referenceType)) {
+                String jndiName = Assembler.VALIDATOR_NAMING_CONTEXT + uniqueId;
+                reference = new IntraVmJndiReference(jndiName);
             } else if (referenceInfo.location != null) {
                 reference = buildReferenceLocation(referenceInfo.location);
             } else if (referenceInfo.resourceID != null) {
@@ -256,16 +274,14 @@ public class JndiEncBuilder {
                 if (EJBContext.class.isAssignableFrom(type)) {
                     String jndiName = "java:comp/EJBContext";
                     linkRef = new LinkRef(jndiName);
-                    bindings.put(normalize(referenceInfo.resourceEnvRefName), linkRef);
-                    continue;
                 } else if (WebServiceContext.class.equals(type)) {
                     String jndiName = "java:comp/WebServiceContext";
                     linkRef = new LinkRef(jndiName);
-                    bindings.put(normalize(referenceInfo.resourceEnvRefName), linkRef);
-                    continue;
                 } else if (TimerService.class.equals(type)) {
                     String jndiName = "java:comp/TimerService";
                     linkRef = new LinkRef(jndiName);
+                }
+                if (linkRef != null) {
                     bindings.put(normalize(referenceInfo.resourceEnvRefName), linkRef);
                     continue;
                 }
@@ -296,7 +312,7 @@ public class JndiEncBuilder {
                 continue;
             }
 
-            String jndiName = "openejb/PersistenceUnit/" + referenceInfo.unitId;
+            String jndiName = PersistenceBuilder.getOpenEJBJndiName(referenceInfo.unitId);
             Reference reference = new IntraVmJndiReference(jndiName);
             bindings.put(normalize(referenceInfo.referenceName), reference);
         }
@@ -311,7 +327,8 @@ public class JndiEncBuilder {
             Context context = SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext();
             EntityManagerFactory factory;
             try {
-                factory = (EntityManagerFactory) context.lookup("openejb/PersistenceUnit/" + contextInfo.unitId);
+                String jndiName = PersistenceBuilder.getOpenEJBJndiName(contextInfo.unitId);
+                factory = (EntityManagerFactory) context.lookup(jndiName);
             } catch (NamingException e) {
                 throw new OpenEJBException("PersistenceUnit '" + contextInfo.unitId + "' not found for EXTENDED ref '" + contextInfo.referenceName + "'");
             }

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PersistenceBuilder.java Tue May 10 11:19:47 2011
@@ -18,6 +18,7 @@ package org.apache.openejb.assembler.cla
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 
 import javax.naming.Context;
@@ -110,6 +111,8 @@ public class PersistenceBuilder {
         // Exclude Unlisted Classes
         unitInfo.setExcludeUnlistedClasses(info.excludeUnlistedClasses);
 
+        Context context = SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext();
+
         // JTA Datasource
         String jtaDataSourceId = info.jtaDataSource;
         if (jtaDataSourceEnv != null) jtaDataSourceId = jtaDataSourceEnv;
@@ -120,7 +123,6 @@ public class PersistenceBuilder {
                     if (!jtaDataSourceId.startsWith("java:openejb/Resource/")
                             && !jtaDataSourceId.startsWith("openejb/Resource/")) jtaDataSourceId = "openejb/Resource/"+jtaDataSourceId;
 
-                    Context context = SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext();
                     DataSource jtaDataSource = (DataSource) context.lookup(jtaDataSourceId);
                     unitInfo.setJtaDataSource(jtaDataSource);
                 } catch (NamingException e) {
@@ -172,7 +174,6 @@ public class PersistenceBuilder {
                 try {
                     if (!nonJtaDataSourceId.startsWith("java:openejb/Resource/")) nonJtaDataSourceId = "java:openejb/Resource/"+nonJtaDataSourceId;
 
-                    Context context = SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext();
                     DataSource nonJtaDataSource = (DataSource) context.lookup(nonJtaDataSourceId);
                     unitInfo.setNonJtaDataSource(nonJtaDataSource);
                 } catch (NamingException e) {
@@ -196,8 +197,10 @@ public class PersistenceBuilder {
             Class clazz = classLoader.loadClass(persistenceProviderClassName);
             PersistenceProvider persistenceProvider = (PersistenceProvider) clazz.newInstance();
 
-            // Create entity manager factory
-            EntityManagerFactory emf = persistenceProvider.createContainerEntityManagerFactory(unitInfo, new HashMap());
+            // Create entity manager factories with the validator factory
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put("javax.persistence.validator.ValidatorFactory", new ValidatorFactoryWrapper());
+            EntityManagerFactory emf = persistenceProvider.createContainerEntityManagerFactory(unitInfo, properties);
             return emf;
         } finally {
             final long time = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS);
@@ -209,4 +212,8 @@ public class PersistenceBuilder {
             }
         }
     }
+
+    public static String getOpenEJBJndiName(String unit) {
+        return Assembler.PERSISTENCE_UNIT_NAMING_CONTEXT + unit;
+}
 }

Added: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfo.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfo.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfo.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfo.java Tue May 10 11:19:47 2011
@@ -0,0 +1,17 @@
+package org.apache.openejb.assembler.classic;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @author Romain Manni-Bucau
+ */
+public class ValidationInfo extends InfoObject {
+    public String providerClassName;
+    public String messageInterpolatorClass;
+    public String traversableResolverClass;
+    public String constraintFactoryClass;
+    public final Properties propertyTypes = new Properties();
+    public final List<String> constraintMappings = new ArrayList<String>();
+}

Added: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfoObject.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfoObject.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfoObject.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidationInfoObject.java Tue May 10 11:19:47 2011
@@ -0,0 +1,9 @@
+package org.apache.openejb.assembler.classic;
+
+/**
+ * @author Romain Manni-Bucau
+ */
+public class ValidationInfoObject extends InfoObject {
+    public ValidationInfo validationInfo;
+    public String uniqueId;
+}

Added: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorBuilder.java Tue May 10 11:19:47 2011
@@ -0,0 +1,159 @@
+package org.apache.openejb.assembler.classic;
+
+import org.apache.openejb.config.sys.JaxbOpenejb;
+import org.apache.openejb.jee.bval.PropertyType;
+import org.apache.openejb.jee.bval.ValidationConfigType;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+import javax.validation.Configuration;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
+import javax.validation.Validation;
+import javax.validation.ValidationException;
+import javax.validation.ValidatorFactory;
+import javax.validation.spi.ValidationProvider;
+import javax.xml.bind.JAXBElement;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Map;
+
+public final class ValidatorBuilder {
+    public static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP, ValidatorBuilder.class);
+
+    private ValidatorBuilder() {
+        // no-op
+    }
+
+    public static ValidatorFactory buildFactory(ClassLoader classLoader, ValidationInfo info) {
+        return buildFactory(info, classLoader);
+    }
+
+    public static ValidationConfigType readConfig(URL url) {
+        if (url == null) {
+            return null;
+        }
+
+        ValidationConfigType validationConfigType;
+        try {
+            validationConfigType = JaxbOpenejb.unmarshal(ValidationConfigType.class, url.openStream());
+       } catch (Throwable t) {
+            logger.warning("Unable to create module ValidatorFactory instance.  Using default factory", t);
+            return null;
+        }
+
+        return validationConfigType;
+    }
+
+    public static ValidationInfo getInfo(ValidationConfigType config) {
+        ValidationInfo info = new ValidationInfo();
+        if (config != null) {
+            info.providerClassName = config.getDefaultProvider();
+            info.constraintFactoryClass = config.getConstraintValidatorFactory();
+            info.traversableResolverClass = config.getTraversableResolver();
+            info.messageInterpolatorClass = config.getMessageInterpolator();
+            for (PropertyType p : config.getProperty()) {
+                info.propertyTypes.put(p.getName(), p.getValue());
+            }
+            for (JAXBElement<String> element : config.getConstraintMapping()) {
+                info.constraintMappings.add(element.getValue());
+            }
+        }
+        return info;
+    }
+
+    public static ValidatorFactory buildFactory(ValidationInfo config, ClassLoader classLoader) {
+        ValidatorFactory factory = null;
+        ClassLoader oldContextLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(classLoader);
+            if (config == null) {
+                factory = Validation.buildDefaultValidatorFactory();
+            } else {
+                Configuration<?> configuration = getConfig(config);
+                factory = configuration.buildValidatorFactory();
+                configuration.ignoreXmlConfiguration();
+            }
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldContextLoader);
+        }
+        return factory;
+    }
+
+    private static Configuration<?> getConfig(ValidationInfo info) {
+        Configuration<?> target = null;
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+        String providerClassName = info.providerClassName;
+        if (providerClassName != null) {
+            try {
+                @SuppressWarnings("unchecked")
+                Class<? extends ValidationProvider> clazz = (Class<? extends ValidationProvider>) classLoader.loadClass(providerClassName);
+                target = Validation.byProvider(clazz).configure();
+                logger.info("Using " + providerClassName + " as validation provider.");
+            } catch (ClassNotFoundException e) {
+                logger.warning("Unable to load provider class "+providerClassName, e);
+            }
+        }
+        if (target == null) {
+            target = Validation.byDefaultProvider().configure();
+        }
+
+        String messageInterpolatorClass = info.messageInterpolatorClass;
+        if (messageInterpolatorClass != null) {
+            try {
+                @SuppressWarnings("unchecked")
+                Class<MessageInterpolator> clazz = (Class<MessageInterpolator>) classLoader.loadClass(messageInterpolatorClass);
+                target.messageInterpolator(clazz.newInstance());
+            } catch (Exception e) {
+                logger.warning("Unable to set "+messageInterpolatorClass+ " as message interpolator.", e);
+            }
+            logger.info("Using " + messageInterpolatorClass + " as message interpolator.");
+        }
+        String traversableResolverClass = info.traversableResolverClass;
+        if (traversableResolverClass != null) {
+            try {
+                @SuppressWarnings("unchecked")
+                Class<TraversableResolver> clazz = (Class<TraversableResolver>) classLoader.loadClass(traversableResolverClass);
+                target.traversableResolver(clazz.newInstance());
+            } catch (Exception e) {
+                logger.warning("Unable to set "+traversableResolverClass+ " as traversable resolver.", e);
+            }
+            logger.info("Using " + traversableResolverClass + " as traversable resolver.");
+        }
+        String constraintFactoryClass = info.constraintFactoryClass;
+        if (constraintFactoryClass != null) {
+            try {
+                @SuppressWarnings("unchecked")
+                Class<ConstraintValidatorFactory> clazz = (Class<ConstraintValidatorFactory>) classLoader.loadClass(constraintFactoryClass);
+                target.constraintValidatorFactory(clazz.newInstance());
+            } catch (Exception e) {
+                logger.warning("Unable to set "+constraintFactoryClass+ " as constraint factory.", e);
+            }
+            logger.info("Using " + constraintFactoryClass + " as constraint factory.");
+        }
+        for (Map.Entry<Object, Object> entry : info.propertyTypes.entrySet()) {
+            PropertyType property = new PropertyType();
+            property.setName((String) entry.getKey());
+            property.setValue((String) entry.getValue());
+
+            if (logger.isDebugEnabled()) {
+                logger.debug("Found property '" + property.getName() + "' with value '" + property.getValue());
+            }
+            target.addProperty(property.getName(), property.getValue());
+        }
+        for (String mappingFileName : info.constraintMappings) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Opening input stream for " + mappingFileName);
+            }
+            InputStream in = classLoader.getResourceAsStream(mappingFileName);
+            if (in == null) {
+                throw new ValidationException("Unable to open input stream for mapping file " + mappingFileName);
+            }
+            target.addMapping(in);
+        }
+
+        return target;
+    }
+}

Added: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorFactoryWrapper.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorFactoryWrapper.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorFactoryWrapper.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ValidatorFactoryWrapper.java Tue May 10 11:19:47 2011
@@ -0,0 +1,59 @@
+package org.apache.openejb.assembler.classic;
+
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
+import javax.validation.Validator;
+import javax.validation.ValidatorContext;
+import javax.validation.ValidatorFactory;
+
+/**
+ * @author Romain Manni-Bucau
+ */
+public class ValidatorFactoryWrapper implements ValidatorFactory {
+    public static final Logger logger = Logger.getInstance(LogCategory.OPENEJB, ValidatorFactoryWrapper.class);
+
+    private ValidatorFactory factory() {
+        try {
+            return (ValidatorFactory) new InitialContext().lookup("java:comp/ValidatorFactory");
+        } catch (NamingException e) {
+            logger.warning("validator factory not found for current module ");
+            return null;
+        }
+    }
+
+    @Override
+    public Validator getValidator() {
+        return factory().getValidator();
+    }
+
+    @Override
+    public ValidatorContext usingContext() {
+        return factory().usingContext();
+    }
+
+    @Override
+    public MessageInterpolator getMessageInterpolator() {
+        return factory().getMessageInterpolator();
+    }
+
+    @Override
+    public TraversableResolver getTraversableResolver() {
+        return factory().getTraversableResolver();
+    }
+
+    @Override
+    public ConstraintValidatorFactory getConstraintValidatorFactory() {
+        return factory().getConstraintValidatorFactory();
+    }
+
+    @Override
+    public <T> T unwrap(Class<T> tClass) {
+        return factory().unwrap(tClass);
+    }
+}

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WebAppInfo.java Tue May 10 11:19:47 2011
@@ -22,7 +22,7 @@ import java.util.TreeSet;
 import java.util.List;
 import java.util.ArrayList;
 
-public class WebAppInfo extends InfoObject {
+public class WebAppInfo extends ValidationInfoObject {
     public String codebase;
     public String description;
     public String displayName;

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Tue May 10 11:19:47 2011
@@ -142,6 +142,8 @@ import javax.persistence.PersistenceCont
 import javax.persistence.PersistenceContexts;
 import javax.persistence.PersistenceUnit;
 import javax.persistence.PersistenceUnits;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceProvider;
 import javax.xml.ws.WebServiceRef;

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java Tue May 10 11:19:47 2011
@@ -64,6 +64,8 @@ import static org.apache.openejb.util.Jo
 
 import javax.jms.Queue;
 import javax.jms.Topic;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
 
 import java.io.File;
 import java.io.IOException;
@@ -97,6 +99,9 @@ public class AutoConfig implements Dynam
         // User transaction is automatically handled
         ignoredReferenceTypes.add("javax.transaction.UserTransaction");
         ignoredReferenceTypes.add("javax.ejb.TimerService");
+        // Bean Validation is automatically handled
+        ignoredReferenceTypes.add(Validator.class.getName());
+        ignoredReferenceTypes.add(ValidatorFactory.class.getName());
     }
 
     private final ConfigurationFactory configFactory;

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ClientModule.java Tue May 10 11:19:47 2011
@@ -30,7 +30,7 @@ import java.io.File;
 /**
  * @version $Rev$ $Date$
  */
-public class ClientModule implements DeploymentModule {
+public class ClientModule extends Module implements DeploymentModule {
     private final ValidationContext validation;
     private ApplicationClient applicationClient;
     private String jarLocation;
@@ -40,7 +40,6 @@ public class ClientModule implements Dep
     private AtomicReference<ClassFinder> finder;
     private final Set<String> localClients = new HashSet<String>();
     private final Set<String> remoteClients = new HashSet<String>();
-    private final Map<String,Object> altDDs = new HashMap<String,Object>();
     private final String moduleId;
     private final Set<String> watchedResources = new TreeSet<String>();
 
@@ -91,10 +90,6 @@ public class ClientModule implements Dep
         return moduleId;
     }
 
-    public Map<String, Object> getAltDDs() {
-        return altDDs;
-    }
-
     public ApplicationClient getApplicationClient() {
         return applicationClient;
     }

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ConnectorModule.java Tue May 10 11:19:47 2011
@@ -30,9 +30,8 @@ import java.net.URL;
 /**
  * @version $Rev$ $Date$
  */
-public class ConnectorModule implements DeploymentModule {
+public class ConnectorModule extends Module implements DeploymentModule {
     private final ValidationContext validation;
-    private final Map<String,Object> altDDs = new HashMap<String,Object>();
 
     private Connector connector;
     private ClassLoader classLoader;
@@ -77,10 +76,6 @@ public class ConnectorModule implements 
         return moduleId;
     }
 
-    public Map<String, Object> getAltDDs() {
-        return altDDs;
-    }
-
     public Connector getConnector() {
         return connector;
     }

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/EjbModule.java Tue May 10 11:19:47 2011
@@ -34,7 +34,7 @@ import java.util.concurrent.atomic.Atomi
  * Class is intentionally not an interface as that would encourage "smart" implementations
  * @version $Revision$ $Date$
  */
-public class EjbModule implements WsModule {
+public class EjbModule extends Module implements WsModule {
 
     private final ValidationContext validation;
 
@@ -45,7 +45,6 @@ public class EjbModule implements WsModu
     private Webservices webservices;
     private String moduleId;
     private final AtomicReference<ClassFinder> finder = new AtomicReference<ClassFinder>();
-    private final Map<String,Object> altDDs = new HashMap<String,Object>();
     private final Set<String> watchedResources = new TreeSet<String>();
 
     private ClientModule clientModule;
@@ -120,10 +119,6 @@ public class EjbModule implements WsModu
         return validation;
     }
 
-    public Map<String, Object> getAltDDs() {
-        return altDDs;
-    }
-
     public ClassLoader getClassLoader() {
         return classLoader;
     }

Added: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java Tue May 10 11:19:47 2011
@@ -0,0 +1,35 @@
+package org.apache.openejb.config;
+
+import org.apache.openejb.jee.bval.ValidationConfigType;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Module {
+    private static int currentId = 1; // unique id to be able to bind something for each module in the jndi tree
+
+    private ValidationConfigType validationConfig;
+    private final Map<String, Object> altDDs = new HashMap<String, Object>();
+
+    private String uniqueId;
+
+        public Module() {
+        uniqueId = Integer.toString(currentId++);
+    }
+
+    public ValidationConfigType getValidationConfig() {
+        return validationConfig;
+    }
+
+    public void setValidationConfig(ValidationConfigType v) {
+        validationConfig = v;
+    }
+
+    public Map<String, Object> getAltDDs() {
+        return altDDs;
+    }
+
+    public String getUniqueId() {
+        return uniqueId;
+    }
+}

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java Tue May 10 11:19:47 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.openejb.config;
 
-import static org.apache.openejb.util.URLs.toFilePath;
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.core.webservices.WsdlResolver;
 import org.apache.openejb.jee.ApplicationClient;
@@ -25,6 +24,8 @@ import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.FacesConfig;
 import org.apache.openejb.jee.HandlerChains;
 import org.apache.openejb.jee.JavaWsdlMapping;
+import org.apache.openejb.assembler.classic.ValidatorBuilder;
+import org.apache.openejb.config.rules.ValidationBase;
 import org.apache.openejb.jee.JaxbJavaee;
 import org.apache.openejb.jee.TldTaglib;
 import org.apache.openejb.jee.WebApp;
@@ -57,6 +58,7 @@ import java.io.FileOutputStream;
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.net.URL;
 import java.util.List;
 
@@ -73,19 +75,23 @@ public class ReadDescriptors implements 
                 readOpenejbJar(ejbModule);
             }
 
+            readValidationConfigType(ejbModule);
             readCmpOrm(ejbModule);
         }
 
         for (ClientModule clientModule : appModule.getClientModules()) {
             readAppClient(clientModule, appModule);
+            readValidationConfigType(clientModule);
         }
 
         for (ConnectorModule connectorModule : appModule.getResourceModules()) {
             readConnector(connectorModule, appModule);
+            readValidationConfigType(connectorModule);
         }
 
         for (WebModule webModule : appModule.getWebModules()) {
             readWebApp(webModule, appModule);
+            readValidationConfigType(webModule);
         }
 
         List<URL> persistenceUrls = (List<URL>) appModule.getAltDDs().get("persistence.xml");
@@ -118,6 +124,16 @@ public class ReadDescriptors implements 
 
     }
 
+    private void readValidationConfigType(Module module) {
+        if (module.getValidationConfig() != null) {
+            return;
+        }
+        URL url = (URL) module.getAltDDs().get("validation.xml");
+        if (url != null) {
+            module.setValidationConfig(ValidatorBuilder.readConfig(url));
+        }
+    }
+
     private void readOpenejbJar(EjbModule ejbModule) throws OpenEJBException {
         Source source = getSource(ejbModule.getAltDDs().get("openejb-jar.xml"));
 

Modified: openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java?rev=1101405&r1=1101404&r2=1101405&view=diff
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java (original)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/main/java/org/apache/openejb/config/WebModule.java Tue May 10 11:19:47 2011
@@ -34,9 +34,8 @@ import org.apache.xbean.finder.ClassFind
 /**
  * @version $Rev$ $Date$
  */
-public class WebModule implements WsModule {
+public class WebModule extends Module implements WsModule {
     private final ValidationContext validation;
-    private final Map<String,Object> altDDs = new HashMap<String,Object>();
 
     private WebApp webApp;
     private Webservices webservices;
@@ -102,10 +101,6 @@ public class WebModule implements WsModu
         return moduleId;
     }
 
-    public Map<String, Object> getAltDDs() {
-        return altDDs;
-    }
-
     public WebApp getWebApp() {
         return webApp;
     }

Added: openejb/branches/openejb-3.2.x/container/openejb-core/src/test/java/org/apache/openejb/bval/BeanValidationTest.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-core/src/test/java/org/apache/openejb/bval/BeanValidationTest.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-core/src/test/java/org/apache/openejb/bval/BeanValidationTest.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-core/src/test/java/org/apache/openejb/bval/BeanValidationTest.java Tue May 10 11:19:47 2011
@@ -0,0 +1,144 @@
+package org.apache.openejb.bval;
+
+import org.apache.openejb.jee.EmptyType;
+import org.apache.openejb.jee.StatelessBean;
+import org.apache.openejb.jee.jpa.unit.Persistence;
+import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Configuration;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.EJBException;
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.naming.InitialContext;
+import javax.persistence.Entity;
+import javax.persistence.EntityManager;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.PersistenceContext;
+import javax.validation.ConstraintViolationException;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.rmi.RemoteException;
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+/**
+ * @author Romain Manni-Bucau
+ */
+@RunWith(ApplicationComposer.class)
+public class BeanValidationTest {
+    @EJB private PersistManager persistManager;
+    @Resource private Validator validator;
+    @Resource private ValidatorFactory validatorFactory;
+
+    @Configuration public Properties config() {
+        final Properties p = new Properties();
+        p.put("bvalDatabase", "new://Resource?type=DataSource");
+        p.put("bvalDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+        p.put("bvalDatabase.JdbcUrl", "jdbc:hsqldb:mem:bval");
+        return p;
+    }
+
+    @Module public StatelessBean app() throws Exception {
+        final StatelessBean bean = new StatelessBean(PersistManager.class);
+        bean.setLocalBean(new EmptyType());
+        return bean;
+    }
+
+    @Module public Persistence persistence() {
+        PersistenceUnit unit = new PersistenceUnit("foo-unit");
+        unit.addClass(EntityToValidate.class);
+        unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+        unit.getProperties().setProperty("openjpa.RuntimeUnenhancedClasses", "supported");
+        unit.setExcludeUnlistedClasses(true);
+
+        Persistence persistence = new Persistence(unit);
+        persistence.setVersion("2.0");
+        return persistence;
+    }
+
+    @LocalBean
+    @Stateless
+    public static class PersistManager {
+        @PersistenceContext private EntityManager em;
+
+        public void persistValid() {
+            EntityToValidate entity = new EntityToValidate();
+            entity.setName("name");
+            em.persist(entity);
+        }
+
+        public void persistNotValid() {
+            em.persist(new EntityToValidate());
+        }
+    }
+
+    @Entity
+    public static class EntityToValidate {
+        @Id @GeneratedValue private long id;
+        @NotNull @Size(min = 1, max = 5) private String name;
+
+        public long getId() {
+            return id;
+        }
+
+        public void setId(long i) {
+            id = i;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String n) {
+            name = n;
+        }
+    }
+
+    @Test public void valid()  {
+        persistManager.persistValid();
+    }
+
+    @Test public void notValid()  {
+        try {
+            persistManager.persistNotValid();
+            fail();
+        } catch (Exception wrappingException) {
+            assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+            ConstraintViolationException constraintViolationException = (ConstraintViolationException) wrappingException.getCause();
+            assertEquals(1, constraintViolationException.getConstraintViolations().size());
+        }
+    }
+
+    @Test public void lookupValidatorFactory() throws Exception {
+        ValidatorFactory validatorFactory = (ValidatorFactory) new InitialContext().lookup("java:comp/ValidatorFactory");
+        assertNotNull(validatorFactory);
+    }
+
+    @Test public void lookupValidator() throws Exception {
+        Validator validator = (Validator)  new InitialContext().lookup("java:comp/Validator");
+        assertNotNull(validator);
+    }
+
+    @Test public void injectionValidatorFactory() {
+        assertNotNull(validatorFactory);
+    }
+
+    @Test public void injectionValidator() {
+        assertNotNull(validator);
+    }
+}

Added: openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/AnnotationType.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/AnnotationType.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/AnnotationType.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/AnnotationType.java Tue May 10 11:19:47 2011
@@ -0,0 +1,66 @@
+package org.apache.openejb.jee.bval;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for annotationType complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="annotationType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="element" type="{http://jboss.org/xml/ns/javax/validation/mapping}elementType" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "annotationType", propOrder = {
+    "element"
+})
+public class AnnotationType {
+
+    protected List<ElementType> element;
+
+    /**
+     * Gets the value of the element property.
+     * 
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the element property.
+     * 
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getElement().add(newItem);
+     * </pre>
+     * 
+     * 
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link ElementType }
+     * 
+     * 
+     */
+    public List<ElementType> getElement() {
+        if (element == null) {
+            element = new ArrayList<ElementType>();
+        }
+        return this.element;
+    }
+
+}

Added: openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/BeanType.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/BeanType.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/BeanType.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/BeanType.java Tue May 10 11:19:47 2011
@@ -0,0 +1,185 @@
+package org.apache.openejb.jee.bval;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for beanType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="beanType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="class" type="{http://jboss.org/xml/ns/javax/validation/mapping}classType" minOccurs="0"/>
+ *         &lt;element name="field" type="{http://jboss.org/xml/ns/javax/validation/mapping}fieldType" maxOccurs="unbounded" minOccurs="0"/>
+ *         &lt;element name="getter" type="{http://jboss.org/xml/ns/javax/validation/mapping}getterType" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="class" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       &lt;attribute name="ignore-annotations" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "beanType", propOrder = {
+    "classType",
+    "field",
+    "getter"
+})
+public class BeanType {
+
+    @XmlElement(name = "class")
+    protected ClassType classType;
+    protected List<FieldType> field;
+    protected List<GetterType> getter;
+    @XmlAttribute(name = "class", required = true)
+    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+    protected String clazz;
+    @XmlAttribute(name = "ignore-annotations")
+    protected Boolean ignoreAnnotations;
+
+    /**
+     * Gets the value of the classType property.
+     *
+     * @return
+     *     possible object is
+     *     {@link ClassType }
+     *
+     */
+    public ClassType getClassType() {
+        return classType;
+    }
+
+    /**
+     * Sets the value of the classType property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link ClassType }
+     *
+     */
+    public void setClassType(ClassType value) {
+        this.classType = value;
+    }
+
+    /**
+     * Gets the value of the field property.
+     *
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the field property.
+     *
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getField().add(newItem);
+     * </pre>
+     *
+     *
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link FieldType }
+     *
+     *
+     */
+    public List<FieldType> getField() {
+        if (field == null) {
+            field = new ArrayList<FieldType>();
+        }
+        return this.field;
+    }
+
+    /**
+     * Gets the value of the getter property.
+     *
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the getter property.
+     *
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getGetter().add(newItem);
+     * </pre>
+     *
+     *
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link GetterType }
+     *
+     *
+     */
+    public List<GetterType> getGetter() {
+        if (getter == null) {
+            getter = new ArrayList<GetterType>();
+        }
+        return this.getter;
+    }
+
+    /**
+     * Gets the value of the clazz property.
+     *
+     * @return
+     *     possible object is
+     *     {@link String }
+     *
+     */
+    public String getClazz() {
+        return clazz;
+    }
+
+    /**
+     * Sets the value of the clazz property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *
+     */
+    public void setClazz(String value) {
+        this.clazz = value;
+    }
+
+    /**
+     * Gets the value of the ignoreAnnotations property.
+     *
+     * @return
+     *     possible object is
+     *     {@link Boolean }
+     *
+     */
+    public Boolean isIgnoreAnnotations() {
+        return ignoreAnnotations;
+    }
+
+    /**
+     * Sets the value of the ignoreAnnotations property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link Boolean }
+     *
+     */
+    public void setIgnoreAnnotations(Boolean value) {
+        this.ignoreAnnotations = value;
+    }
+
+}

Added: openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ClassType.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ClassType.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ClassType.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ClassType.java Tue May 10 11:19:47 2011
@@ -0,0 +1,123 @@
+package org.apache.openejb.jee.bval;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for classType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="classType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="group-sequence" type="{http://jboss.org/xml/ns/javax/validation/mapping}groupSequenceType" minOccurs="0"/>
+ *         &lt;element name="constraint" type="{http://jboss.org/xml/ns/javax/validation/mapping}constraintType" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="ignore-annotations" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "classType", propOrder = {
+    "groupSequence",
+    "constraint"
+})
+public class ClassType {
+
+    @XmlElement(name = "group-sequence")
+    protected GroupSequenceType groupSequence;
+    protected List<ConstraintType> constraint;
+    @XmlAttribute(name = "ignore-annotations")
+    protected Boolean ignoreAnnotations;
+
+    /**
+     * Gets the value of the groupSequence property.
+     *
+     * @return
+     *     possible object is
+     *     {@link GroupSequenceType }
+     *
+     */
+    public GroupSequenceType getGroupSequence() {
+        return groupSequence;
+    }
+
+    /**
+     * Sets the value of the groupSequence property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link GroupSequenceType }
+     *
+     */
+    public void setGroupSequence(GroupSequenceType value) {
+        this.groupSequence = value;
+    }
+
+    /**
+     * Gets the value of the constraint property.
+     *
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the constraint property.
+     *
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getConstraint().add(newItem);
+     * </pre>
+     *
+     *
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link ConstraintType }
+     *
+     *
+     */
+    public List<ConstraintType> getConstraint() {
+        if (constraint == null) {
+            constraint = new ArrayList<ConstraintType>();
+        }
+        return this.constraint;
+    }
+
+    /**
+     * Gets the value of the ignoreAnnotations property.
+     *
+     * @return
+     *     possible object is
+     *     {@link Boolean }
+     *
+     */
+    public Boolean isIgnoreAnnotations() {
+        return ignoreAnnotations;
+    }
+
+    /**
+     * Sets the value of the ignoreAnnotations property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link Boolean }
+     *
+     */
+    public void setIgnoreAnnotations(Boolean value) {
+        this.ignoreAnnotations = value;
+    }
+
+}

Added: openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintDefinitionType.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintDefinitionType.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintDefinitionType.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintDefinitionType.java Tue May 10 11:19:47 2011
@@ -0,0 +1,92 @@
+package org.apache.openejb.jee.bval;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for constraint-definitionType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="constraint-definitionType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="validated-by" type="{http://jboss.org/xml/ns/javax/validation/mapping}validated-byType"/>
+ *       &lt;/sequence>
+ *       &lt;attribute name="annotation" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "constraint-definitionType", propOrder = {
+    "validatedBy"
+})
+public class ConstraintDefinitionType {
+
+    @XmlElement(name = "validated-by", required = true)
+    protected ValidatedByType validatedBy;
+    @XmlAttribute(required = true)
+    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+    protected String annotation;
+
+    /**
+     * Gets the value of the validatedBy property.
+     *
+     * @return
+     *     possible object is
+     *     {@link ValidatedByType }
+     *
+     */
+    public ValidatedByType getValidatedBy() {
+        return validatedBy;
+    }
+
+    /**
+     * Sets the value of the validatedBy property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link ValidatedByType }
+     *
+     */
+    public void setValidatedBy(ValidatedByType value) {
+        this.validatedBy = value;
+    }
+
+    /**
+     * Gets the value of the annotation property.
+     *
+     * @return
+     *     possible object is
+     *     {@link String }
+     *
+     */
+    public String getAnnotation() {
+        return annotation;
+    }
+
+    /**
+     * Sets the value of the annotation property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *
+     */
+    public void setAnnotation(String value) {
+        this.annotation = value;
+    }
+
+}

Added: openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintMappingsType.java
URL: http://svn.apache.org/viewvc/openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintMappingsType.java?rev=1101405&view=auto
==============================================================================
--- openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintMappingsType.java (added)
+++ openejb/branches/openejb-3.2.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/bval/ConstraintMappingsType.java Tue May 10 11:19:47 2011
@@ -0,0 +1,131 @@
+package org.apache.openejb.jee.bval;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for constraint-mappingsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="constraint-mappingsType">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="default-package" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         &lt;element name="bean" type="{http://jboss.org/xml/ns/javax/validation/mapping}beanType" maxOccurs="unbounded" minOccurs="0"/>
+ *         &lt;element name="constraint-definition" type="{http://jboss.org/xml/ns/javax/validation/mapping}constraint-definitionType" maxOccurs="unbounded" minOccurs="0"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "constraint-mappingsType", propOrder = {
+    "defaultPackage",
+    "bean",
+    "constraintDefinition"
+})
+public class ConstraintMappingsType {
+    @XmlElement(name = "default-package")
+    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+    protected String defaultPackage;
+    protected List<BeanType> bean;
+    @XmlElement(name = "constraint-definition")
+    protected List<ConstraintDefinitionType> constraintDefinition;
+
+    /**
+     * Gets the value of the defaultPackage property.
+     *
+     * @return
+     *     possible object is
+     *     {@link String }
+     *
+     */
+    public String getDefaultPackage() {
+        return defaultPackage;
+    }
+
+    /**
+     * Sets the value of the defaultPackage property.
+     *
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *
+     */
+    public void setDefaultPackage(String value) {
+        this.defaultPackage = value;
+    }
+
+    /**
+     * Gets the value of the bean property.
+     *
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the bean property.
+     *
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getBean().add(newItem);
+     * </pre>
+     *
+     *
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link BeanType }
+     *
+     *
+     */
+    public List<BeanType> getBean() {
+        if (bean == null) {
+            bean = new ArrayList<BeanType>();
+        }
+        return this.bean;
+    }
+
+    /**
+     * Gets the value of the constraintDefinition property.
+     *
+     * <p>
+     * This accessor method returns a reference to the live list,
+     * not a snapshot. Therefore any modification you make to the
+     * returned list will be present inside the JAXB object.
+     * This is why there is not a <CODE>set</CODE> method for the constraintDefinition property.
+     *
+     * <p>
+     * For example, to add a new item, do as follows:
+     * <pre>
+     *    getConstraintDefinition().add(newItem);
+     * </pre>
+     *
+     *
+     * <p>
+     * Objects of the following type(s) are allowed in the list
+     * {@link ConstraintDefinitionType }
+     *
+     *
+     */
+    public List<ConstraintDefinitionType> getConstraintDefinition() {
+        if (constraintDefinition == null) {
+            constraintDefinition = new ArrayList<ConstraintDefinitionType>();
+        }
+        return this.constraintDefinition;
+    }
+
+}
+



Mime
View raw message