[jboss-cvs] JBossAS SVN: r92308 - in projects/jboss-jsr303/trunk: deployers and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 13 10:08:33 EDT 2009
Author: alesj
Date: 2009-08-13 10:08:31 -0400 (Thu, 13 Aug 2009)
New Revision: 92308
Added:
projects/jboss-jsr303/trunk/deployers/src/main/java/org/
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/ValidatorFactoryDeployer.java
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/ValidatorFactoryJndiBinderDeployer.java
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/AttachmentPresentDeploymentUnitFilter.java
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/DefaultJndiNameCreator.java
projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/JndiNameCreator.java
projects/jboss-jsr303/trunk/deployers/src/test/java/org/
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/DeployersTestSuite.java
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/AllDUFilter.java
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/MockVFJndiBinderDeployer.java
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/test/
projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/test/SmokeTestCase.java
projects/jboss-jsr303/trunk/deployers/src/test/resources/org/
projects/jboss-jsr303/trunk/deployers/src/test/resources/org/jboss/
projects/jboss-jsr303/trunk/deployers/src/test/resources/org/jboss/test/
projects/jboss-jsr303/trunk/deployers/src/test/resources/org/jboss/test/deployers/
projects/jboss-jsr303/trunk/deployers/src/test/resources/org/jboss/test/deployers/test/
projects/jboss-jsr303/trunk/deployers/src/test/resources/org/jboss/test/deployers/test/SmokeTestCase.xml
projects/jboss-jsr303/trunk/deployers/src/test/resources/smoke/
projects/jboss-jsr303/trunk/deployers/src/test/resources/smoke/smoke-beans.xml
Modified:
projects/jboss-jsr303/trunk/deployers/pom.xml
projects/jboss-jsr303/trunk/deployers/src/main/assembly/META-INF/bv-core-jboss-beans.xml
projects/jboss-jsr303/trunk/deployers/src/main/assembly/META-INF/bv-deployers-jboss-beans.xml
projects/jboss-jsr303/trunk/pom.xml
Log:
[JBAS-7167]; initial BV deployers.
Modified: projects/jboss-jsr303/trunk/deployers/pom.xml
===================================================================
--- projects/jboss-jsr303/trunk/deployers/pom.xml 2009-08-13 13:53:00 UTC (rev 92307)
+++ projects/jboss-jsr303/trunk/deployers/pom.xml 2009-08-13 14:08:31 UTC (rev 92308)
@@ -153,11 +153,17 @@
<!-- Test dependencies -->
- <!-- dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-vfs</artifactId>
<type>test-jar</type>
- <scope>test</scope -->
+ <scope>test</scope>
<!--
<exclusions>
<exclusion>
@@ -176,8 +182,8 @@
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloading</artifactId>
</exclusion>
- </exclusions>
- </dependency -->
+ </exclusions -->
+ </dependency>
<dependency>
<groupId>org.jboss.test</groupId>
Modified: projects/jboss-jsr303/trunk/deployers/src/main/assembly/META-INF/bv-core-jboss-beans.xml
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/main/assembly/META-INF/bv-core-jboss-beans.xml 2009-08-13 13:53:00 UTC (rev 92307)
+++ projects/jboss-jsr303/trunk/deployers/src/main/assembly/META-INF/bv-core-jboss-beans.xml 2009-08-13 14:08:31 UTC (rev 92308)
@@ -1,59 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Web Beans RI + JBossAS integration
+ Bean Validation (jsr303) core beans.
-->
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- Web Beans deployers -->
-
- <!-- Responsible for discovering Web Bean files -->
- <bean name="WebBeansFilesDeployer" class="org.jboss.webbeans.integration.deployer.metadata.WebBeansFilesDeployer"/>
+ <!-- ValidatorFactory factory -->
+ <beanfactory name="ValidatorFactoryFactory" class="javax.validation.ValidatorFactory">
+ <constructor factoryClass="javax.validation.Validation" factoryMethod="buildDefaultValidatorFactory" />
+ </beanfactory>
- <!-- Responsible for discovering Web Bean classes -->
- <bean name="WebBeansDiscoveryDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeanDiscoveryDeployer"/>
-
- <!-- Responsible for discovering Web Bean classes -->
- <bean name="EjbServicesDeployer" class="org.jboss.webbeans.integration.deployer.env.EjbServicesDeployer"/>
-
- <!-- Responsible for discovering Web Bean classes -->
- <bean name="FlatDeploymentDeployer" class="org.jboss.webbeans.integration.deployer.env.FlatDeploymentDeployer"/>
-
- <!-- Responsible for dynamic ejb dependency creation -->
- <bean name="DynamicDependencyCreator" class="org.jboss.webbeans.integration.deployer.env.DynamicDependencyCreator">
- <constructor>
- <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
- </constructor>
+ <!-- JEE DU filter -->
+ <bean name="VFDUFilter" class="org.jboss.jsr303.util.AttachmentPresentDeploymentUnitFilter">
+ <property name="attachmentNames">
+ <set>
+ <value>org.jboss.metadata.web.jboss.JBossWebMetaData</value>
+ <value>org.jboss.metadata.ejb.jboss.JBossMetaData</value>
+ </set>
+ </property>
</bean>
- <!-- Responsible for booting Web Beans -->
- <bean name="WebBeansBootstrapDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeansBootstrapDeployer"/>
-
- <!-- Responsible for pushing the JSF onto the application classpath -->
- <bean name="WebBeansFacesIntegrationDeployer" class="org.jboss.webbeans.integration.deployer.cl.WebBeansFacesIntegrationDeployer"/>
-
- <!-- Responsible for pushing the WB RI onto the application classpath -->
- <bean name="WebBeansCoreIntegrationDeployer" class="org.jboss.webbeans.integration.deployer.cl.WebBeansCoreIntegrationDeployer"/>
+ <!-- Default JNDI name creator -->
+ <bean name="DefaultJndiNameCreator" class="org.jboss.jsr303.util.DefaultJndiNameCreator" />
- <!-- Responsible for inserting the Web Beans RI EJB interceptor -->
- <bean name="PostEjbJarMetadataDeployer" class="org.jboss.webbeans.integration.deployer.metadata.WBEjbInterceptorMetadataDeployer"/>
-
- <!-- Responsible for enabling classloader isolation for Web Bean jars -->
- <bean name="PostJBossMetadataDeployer" class="org.jboss.webbeans.integration.deployer.metadata.PostJBossMetadataDeployer"/>
-
- <!-- Responsible for enabling classloader isolation for Web Bean wars -->
- <bean name="PostJBossWebMetadataDeployer" class="org.jboss.webbeans.integration.deployer.metadata.PostJBossWebMetadataDeployer"/>
-
- <!-- Responsible for adding the Web Beans RI listener to the Servlet -->
- <bean name="PostWebMetadataDeployer" class="org.jboss.webbeans.integration.deployer.metadata.PostWebMetadataDeployer"/>
-
- <!-- Responsible for adding the Web Beans Manager object factory to JNDI -->
- <bean name="WebBeansJndiBinder" class="org.jboss.webbeans.integration.deployer.env.WebBeansJndiBinder">
- <start method="startService">
- <parameter>java:app/BeanManager</parameter>
- <parameter>org.jboss.webbeans.resources.ManagerObjectFactory</parameter>
- </start>
- <stop method="stopService"/>
- </bean>
-
</deployment>
Modified: projects/jboss-jsr303/trunk/deployers/src/main/assembly/META-INF/bv-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/main/assembly/META-INF/bv-deployers-jboss-beans.xml 2009-08-13 13:53:00 UTC (rev 92307)
+++ projects/jboss-jsr303/trunk/deployers/src/main/assembly/META-INF/bv-deployers-jboss-beans.xml 2009-08-13 14:08:31 UTC (rev 92308)
@@ -1,59 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Web Beans RI + JBossAS integration
+ Bean Validator (jsr303) deployers.
-->
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- Web Beans deployers -->
-
- <!-- Responsible for discovering Web Bean files -->
- <bean name="WebBeansFilesDeployer" class="org.jboss.webbeans.integration.deployer.metadata.WebBeansFilesDeployer"/>
-
- <!-- Responsible for discovering Web Bean classes -->
- <bean name="WebBeansDiscoveryDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeanDiscoveryDeployer"/>
-
- <!-- Responsible for discovering Web Bean classes -->
- <bean name="EjbServicesDeployer" class="org.jboss.webbeans.integration.deployer.env.EjbServicesDeployer"/>
-
- <!-- Responsible for discovering Web Bean classes -->
- <bean name="FlatDeploymentDeployer" class="org.jboss.webbeans.integration.deployer.env.FlatDeploymentDeployer"/>
-
- <!-- Responsible for dynamic ejb dependency creation -->
- <bean name="DynamicDependencyCreator" class="org.jboss.webbeans.integration.deployer.env.DynamicDependencyCreator">
+ <!-- ValidatorFactory creator -->
+ <bean name="VFCreator" class="org.jboss.jsr303.deployers.ValidatorFactoryDeployer">
<constructor>
- <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
+ <parameter><inject bean="ValidatorFactoryFactory" /></parameter>
</constructor>
+ <property name="filter"><inject bean="VFDUFilter" /></property>
</bean>
- <!-- Responsible for booting Web Beans -->
- <bean name="WebBeansBootstrapDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeansBootstrapDeployer"/>
-
- <!-- Responsible for pushing the JSF onto the application classpath -->
- <bean name="WebBeansFacesIntegrationDeployer" class="org.jboss.webbeans.integration.deployer.cl.WebBeansFacesIntegrationDeployer"/>
-
- <!-- Responsible for pushing the WB RI onto the application classpath -->
- <bean name="WebBeansCoreIntegrationDeployer" class="org.jboss.webbeans.integration.deployer.cl.WebBeansCoreIntegrationDeployer"/>
-
- <!-- Responsible for inserting the Web Beans RI EJB interceptor -->
- <bean name="PostEjbJarMetadataDeployer" class="org.jboss.webbeans.integration.deployer.metadata.WBEjbInterceptorMetadataDeployer"/>
-
- <!-- Responsible for enabling classloader isolation for Web Bean jars -->
- <bean name="PostJBossMetadataDeployer" class="org.jboss.webbeans.integration.deployer.metadata.PostJBossMetadataDeployer"/>
-
- <!-- Responsible for enabling classloader isolation for Web Bean wars -->
- <bean name="PostJBossWebMetadataDeployer" class="org.jboss.webbeans.integration.deployer.metadata.PostJBossWebMetadataDeployer"/>
-
- <!-- Responsible for adding the Web Beans RI listener to the Servlet -->
- <bean name="PostWebMetadataDeployer" class="org.jboss.webbeans.integration.deployer.metadata.PostWebMetadataDeployer"/>
-
- <!-- Responsible for adding the Web Beans Manager object factory to JNDI -->
- <bean name="WebBeansJndiBinder" class="org.jboss.webbeans.integration.deployer.env.WebBeansJndiBinder">
- <start method="startService">
- <parameter>java:app/BeanManager</parameter>
- <parameter>org.jboss.webbeans.resources.ManagerObjectFactory</parameter>
- </start>
- <stop method="stopService"/>
+ <!-- ValidatorFactory jndi binder -->
+ <bean name="VFJndiBinder" class="org.jboss.jsr303.deployers.ValidatorFactoryJndiBinderDeployer">
+ <constructor>
+ <parameter><inject bean="DefaultJndiNameCreator" /></parameter>
+ </constructor>
</bean>
</deployment>
Added: projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/ValidatorFactoryDeployer.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/ValidatorFactoryDeployer.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/ValidatorFactoryDeployer.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jsr303.deployers;
+
+import javax.validation.ValidatorFactory;
+
+import org.jboss.beans.metadata.spi.factory.BeanFactory;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.DeploymentUnitFilter;
+
+/**
+ * Create ValidatorFactory and add it into deployment unit.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ValidatorFactoryDeployer extends AbstractRealDeployer
+{
+ private BeanFactory factory;
+ private DeploymentUnitFilter filter;
+
+ public ValidatorFactoryDeployer(BeanFactory factory)
+ {
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+
+ setStage(DeploymentStages.PRE_REAL);
+ setOutput(ValidatorFactory.class);
+
+ this.factory = factory;
+ }
+
+ /**
+ * Is deployer relevant.
+ *
+ * @param unit the deployment unit
+ * @return true if deployer is relevant, false otherwise
+ */
+ protected boolean isRelevant(DeploymentUnit unit)
+ {
+ return filter != null && filter.accepts(unit);
+ }
+
+ protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
+ {
+ if (isRelevant(unit))
+ {
+ try
+ {
+ Object result = factory.createBean();
+ ValidatorFactory vf = ValidatorFactory.class.cast(result);
+ unit.addAttachment(ValidatorFactory.class, vf);
+ }
+ catch (Throwable t)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error creating validator factory", t);
+ }
+ }
+ }
+
+ /**
+ * Set deployment unit filter.
+ *
+ * @param filter the deployment unit filter
+ */
+ public void setFilter(DeploymentUnitFilter filter)
+ {
+ this.filter = filter;
+ }
+}
Added: projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/ValidatorFactoryJndiBinderDeployer.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/ValidatorFactoryJndiBinderDeployer.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/deployers/ValidatorFactoryJndiBinderDeployer.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jsr303.deployers;
+
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.validation.ValidatorFactory;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.jsr303.util.JndiNameCreator;
+
+/**
+ * Bind ValidatorFactory to jndi.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ValidatorFactoryJndiBinderDeployer extends AbstractSimpleRealDeployer<ValidatorFactory>
+{
+ private JndiNameCreator jndiNameCreator;
+ private Hashtable<?, ?> environment;
+
+ public ValidatorFactoryJndiBinderDeployer(JndiNameCreator jndiNameCreator)
+ {
+ super(ValidatorFactory.class);
+
+ if (jndiNameCreator == null)
+ throw new IllegalArgumentException("Null jndi name creator");
+
+ setStage(DeploymentStages.PRE_REAL);
+ addOutput(ValidatorFactory.class.getName() + ".JNDI_NAME");
+
+ this.jndiNameCreator = jndiNameCreator;
+ }
+
+ public void deploy(DeploymentUnit unit, ValidatorFactory factory) throws DeploymentException
+ {
+ try
+ {
+ Context context = createContext();
+ context.bind(jndiNameCreator.createName(unit, factory), factory);
+ }
+ catch (Exception e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Cannot bind validator factory.", e);
+ }
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit, ValidatorFactory factory)
+ {
+ try
+ {
+ Context context = createContext();
+ context.unbind(jndiNameCreator.createName(unit, factory));
+ }
+ catch (Exception e)
+ {
+ log.warn("Exception unbinding validator factory: " + e);
+ }
+ }
+
+ /**
+ * Create context.
+ *
+ * @return new context
+ * @throws Exception for any error
+ */
+ protected Context createContext() throws Exception
+ {
+ return (environment != null) ? new InitialContext(environment) : new InitialContext();
+ }
+
+ /**
+ * Set naming context env.
+ *
+ * @param environment the env
+ */
+ public void setEnvironment(Hashtable<?, ?> environment)
+ {
+ this.environment = environment;
+ }
+}
\ No newline at end of file
Added: projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/AttachmentPresentDeploymentUnitFilter.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/AttachmentPresentDeploymentUnitFilter.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/AttachmentPresentDeploymentUnitFilter.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jsr303.util;
+
+import java.util.Set;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.DeploymentUnitFilter;
+
+/**
+ * Check if any attachment is present in deployment unit.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class AttachmentPresentDeploymentUnitFilter implements DeploymentUnitFilter
+{
+ private Set<String> attachmentNames;
+
+ public boolean accepts(DeploymentUnit unit)
+ {
+ if (attachmentNames != null && attachmentNames.isEmpty() == false)
+ {
+ for (String name : attachmentNames)
+ {
+ if (unit.isAttachmentPresent(name))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Set attachment names.
+ *
+ * @param attachmentNames the attachment names
+ */
+ public void setAttachmentNames(Set<String> attachmentNames)
+ {
+ this.attachmentNames = attachmentNames;
+ }
+}
Added: projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/DefaultJndiNameCreator.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/DefaultJndiNameCreator.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/DefaultJndiNameCreator.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jsr303.util;
+
+import javax.validation.ValidatorFactory;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Default jndi name creator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DefaultJndiNameCreator implements JndiNameCreator
+{
+ public String createName(DeploymentUnit unit, ValidatorFactory factory)
+ {
+ return "java:comp/env/" + unit.getSimpleName(); // TODO - fix this
+ }
+}
Added: projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/JndiNameCreator.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/JndiNameCreator.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/main/java/org/jboss/jsr303/util/JndiNameCreator.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jsr303.util;
+
+import javax.validation.ValidatorFactory;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Create jndi name for Validator Factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface JndiNameCreator
+{
+ /**
+ * Create jndi name from deployment unit.
+ *
+ * @param unit the deployment unit
+ * @param factory the validator factory
+ * @return new jndi name for VF
+ */
+ String createName(DeploymentUnit unit, ValidatorFactory factory);
+}
Added: projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/DeployersTestSuite.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/DeployersTestSuite.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/DeployersTestSuite.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.deployers;
+
+import junit.textui.TestRunner;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.test.deployers.test.SmokeTestCase;
+
+/**
+ * BV deployers tests suite.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DeployersTestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Deployers BV Tests");
+
+ // Smoke
+ suite.addTest(SmokeTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/AllDUFilter.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/AllDUFilter.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/AllDUFilter.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.deployers.support;
+
+import org.jboss.deployers.structure.spi.DeploymentUnitFilter;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class AllDUFilter implements DeploymentUnitFilter
+{
+ public boolean accepts(DeploymentUnit unit)
+ {
+ return true;
+ }
+}
Added: projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/MockVFJndiBinderDeployer.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/MockVFJndiBinderDeployer.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/support/MockVFJndiBinderDeployer.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.deployers.support;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.jboss.jsr303.deployers.ValidatorFactoryJndiBinderDeployer;
+import org.jboss.jsr303.util.JndiNameCreator;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockVFJndiBinderDeployer extends ValidatorFactoryJndiBinderDeployer
+{
+ public static final Context context = new MockContext();
+
+ public MockVFJndiBinderDeployer(JndiNameCreator jndiNameCreator)
+ {
+ super(jndiNameCreator);
+ }
+
+ @Override
+ protected Context createContext() throws Exception
+ {
+ return context;
+ }
+
+ private static class MockContext implements Context
+ {
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ public Object lookup(Name name) throws NamingException
+ {
+ return map.get(name);
+ }
+
+ public Object lookup(String name) throws NamingException
+ {
+ return map.get(name);
+ }
+
+ public void bind(Name name, Object obj) throws NamingException
+ {
+ map.put(name, obj);
+ }
+
+ public void bind(String name, Object obj) throws NamingException
+ {
+ map.put(name, obj);
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException
+ {
+ bind(name, obj);
+ }
+
+ public void rebind(String name, Object obj) throws NamingException
+ {
+ bind(name, obj);
+ }
+
+ public void unbind(Name name) throws NamingException
+ {
+ map.remove(name);
+ }
+
+ public void unbind(String name) throws NamingException
+ {
+ map.remove(name);
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException
+ {
+ Object previous = map.remove(oldName);
+ if (previous != null)
+ map.put(newName, previous);
+ }
+
+ public void rename(String oldName, String newName) throws NamingException
+ {
+ Object previous = map.remove(oldName);
+ if (previous != null)
+ map.put(newName, previous);
+ }
+
+ public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public NamingEnumeration<NameClassPair> list(String name) throws NamingException
+ {
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public NamingEnumeration<Binding> listBindings(String name) throws NamingException
+ {
+ return null;
+ }
+
+ public void destroySubcontext(Name name) throws NamingException
+ {
+ }
+
+ public void destroySubcontext(String name) throws NamingException
+ {
+ }
+
+ public Context createSubcontext(Name name) throws NamingException
+ {
+ return new MockContext();
+ }
+
+ public Context createSubcontext(String name) throws NamingException
+ {
+ return new MockContext();
+ }
+
+ public Object lookupLink(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public Object lookupLink(String name) throws NamingException
+ {
+ return null;
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ public NameParser getNameParser(String name) throws NamingException
+ {
+ return null;
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException
+ {
+ return null;
+ }
+
+ public String composeName(String name, String prefix) throws NamingException
+ {
+ return null;
+ }
+
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException
+ {
+ return null;
+ }
+
+ public Object removeFromEnvironment(String propName) throws NamingException
+ {
+ return null;
+ }
+
+ public Hashtable<?, ?> getEnvironment() throws NamingException
+ {
+ return null;
+ }
+
+ public void close() throws NamingException
+ {
+ map.clear();
+ }
+
+ public String getNameInNamespace() throws NamingException
+ {
+ return null;
+ }
+ }
+}
Added: projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/test/SmokeTestCase.java
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/test/SmokeTestCase.java (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/test/java/org/jboss/test/deployers/test/SmokeTestCase.java 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.deployers.test;
+
+import javax.validation.ValidatorFactory;
+
+import junit.framework.Test;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+import org.jboss.test.deployers.support.MockVFJndiBinderDeployer;
+
+/**
+ * Simple "smoke" tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class SmokeTestCase extends BootstrapDeployersTest
+{
+ public SmokeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(SmokeTestCase.class);
+ }
+
+ public void testDeployers() throws Exception
+ {
+ DeploymentUnit unit = assertDeploy("/smoke", "smoke-beans.xml");
+ try
+ {
+ ValidatorFactory factory = unit.getAttachment(ValidatorFactory.class);
+ assertNotNull(factory);
+ assertSame(factory, MockVFJndiBinderDeployer.context.lookup("java:comp/env/smoke-beans.xml"));
+ }
+ finally
+ {
+ undeploy(unit);
+
+ assertNull(MockVFJndiBinderDeployer.context.lookup("java:comp/env/smoke-beans.xml"));
+ }
+ }
+}
Added: projects/jboss-jsr303/trunk/deployers/src/test/resources/org/jboss/test/deployers/test/SmokeTestCase.xml
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/test/resources/org/jboss/test/deployers/test/SmokeTestCase.xml (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/test/resources/org/jboss/test/deployers/test/SmokeTestCase.xml 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Bean Validator (jsr303) deployers.
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- ValidatorFactory factory -->
+ <beanfactory name="ValidatorFactoryFactory" class="javax.validation.ValidatorFactory">
+ <constructor factoryClass="javax.validation.Validation" factoryMethod="buildDefaultValidatorFactory" />
+ </beanfactory>
+
+ <!-- Mock all DU filter -->
+ <bean name="AllDUFilter" class="org.jboss.test.deployers.support.AllDUFilter" />
+
+ <!-- Default JNDI name creator -->
+ <bean name="DefaultJndiNameCreator" class="org.jboss.jsr303.util.DefaultJndiNameCreator" />
+
+ <!-- ValidatorFactory creator -->
+ <bean name="VFCreator" class="org.jboss.jsr303.deployers.ValidatorFactoryDeployer">
+ <constructor>
+ <parameter><inject bean="ValidatorFactoryFactory" /></parameter>
+ </constructor>
+ <property name="filter"><inject bean="AllDUFilter" /></property>
+ </bean>
+
+ <!-- ValidatorFactory jndi binder -->
+ <bean name="VFJndiBinder" class="org.jboss.test.deployers.support.MockVFJndiBinderDeployer">
+ <constructor>
+ <parameter><inject bean="DefaultJndiNameCreator" /></parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/jboss-jsr303/trunk/deployers/src/test/resources/smoke/smoke-beans.xml
===================================================================
--- projects/jboss-jsr303/trunk/deployers/src/test/resources/smoke/smoke-beans.xml (rev 0)
+++ projects/jboss-jsr303/trunk/deployers/src/test/resources/smoke/smoke-beans.xml 2009-08-13 14:08:31 UTC (rev 92308)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Test" class="java.lang.Object" />
+
+</deployment>
Modified: projects/jboss-jsr303/trunk/pom.xml
===================================================================
--- projects/jboss-jsr303/trunk/pom.xml 2009-08-13 13:53:00 UTC (rev 92307)
+++ projects/jboss-jsr303/trunk/pom.xml 2009-08-13 14:08:31 UTC (rev 92308)
@@ -28,8 +28,9 @@
</modules>
<properties>
- <version.javax.bv>1.0.CR3</version.javax.bv>
- <version.hibernate.validator>4.0.0.Beta2</version.hibernate.validator>
+ <version.javax.bv>1.0.CR4</version.javax.bv>
+ <version.hibernate.validator>4.0.0.Beta3</version.hibernate.validator>
+ <version.slf4j>1.5.8</version.slf4j>
<version.jboss.vfs>2.1.2.GA</version.jboss.vfs>
<version.jboss.mdr>2.0.2.GA</version.jboss.mdr>
<version.jboss.man>2.1.0.GA</version.jboss.man>
@@ -366,6 +367,21 @@
<!-- test dependencies -->
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${version.slf4j}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-vfs</artifactId>
+ <version>${version.jboss.deployers}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.test</groupId>
<artifactId>jboss-test</artifactId>
<version>${version.org.jboss.test}</version>
More information about the jboss-cvs-commits
mailing list