[jboss-cvs] JBossAS SVN: r106133 - in trunk: resteasy-int/jar and 28 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 17 14:04:08 EDT 2010
Author: bill.burke at jboss.com
Date: 2010-06-17 14:04:06 -0400 (Thu, 17 Jun 2010)
New Revision: 106133
Added:
trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentScanningData.java
trunk/resteasy-int/test/cdi-test-2/
trunk/resteasy-int/test/cdi-test-2/pom.xml
trunk/resteasy-int/test/cdi-test-2/src/
trunk/resteasy-int/test/cdi-test-2/src/main/
trunk/resteasy-int/test/cdi-test-2/src/main/java/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/Cat.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/Dog.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/SubResource.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/MockResource.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/ProductionResource.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/ApplicationScopedTestResource.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/TestProvider.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/TestResource.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/InjectedStatelessEjb.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/InjectedStatelessEjbLocal.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource1.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource1Local.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource2.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource2Local.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatelessSessionBeanResource.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatelessSessionBeanResourceLocal.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestInterceptor.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestInterceptorBinding.java
trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestResource.java
trunk/resteasy-int/test/cdi-test-2/src/main/resources/
trunk/resteasy-int/test/cdi-test-2/src/main/webapp/
trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/
trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/beans.xml
trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/web.xml
trunk/resteasy-int/test/cdi-test-2/src/test/
trunk/resteasy-int/test/cdi-test-2/src/test/java/
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AbstractResourceTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AbstractResteasyCdiTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AlternativeTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ApplicationScopedResourceTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/InterceptorTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ProviderTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ResourceTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatefulSessionBeanWithAnnotationsOnBeanClassTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatefulSessionBeanWithAnnotationsOnLocalInterfaceTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatelessSessionBeanTest.java
trunk/resteasy-int/test/cdi-test-2/src/test/resources/
Removed:
trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentData.java
Modified:
trunk/component-matrix/pom.xml
trunk/resteasy-int/jar/pom.xml
trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyEjbDeployer.java
trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyIntegrationDeployer.java
trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyScannerDeployer.java
trunk/resteasy-int/test/ejb-war/pom.xml
trunk/resteasy-int/test/ejb-war/src/main/java/org/jboss/resteasy/test/MyResource.java
trunk/resteasy-int/test/pom.xml
trunk/resteasy-int/test/scanned-war/src/test/java/org/jboss/resteasy/test/jboss/ScanningTest.java
trunk/resteasy-int/zip/assembly.xml
trunk/resteasy-int/zip/pom.xml
Log:
further resteasy integration
Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/component-matrix/pom.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -141,11 +141,11 @@
<version.org.jboss.reflect>2.2.0.Alpha7</version.org.jboss.reflect>
<version.org.jboss.reloaded.naming>0.1.0</version.org.jboss.reloaded.naming>
<version.org.jboss.reloaded.naming.deployers>0.1.0</version.org.jboss.reloaded.naming.deployers>
- <version.org.jboss.resteasy>2.0-beta-2</version.org.jboss.resteasy>
+ <version.org.jboss.resteasy>2.0-beta-3</version.org.jboss.resteasy>
<version.org.jboss.remoting>2.5.2.SP2</version.org.jboss.remoting>
<version.org.jboss.remoting3>3.1.0.Beta2</version.org.jboss.remoting3>
<version.org.jboss.remoting3.metadata>1.0.0.Beta2</version.org.jboss.remoting3.metadata>
- <version.org.jboss.scanning>1.0.0.Alpha2</version.org.jboss.scanning>
+ <version.org.jboss.scanning>1.0.0.Alpha3</version.org.jboss.scanning>
<version.org.jboss.security>3.0.0.Beta4</version.org.jboss.security>
<version.org.jboss.security.negotiation>2.0.3.SP1</version.org.jboss.security.negotiation>
<version.org.jboss.service.binding>1.1.0.CR1</version.org.jboss.service.binding>
Modified: trunk/resteasy-int/jar/pom.xml
===================================================================
--- trunk/resteasy-int/jar/pom.xml 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/jar/pom.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -93,53 +93,6 @@
</exclusions>
</dependency>
- <!--
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-system-jmx</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloading</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-vfs</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-reflect</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-dependency</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-kernel</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.metadata</groupId>
- <artifactId>jboss-metadata-common</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.security</groupId>
- <artifactId>jboss-security-spi</artifactId>
- <scope>provided</scope>
- </dependency>
- -->
</dependencies>
</project>
Deleted: trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentData.java
===================================================================
--- trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentData.java 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentData.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -1,93 +0,0 @@
-package org.jboss.resteasy.integration.deployers;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
- * @version $Revision: 1 $
- */
-public class ResteasyDeploymentData
-{
- private boolean scanAll;
- private boolean scanResources;
- private boolean scanProviders;
- private boolean createDispatcher;
- private Set<String> resources = new LinkedHashSet<String>();
- private Set<String> providers = new LinkedHashSet<String>();
-
- public boolean shouldScan()
- {
- return scanAll || scanResources || scanProviders;
- }
-
- public boolean isScanAll()
- {
- return scanAll;
- }
-
- public void setScanAll(boolean scanAll)
- {
- if (scanAll)
- {
- scanResources = true;
- scanProviders = true;
- }
- this.scanAll = scanAll;
- }
-
- public boolean isScanResources()
- {
- return scanResources;
- }
-
- public void setScanResources(boolean scanResources)
- {
- this.scanResources = scanResources;
- }
-
- public boolean isScanProviders()
- {
- return scanProviders;
- }
-
- public void setScanProviders(boolean scanProviders)
- {
- this.scanProviders = scanProviders;
- }
-
- public Set<String> getResources()
- {
- return resources;
- }
-
- public void setResources(Set<String> resources)
- {
- this.resources = resources;
- }
-
- public Set<String> getProviders()
- {
- return providers;
- }
-
- public void setProviders(Set<String> providers)
- {
- this.providers = providers;
- }
-
- /**
- * A component layer wants a dispatcher created
- */
- public void createDispatcher()
- {
- this.createDispatcher = true;
- }
-
- public boolean shouldCreateDispatcher()
- {
- return createDispatcher || !resources.isEmpty() || !providers.isEmpty();
- }
-
-
-}
Copied: trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentScanningData.java (from rev 105904, trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentData.java)
===================================================================
--- trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentScanningData.java (rev 0)
+++ trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyDeploymentScanningData.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,104 @@
+package org.jboss.resteasy.integration.deployers;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class ResteasyDeploymentScanningData
+{
+ private boolean scanAll;
+ private boolean scanResources;
+ private boolean scanProviders;
+ private boolean createDispatcher;
+ private Set<String> resources = new LinkedHashSet<String>();
+ private Set<String> providers = new LinkedHashSet<String>();
+ private boolean bootClasses;
+
+ public boolean hasBootClasses()
+ {
+ return bootClasses;
+ }
+
+ public void setBootClasses(boolean bootClasses)
+ {
+ this.bootClasses = bootClasses;
+ }
+
+ public boolean shouldScan()
+ {
+ return scanAll || scanResources || scanProviders;
+ }
+
+ public boolean isScanAll()
+ {
+ return scanAll;
+ }
+
+ public void setScanAll(boolean scanAll)
+ {
+ if (scanAll)
+ {
+ scanResources = true;
+ scanProviders = true;
+ }
+ this.scanAll = scanAll;
+ }
+
+ public boolean isScanResources()
+ {
+ return scanResources;
+ }
+
+ public void setScanResources(boolean scanResources)
+ {
+ this.scanResources = scanResources;
+ }
+
+ public boolean isScanProviders()
+ {
+ return scanProviders;
+ }
+
+ public void setScanProviders(boolean scanProviders)
+ {
+ this.scanProviders = scanProviders;
+ }
+
+ public Set<String> getResources()
+ {
+ return resources;
+ }
+
+ public void setResources(Set<String> resources)
+ {
+ this.resources = resources;
+ }
+
+ public Set<String> getProviders()
+ {
+ return providers;
+ }
+
+ public void setProviders(Set<String> providers)
+ {
+ this.providers = providers;
+ }
+
+ /**
+ * A component layer wants a dispatcher created
+ */
+ public void createDispatcher()
+ {
+ this.createDispatcher = true;
+ }
+
+ public boolean shouldCreateDispatcher()
+ {
+ return createDispatcher || !resources.isEmpty() || !providers.isEmpty();
+ }
+
+
+}
Modified: trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyEjbDeployer.java
===================================================================
--- trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyEjbDeployer.java 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyEjbDeployer.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -4,6 +4,7 @@
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.ejb.deployers.MergedJBossMetaDataDeployer;
import org.jboss.ejb3.annotation.LocalBinding;
import org.jboss.logging.Logger;
@@ -36,7 +37,7 @@
super();
addRequiredInput(JBossWebMetaData.class);
- addRequiredInput(ResteasyDeploymentData.class);
+ addRequiredInput(ResteasyDeploymentScanningData.class);
addRequiredInput(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
addOutput(JBossWebMetaData.class);
setStage(DeploymentStages.PRE_REAL); // TODO -- right stage?
@@ -44,7 +45,7 @@
protected void internalDeploy(DeploymentUnit du) throws DeploymentException
{
- ResteasyDeploymentData resteasy = du.getAttachment(ResteasyDeploymentData.class);
+ ResteasyDeploymentScanningData resteasy = du.getAttachment(ResteasyDeploymentScanningData.class);
/*
log.info("*******************");
@@ -60,6 +61,7 @@
// right now I only support resources
if (!resteasy.isScanResources()) return;
+ if (((VFSDeploymentUnit)du).getMetaDataFile("beans.xml") != null) return;
JBossWebMetaData webdata = du.getAttachment(JBossWebMetaData.class);
JBossMetaData ejbs = (JBossMetaData) du
Modified: trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyIntegrationDeployer.java
===================================================================
--- trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyIntegrationDeployer.java 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyIntegrationDeployer.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -4,6 +4,7 @@
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
@@ -23,13 +24,14 @@
public class ResteasyIntegrationDeployer extends AbstractRealDeployer
{
private static final Logger LOGGER = Logger.getLogger(ResteasyIntegrationDeployer.class);
+ public static final String CDI_INJECTOR_FACTORY_CLASS = "org.jboss.resteasy.cdi.CdiInjectorFactory";
public ResteasyIntegrationDeployer()
{
super();
addRequiredInput(JBossWebMetaData.class);
- addRequiredInput(ResteasyDeploymentData.class);
+ addRequiredInput(ResteasyDeploymentScanningData.class);
addOutput(JBossWebMetaData.class);
setStage(DeploymentStages.PRE_REAL); // TODO -- right stage?
}
@@ -39,7 +41,7 @@
}
- protected void setInitParam(FilterMetaData filter, String name, String value)
+ protected void setFilterInitParam(FilterMetaData filter, String name, String value)
{
ParamValueMetaData param = new ParamValueMetaData();
param.setParamName(name);
@@ -54,16 +56,27 @@
}
+ public static void setContextParameter(JBossWebMetaData webdata, String name, String value)
+ {
+ ParamValueMetaData param = new ParamValueMetaData();
+ param.setParamName(name);
+ param.setParamValue(value);
+ List<ParamValueMetaData> params = webdata.getContextParams();
+ if (params == null)
+ {
+ params = new ArrayList<ParamValueMetaData>();
+ webdata.setContextParams(params);
+ }
+ params.add(param);
+
+ }
+
protected void internalDeploy(DeploymentUnit du) throws DeploymentException
{
JBossWebMetaData webdata = du.getAttachment(JBossWebMetaData.class);
- ResteasyDeploymentData resteasy = du.getAttachment(ResteasyDeploymentData.class);
+ ResteasyDeploymentScanningData resteasy = du.getAttachment(ResteasyDeploymentScanningData.class);
if (!resteasy.shouldCreateDispatcher()) return;
- FilterMetaData filter = new FilterMetaData();
- filter.setFilterClass(FilterDispatcher.class.getName());
- filter.setName("Resteasy");
-
if (!resteasy.getResources().isEmpty())
{
StringBuffer buf = null;
@@ -78,10 +91,9 @@
{
buf.append(",").append(resource);
}
- log.info("******** Adding RESOURCE CLASS: " + resource);
}
String resources = buf.toString();
- setInitParam(filter, ResteasyContextParameters.RESTEASY_RESOURCES, resources);
+ setContextParameter(webdata, ResteasyContextParameters.RESTEASY_RESOURCES, resources);
}
if (!resteasy.getProviders().isEmpty())
{
@@ -98,8 +110,28 @@
buf.append(",").append(provider);
}
}
- setInitParam(filter, ResteasyContextParameters.RESTEASY_PROVIDERS, buf.toString());
+ setContextParameter(webdata, ResteasyContextParameters.RESTEASY_PROVIDERS, buf.toString());
}
+
+ try
+ {
+ Thread.currentThread().getContextClassLoader().loadClass(CDI_INJECTOR_FACTORY_CLASS);
+ // don't set this param if CDI is not in classpath
+ if (((VFSDeploymentUnit)du).getMetaDataFile("beans.xml") != null)
+ {
+ setContextParameter(webdata, "resteasy.injector.factory", CDI_INJECTOR_FACTORY_CLASS);
+ }
+ }
+ catch (ClassNotFoundException ignored)
+ {
+ }
+
+ if (resteasy.hasBootClasses()) return;
+
+ FilterMetaData filter = new FilterMetaData();
+ filter.setFilterClass(FilterDispatcher.class.getName());
+ filter.setName("Resteasy");
+
FilterMappingMetaData mapping = new FilterMappingMetaData();
mapping.setFilterName("Resteasy");
List<String> patterns = new ArrayList<String>();
Modified: trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyScannerDeployer.java
===================================================================
--- trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyScannerDeployer.java 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/jar/src/main/java/org/jboss/resteasy/integration/deployers/ResteasyScannerDeployer.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -4,6 +4,7 @@
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
@@ -15,6 +16,7 @@
import org.jboss.scanning.annotations.spi.AnnotationIndex;
import org.jboss.scanning.annotations.spi.AnnotationRepository;
import org.jboss.scanning.annotations.spi.Element;
+import org.jboss.scanning.hierarchy.spi.HierarchyIndex;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;
@@ -25,6 +27,8 @@
import java.util.Set;
/**
+ * Use cases:
+ *
* @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
@@ -48,7 +52,7 @@
addRequiredInput(JBossWebMetaData.class);
addInput(AnnotationRepository.class);
addOutput(JBossWebMetaData.class);
- addOutput(ResteasyDeploymentData.class);
+ addOutput(ResteasyDeploymentScanningData.class);
setStage(DeploymentStages.PRE_REAL); // TODO -- right stage?
}
@@ -72,7 +76,7 @@
* @return
* @throws DeploymentException
*/
- protected boolean scannable(DeploymentUnit du, JBossWebMetaData webdata) throws DeploymentException
+ protected boolean hasBootClasses(DeploymentUnit du, JBossWebMetaData webdata) throws DeploymentException
{
ClassLoader loader = du.getClassLoader();
if (webdata.getServlets() != null)
@@ -80,17 +84,17 @@
for (ServletMetaData servlet : webdata.getServlets())
{
String servletClass = servlet.getServletClass();
- if (BOOT_CLASSES.contains(servletClass)) return false;
+ if (BOOT_CLASSES.contains(servletClass)) return true;
}
}
if (webdata.getFilters() != null)
{
for (FilterMetaData filter : webdata.getFilters())
{
- if (BOOT_CLASSES.contains(filter.getFilterClass())) return false;
+ if (BOOT_CLASSES.contains(filter.getFilterClass())) return true;
}
}
- return true;
+ return false;
}
@@ -125,6 +129,18 @@
servlet.setInitParam(params);
}
params.add(param);
+ try
+ {
+ Thread.currentThread().getContextClassLoader().loadClass(ResteasyIntegrationDeployer.CDI_INJECTOR_FACTORY_CLASS);
+ // don't set this param if it is not in classpath
+ if (((VFSDeploymentUnit)du).getMetaDataFile("beans.xml") != null)
+ {
+ ResteasyIntegrationDeployer.setContextParameter(webdata, "resteasy.injector.factory", ResteasyIntegrationDeployer.CDI_INJECTOR_FACTORY_CLASS);
+ }
+ }
+ catch (ClassNotFoundException ignored)
+ {
+ }
return true;
}
}
@@ -135,10 +151,13 @@
protected void scan(DeploymentUnit du, JBossWebMetaData webdata)
throws DeploymentException
{
- ResteasyDeploymentData scanningData = new ResteasyDeploymentData();
+ ResteasyDeploymentScanningData scanningData = new ResteasyDeploymentScanningData();
// If there is a resteasy boot class in web.xml, then the default should not be to scan
- if (scannable(du, webdata) && !webdata.isMetadataComplete())
+ boolean hasBoot = hasBootClasses(du, webdata);
+ scanningData.setBootClasses(hasBoot);
+
+ if (hasBoot == false && !webdata.isMetadataComplete())
{
scanningData.setScanAll(true);
scanningData.setScanProviders(true);
@@ -152,6 +171,7 @@
boolean hasResourceParam = false;
boolean hasProviderParam = false;
boolean hasJndiParam = false;
+
if (contextParams != null)
{
for (ParamValueMetaData param : contextParams)
@@ -183,19 +203,34 @@
}
}
+ if (hasResourceParam)
+ {
+ scanningData.setScanAll(false);
+ scanningData.setScanResources(false);
+ }
+
+ if (hasProviderParam)
+ {
+ scanningData.setScanAll(false);
+ scanningData.setScanProviders(false);
+ }
+
if (!scanningData.shouldScan())
{
if (hasResourceParam || hasProviderParam || hasJndiParam)
{
- scanningData.createDispatcher();
- du.addAttachment(ResteasyDeploymentData.class, scanningData);
+ if (hasBoot == false)
+ {
+ scanningData.createDispatcher();
+ du.addAttachment(ResteasyDeploymentScanningData.class, scanningData);
+ }
}
return;
}
- du.addAttachment(ResteasyDeploymentData.class, scanningData);
+ du.addAttachment(ResteasyDeploymentScanningData.class, scanningData);
- AnnotationRepository env = du.getAttachment(AnnotationIndex.class);
+ AnnotationIndex env = du.getAttachment(AnnotationIndex.class);
if (env == null)
{
LOGGER.debug("Expecting AnnotationRepository class for scanning WAR for JAX-RS classes");
@@ -219,7 +254,10 @@
{
for (Element e : resources)
{
- if (e.getOwner().isInterface()) continue;
+ if (e.getOwner().isInterface())
+ {
+ continue;
+ }
scanningData.getResources().add(e.getOwnerClassName());
}
}
@@ -231,6 +269,9 @@
scanningData.getProviders().add(e.getOwnerClassName());
}
}
+
+ Set<String> strings = env.classesImplementingInterfacesAnnotatedWith(Path.class.getName());
+ scanningData.getResources().addAll(strings);
}
}
Added: trunk/resteasy-int/test/cdi-test-2/pom.xml
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/pom.xml (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/pom.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,145 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs-all</artifactId>
+ <version>2.0-beta-3</version>
+ </parent>
+
+ <artifactId>resteasy-cdi-test</artifactId>
+ <packaging>war</packaging>
+ <name>RESTEasy-CDI testing application</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.0-SP1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ejb</groupId>
+ <artifactId>ejb-api</artifactId>
+ <version>3.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>jaxrs-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Test libraries -->
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>resteasy-cdi</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-maven-plugin</artifactId>
+ <version>1.3.1</version>
+ <configuration>
+ <jbossHome>${jboss.home}</jbossHome>
+ </configuration>
+ <executions>
+ <execution>
+ <id>jboss-deploy</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>deploy</goal>
+ </goals>
+ <configuration>
+ <fileNames>
+ <fileName>${basedir}/target/${build.finalName}.war</fileName>
+ </fileNames>
+ </configuration>
+ </execution>
+ <execution>
+ <id>jboss-undeploy</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>undeploy</goal>
+ </goals>
+ <configuration>
+ <fileNames>
+ <fileName>${basedir}/target/${build.finalName}.war</fileName>
+ </fileNames>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/Cat.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/Cat.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/Cat.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,11 @@
+package org.jboss.resteasy.cdi.test;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+
+ at SessionScoped
+public class Cat implements Serializable
+{
+ private static final long serialVersionUID = 5875753813720411262L;
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/Dog.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/Dog.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/Dog.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,6 @@
+package org.jboss.resteasy.cdi.test;
+
+public class Dog
+{
+
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/SubResource.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/SubResource.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/SubResource.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,18 @@
+package org.jboss.resteasy.cdi.test;
+
+import java.io.Serializable;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Produces;
+
+ at Produces("text/plain")
+public class SubResource implements Serializable
+{
+ private static final long serialVersionUID = 8722971164845596111L;
+
+ @GET
+ public String foo()
+ {
+ return "bar";
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/MockResource.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/MockResource.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/MockResource.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,17 @@
+package org.jboss.resteasy.cdi.test.alternative;
+
+import javax.enterprise.inject.Alternative;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+ at Path("/alternative")
+ at Alternative
+public class MockResource extends ProductionResource
+{
+ @Override
+ @GET
+ public String getValue()
+ {
+ return "MockResource";
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/ProductionResource.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/ProductionResource.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/alternative/ProductionResource.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,16 @@
+package org.jboss.resteasy.cdi.test.alternative;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+ at Path("/alternative")
+ at Produces("text/plain")
+public class ProductionResource
+{
+ @GET
+ public String getValue()
+ {
+ return "ProductionResource";
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/ApplicationScopedTestResource.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/ApplicationScopedTestResource.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/ApplicationScopedTestResource.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,113 @@
+package org.jboss.resteasy.cdi.test.basic;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.cdi.test.Cat;
+import org.jboss.resteasy.cdi.test.Dog;
+import org.jboss.resteasy.cdi.test.SubResource;
+
+ at Path("applicationResource")
+ at Produces("text/plain")
+ at ApplicationScoped
+public class ApplicationScopedTestResource extends TestResource
+{
+ @Inject
+ private Cat cat;
+ private Cat constructorCat;
+ private Cat initializerCat;
+ @Context
+ private UriInfo uriInfo;
+ private UriInfo setterUriInfo;
+ @Inject
+ private SubResource subResource;
+
+ public ApplicationScopedTestResource()
+ {
+ }
+
+ @Inject
+ public ApplicationScopedTestResource(Cat cat)
+ {
+ constructorCat = cat;
+ }
+
+ @Inject
+ public void init(Cat cat)
+ {
+ initializerCat = cat;
+ }
+
+ @GET
+ @Path("/fieldInjection")
+ public boolean fieldInjection()
+ {
+ return cat != null;
+ }
+
+ @GET
+ @Path("/jaxrsFieldInjection")
+ public boolean jaxrsFieldInjection()
+ {
+ return uriInfo != null;
+ }
+
+ @GET
+ @Path("/jaxrsSetterInjection")
+ public boolean jaxrsSetterInjection()
+ {
+ return setterUriInfo != null;
+ }
+
+ @GET
+ @Path("/constructorInjection")
+ public boolean constructorInjection()
+ {
+ return constructorCat != null;
+ }
+
+ @GET
+ @Path("/initializerInjection")
+ public boolean initializerInjection()
+ {
+ return initializerCat != null;
+ }
+
+ @GET
+ @Path("/jaxrsMethodInjection")
+ public String jaxrsMethodInjection(@QueryParam("foo") String query)
+ {
+ return query;
+ }
+
+ @GET
+ public String toString()
+ {
+ return super.toString();
+ }
+
+ @GET
+ @Path("/providers")
+ public Dog testProviders()
+ {
+ return new Dog();
+ }
+
+ @Context
+ public void setSetterUriInfo(UriInfo setterUriInfo)
+ {
+ this.setterUriInfo = setterUriInfo;
+ }
+
+ @Path("/subResource")
+ public SubResource subResource()
+ {
+ return subResource;
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/TestProvider.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/TestProvider.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/TestProvider.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,71 @@
+package org.jboss.resteasy.cdi.test.basic;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.inject.Inject;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
+
+import org.jboss.resteasy.cdi.test.Cat;
+import org.jboss.resteasy.cdi.test.Dog;
+
+ at Provider
+ at Produces("text/plain")
+public class TestProvider implements MessageBodyWriter<Dog>
+{
+
+ @Inject
+ private Cat cat;
+ private Cat constructorCat;
+ private Cat initializerCat;
+ @Context
+ private Providers providers;
+
+ public TestProvider()
+ {
+ }
+
+ @Inject
+ public TestProvider(Cat cat)
+ {
+ constructorCat = cat;
+ }
+
+ @Inject
+ public void init(Cat cat)
+ {
+ initializerCat = cat;
+ }
+
+ public long getSize(Dog t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
+ {
+ return -1;
+ }
+
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
+ {
+ return type.isAssignableFrom(Dog.class);
+ }
+
+ public void writeTo(Dog t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException
+ {
+ BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(entityStream));
+ bw.write("CDI field injection: " + (cat != null));
+ bw.write("\nCDI constructor injection: " + (constructorCat != null));
+ bw.write("\nCDI initializer injection: " + (initializerCat != null));
+ bw.write("\nJAX-RS field injection: " + (providers != null));
+ bw.write("\nProvider toString(): " + toString());
+ bw.flush();
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/TestResource.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/TestResource.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/basic/TestResource.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,123 @@
+package org.jboss.resteasy.cdi.test.basic;
+
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.cdi.test.Cat;
+import org.jboss.resteasy.cdi.test.Dog;
+import org.jboss.resteasy.cdi.test.SubResource;
+
+
+ at Path("/resource")
+ at Produces("text/plain")
+public class TestResource
+{
+ @Inject
+ private Cat cat;
+ private Cat constructorCat;
+ private Cat initializerCat;
+ @Context
+ private UriInfo uriInfo;
+ @QueryParam("foo")
+ private String fieldQuery;
+ private UriInfo setterUriInfo;
+ @Inject
+ private SubResource subResource;
+
+ public TestResource()
+ {
+ }
+
+ @Inject
+ public TestResource(Cat cat)
+ {
+ constructorCat = cat;
+ }
+
+ @Inject
+ public void init(Cat cat)
+ {
+ initializerCat = cat;
+ }
+
+ @GET
+ @Path("/fieldInjection")
+ public boolean fieldInjection()
+ {
+ return cat != null;
+ }
+
+ @GET
+ @Path("/jaxrsFieldInjection")
+ public boolean jaxrsFieldInjection()
+ {
+ return uriInfo != null;
+ }
+
+ @GET
+ @Path("/jaxrsFieldInjection2")
+ public String jaxrsFieldInjection2()
+ {
+ return fieldQuery;
+ }
+
+ @GET
+ @Path("/jaxrsSetterInjection")
+ public boolean jaxrsSetterInjection()
+ {
+ return setterUriInfo != null;
+ }
+
+ @GET
+ @Path("/constructorInjection")
+ public boolean constructorInjection()
+ {
+ return constructorCat != null;
+ }
+
+ @GET
+ @Path("/initializerInjection")
+ public boolean initializerInjection()
+ {
+ return initializerCat != null;
+ }
+
+ @GET
+ @Path("/jaxrsMethodInjection")
+ public String jaxrsMethodInjection(@QueryParam("foo") String query)
+ {
+ return query;
+ }
+
+ @GET
+ @Path("/toString")
+ @Override
+ public String toString()
+ {
+ return super.toString();
+ }
+
+ @GET
+ @Path("/providers")
+ public Dog testProviders()
+ {
+ return new Dog();
+ }
+
+ @Context
+ public void setSetterUriInfo(UriInfo setterUriInfo)
+ {
+ this.setterUriInfo = setterUriInfo;
+ }
+
+ @Path("/subResource")
+ public SubResource subResource()
+ {
+ return subResource;
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/InjectedStatelessEjb.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/InjectedStatelessEjb.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/InjectedStatelessEjb.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,12 @@
+package org.jboss.resteasy.cdi.test.ejb;
+
+import javax.ejb.Stateless;
+
+ at Stateless
+public class InjectedStatelessEjb implements InjectedStatelessEjbLocal
+{
+ public boolean foo()
+ {
+ return true;
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/InjectedStatelessEjbLocal.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/InjectedStatelessEjbLocal.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/InjectedStatelessEjbLocal.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,9 @@
+package org.jboss.resteasy.cdi.test.ejb;
+
+import javax.ejb.Local;
+
+ at Local
+public interface InjectedStatelessEjbLocal
+{
+ boolean foo();
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource1.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource1.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource1.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,116 @@
+package org.jboss.resteasy.cdi.test.ejb;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Inject;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.cdi.test.Cat;
+import org.jboss.resteasy.cdi.test.Dog;
+import org.jboss.resteasy.cdi.test.SubResource;
+
+ at Stateful
+public class StatefulSessionBeanResource1 implements StatefulSessionBeanResource1Local
+{
+ private static int uniqueId = 0;
+ private int id = uniqueId++;
+
+ @Inject
+ private Cat cat;
+ @EJB
+ private InjectedStatelessEjbLocal statelessEjb;
+ private Cat constructorCat;
+ private Cat initializerCat;
+ @Context
+ private UriInfo uriInfo;
+ @QueryParam("foo")
+ String fieldQuery;
+ private UriInfo setterUriInfo;
+ @Inject
+ private SubResource subResource;
+
+ public StatefulSessionBeanResource1()
+ {
+ }
+
+ @Inject
+ public StatefulSessionBeanResource1(Cat cat)
+ {
+ constructorCat = cat;
+ }
+
+ @Inject
+ public void init(Cat cat)
+ {
+ initializerCat = cat;
+ }
+
+ public boolean fieldInjection()
+ {
+ return cat != null;
+ }
+
+ public boolean ejbFieldInjection()
+ {
+ return statelessEjb.foo();
+ }
+
+ public boolean jaxrsFieldInjection()
+ {
+ return uriInfo != null;
+ }
+
+ public String jaxrsFieldInjection2()
+ {
+ return fieldQuery;
+ }
+
+ public boolean jaxrsSetterInjection()
+ {
+ return setterUriInfo != null;
+ }
+
+ public boolean constructorInjection()
+ {
+ return constructorCat != null;
+ }
+
+ public boolean initializerInjection()
+ {
+ return initializerCat != null;
+ }
+
+ public String jaxrsMethodInjection(String query)
+ {
+ return query;
+ }
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public Dog testProviders()
+ {
+ return new Dog();
+ }
+
+ @Context
+ public void setSetterUriInfo(UriInfo setterUriInfo)
+ {
+ this.setterUriInfo = setterUriInfo;
+ }
+
+ public SubResource subResource()
+ {
+ return subResource;
+ }
+
+ @Remove
+ public void remove()
+ {
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource1Local.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource1Local.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource1Local.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,64 @@
+package org.jboss.resteasy.cdi.test.ejb;
+
+import javax.ejb.Local;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.cdi.test.Dog;
+import org.jboss.resteasy.cdi.test.SubResource;
+
+ at Local
+ at Path("/statefulEjbResourceWithAnnotationsOnLocalInterface")
+ at Produces("text/plain")
+public interface StatefulSessionBeanResource1Local
+{
+ @GET
+ @Path("/fieldInjection")
+ public boolean fieldInjection();
+
+ @GET
+ @Path("/ejbFieldInjection")
+ public boolean ejbFieldInjection();
+
+ @GET
+ @Path("/jaxrsFieldInjection")
+ public boolean jaxrsFieldInjection();
+
+ @GET
+ @Path("/jaxrsFieldInjection2")
+ public String jaxrsFieldInjection2();
+
+ @GET
+ @Path("/jaxrsSetterInjection")
+ public boolean jaxrsSetterInjection();
+
+ @GET
+ @Path("/constructorInjection")
+ public boolean constructorInjection();
+
+ @GET
+ @Path("/initializerInjection")
+ public boolean initializerInjection();
+
+ @GET
+ @Path("/jaxrsMethodInjection")
+ public String jaxrsMethodInjection(@QueryParam("foo") String query);
+
+ @GET
+ @Path("/toString")
+ public int getId();
+
+ @GET
+ @Path("/providers")
+ public Dog testProviders();
+
+ public void setSetterUriInfo(UriInfo setterUriInfo);
+
+ @Path("/subResource")
+ public SubResource subResource();
+
+ public void remove();
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource2.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource2.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource2.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,142 @@
+package org.jboss.resteasy.cdi.test.ejb;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.cdi.test.Cat;
+import org.jboss.resteasy.cdi.test.Dog;
+import org.jboss.resteasy.cdi.test.SubResource;
+
+ at Stateful
+ at Path("/statefulEjbResourceWithAnnotationsOnBeanClass")
+ at Produces("text/plain")
+public class StatefulSessionBeanResource2 implements StatefulSessionBeanResource2Local
+{
+ private static int uniqueId = 0;
+ private int id = uniqueId++;
+
+ @Inject
+ private Cat cat;
+ @EJB
+ private InjectedStatelessEjbLocal statelessEjb;
+ private Cat constructorCat;
+ private Cat initializerCat;
+ @Context
+ private UriInfo uriInfo;
+ @QueryParam("foo")
+ String fieldQuery;
+ private UriInfo setterUriInfo;
+ @Inject
+ private SubResource subResource;
+
+ public StatefulSessionBeanResource2()
+ {
+ }
+
+ @Inject
+ public StatefulSessionBeanResource2(Cat cat)
+ {
+ constructorCat = cat;
+ }
+
+ @Inject
+ public void init(Cat cat)
+ {
+ initializerCat = cat;
+ }
+
+ @GET
+ @Path("/fieldInjection")
+ public boolean fieldInjection()
+ {
+ return cat != null;
+ }
+
+ @GET
+ @Path("/ejbFieldInjection")
+ public boolean ejbFieldInjection()
+ {
+ return statelessEjb.foo();
+ }
+
+ @GET
+ @Path("/jaxrsFieldInjection")
+ public boolean jaxrsFieldInjection()
+ {
+ return uriInfo != null;
+ }
+
+ @GET
+ @Path("/jaxrsFieldInjection2")
+ public String jaxrsFieldInjection2()
+ {
+ return fieldQuery;
+ }
+
+ @GET
+ @Path("/jaxrsSetterInjection")
+ public boolean jaxrsSetterInjection()
+ {
+ return setterUriInfo != null;
+ }
+
+ @GET
+ @Path("/constructorInjection")
+ public boolean constructorInjection()
+ {
+ return constructorCat != null;
+ }
+
+ @GET
+ @Path("/initializerInjection")
+ public boolean initializerInjection()
+ {
+ return initializerCat != null;
+ }
+
+ @GET
+ @Path("/jaxrsMethodInjection")
+ public String jaxrsMethodInjection(@QueryParam("foo") String query)
+ {
+ return query;
+ }
+
+ @GET
+ @Path("/toString")
+ public int getId()
+ {
+ return id;
+ }
+
+ @GET
+ @Path("/providers")
+ public Dog testProviders()
+ {
+ return new Dog();
+ }
+
+ @Context
+ public void setSetterUriInfo(UriInfo setterUriInfo)
+ {
+ this.setterUriInfo = setterUriInfo;
+ }
+
+ @Path("/subResource")
+ public SubResource subResource()
+ {
+ return subResource;
+ }
+
+ @Remove
+ public void remove()
+ {
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource2Local.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource2Local.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatefulSessionBeanResource2Local.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,27 @@
+package org.jboss.resteasy.cdi.test.ejb;
+
+import javax.ejb.Local;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.cdi.test.Cat;
+import org.jboss.resteasy.cdi.test.Dog;
+import org.jboss.resteasy.cdi.test.SubResource;
+
+ at Local
+public interface StatefulSessionBeanResource2Local
+{
+ void init(Cat cat);
+ boolean fieldInjection();
+ boolean ejbFieldInjection();
+ boolean jaxrsFieldInjection();
+ String jaxrsFieldInjection2();
+ boolean jaxrsSetterInjection();
+ boolean constructorInjection();
+ boolean initializerInjection();
+ String jaxrsMethodInjection(String query);
+ int getId();
+ Dog testProviders();
+ void setSetterUriInfo(UriInfo setterUriInfo);
+ SubResource subResource();
+ void remove();
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatelessSessionBeanResource.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatelessSessionBeanResource.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatelessSessionBeanResource.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,110 @@
+package org.jboss.resteasy.cdi.test.ejb;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.ejb.Stateless;
+import javax.enterprise.context.Dependent;
+import javax.inject.Inject;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.cdi.test.Cat;
+import org.jboss.resteasy.cdi.test.Dog;
+import org.jboss.resteasy.cdi.test.SubResource;
+
+ at Stateless
+ at Dependent
+public class StatelessSessionBeanResource implements StatelessSessionBeanResourceLocal
+{
+ private static int uniqueId = 0;
+ private int id = uniqueId++;
+
+ @Inject
+ private Cat cat;
+ @EJB
+ private InjectedStatelessEjbLocal statelessEjb;
+ private Cat constructorCat;
+ private Cat initializerCat;
+ @Context
+ private UriInfo uriInfo;
+ private UriInfo setterUriInfo;
+ @Inject
+ private SubResource subResource;
+
+ public StatelessSessionBeanResource()
+ {
+ }
+
+ @Inject
+ public StatelessSessionBeanResource(Cat cat)
+ {
+ constructorCat = cat;
+ }
+
+ @Inject
+ public void init(Cat cat)
+ {
+ initializerCat = cat;
+ }
+
+ public boolean fieldInjection()
+ {
+ return cat != null;
+ }
+
+ public boolean ejbFieldInjection()
+ {
+ return statelessEjb.foo();
+ }
+
+ public boolean jaxrsFieldInjection()
+ {
+ return uriInfo != null;
+ }
+
+ public boolean jaxrsSetterInjection()
+ {
+ return setterUriInfo != null;
+ }
+
+ public boolean constructorInjection()
+ {
+ return constructorCat != null;
+ }
+
+ public boolean initializerInjection()
+ {
+ return initializerCat != null;
+ }
+
+ public String jaxrsMethodInjection(String query)
+ {
+ return query;
+ }
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public Dog testProviders()
+ {
+ return new Dog();
+ }
+
+ @Context
+ public void setSetterUriInfo(UriInfo setterUriInfo)
+ {
+ this.setterUriInfo = setterUriInfo;
+ }
+
+ public SubResource subResource()
+ {
+ return subResource;
+ }
+
+ @Remove
+ public void remove()
+ {
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatelessSessionBeanResourceLocal.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatelessSessionBeanResourceLocal.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/ejb/StatelessSessionBeanResourceLocal.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,60 @@
+package org.jboss.resteasy.cdi.test.ejb;
+
+import javax.ejb.Local;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.UriInfo;
+
+import org.jboss.resteasy.cdi.test.Dog;
+import org.jboss.resteasy.cdi.test.SubResource;
+
+ at Local
+ at Path("/statelessEjb")
+ at Produces("text/plain")
+public interface StatelessSessionBeanResourceLocal
+{
+ @GET
+ @Path("/fieldInjection")
+ public boolean fieldInjection();
+
+ @GET
+ @Path("/ejbFieldInjection")
+ public boolean ejbFieldInjection();
+
+ @GET
+ @Path("/jaxrsFieldInjection")
+ public boolean jaxrsFieldInjection();
+
+ @GET
+ @Path("/jaxrsSetterInjection")
+ public boolean jaxrsSetterInjection();
+
+ @GET
+ @Path("/constructorInjection")
+ public boolean constructorInjection();
+
+ @GET
+ @Path("/initializerInjection")
+ public boolean initializerInjection();
+
+ @GET
+ @Path("/jaxrsMethodInjection")
+ public String jaxrsMethodInjection(@QueryParam("foo") String query);
+
+ @GET
+ @Path("/toString")
+ public int getId();
+
+ @GET
+ @Path("/providers")
+ public Dog testProviders();
+
+ public void setSetterUriInfo(UriInfo setterUriInfo);
+
+ @Path("/subResource")
+ public SubResource subResource();
+
+ public void remove();
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestInterceptor.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestInterceptor.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestInterceptor.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,17 @@
+package org.jboss.resteasy.cdi.test.interceptor;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+ at Interceptor
+ at TestInterceptorBinding
+public class TestInterceptor
+{
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception
+ {
+ // Do a negation
+ return !((Boolean) ctx.proceed());
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestInterceptorBinding.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestInterceptorBinding.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestInterceptorBinding.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,19 @@
+package org.jboss.resteasy.cdi.test.interceptor;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+
+import javax.interceptor.InterceptorBinding;
+
+
+ at InterceptorBinding
+ at Target( { TYPE, METHOD } )
+ at Retention(RUNTIME)
+ at Inherited
+public @interface TestInterceptorBinding
+{
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestResource.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestResource.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/java/org/jboss/resteasy/cdi/test/interceptor/TestResource.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,26 @@
+package org.jboss.resteasy.cdi.test.interceptor;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+/**
+ * This test verifies that a JAX-RS resource method invocation
+ * can be intercepted by Interceptor bound using CDI interceptor
+ * binding.
+ *
+ * @author Jozef Hartinger
+ *
+ */
+
+ at Path("/interceptor")
+ at Produces("text/plain")
+ at TestInterceptorBinding
+public class TestResource
+{
+ @GET
+ public boolean getValue()
+ {
+ return false;
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/beans.xml
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/beans.xml (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/beans.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+ <alternatives>
+ <class>org.jboss.resteasy.cdi.test.alternative.MockResource</class>
+ </alternatives>
+ <interceptors>
+ <class>org.jboss.resteasy.cdi.test.interceptor.TestInterceptor</class>
+ </interceptors>
+
+</beans>
Added: trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/main/webapp/WEB-INF/web.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_3_0.xsd"
+ version="3.0">
+ <display-name>RESTEasy-CDI testing application</display-name>
+
+</web-app>
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AbstractResourceTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AbstractResourceTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AbstractResourceTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,51 @@
+package org.jboss.resteasy.cdi.test;
+
+import org.junit.Test;
+
+public abstract class AbstractResourceTest extends AbstractResteasyCdiTest
+{
+ abstract protected String getTestPrefix();
+
+ @Test
+ public void testCdiFieldInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "fieldInjection", true);
+ }
+
+ @Test
+ public void testCdiConstructorInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "constructorInjection", true);
+ }
+
+ @Test
+ public void testCdiInitializerInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "initializerInjection", true);
+ }
+
+ @Test
+ public void testJaxrsFieldInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "jaxrsFieldInjection", true);
+ }
+
+
+ @Test
+ public void testJaxrsSetterInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "jaxrsSetterInjection", true);
+ }
+
+ @Test
+ public void testJaxrsMethodInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "jaxrsMethodInjection?foo=bar", "bar");
+ }
+
+ @Test
+ public void testSubResource()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "subResource", "bar");
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AbstractResteasyCdiTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AbstractResteasyCdiTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AbstractResteasyCdiTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,38 @@
+package org.jboss.resteasy.cdi.test;
+
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public abstract class AbstractResteasyCdiTest
+{
+ private HttpClient client = new HttpClient();
+ public static final String BASE_URI = "http://localhost:8080/resteasy-cdi/";
+
+ public void testPlainTextReadonlyResource(String uri, String body)
+ {
+ GetMethod get = new GetMethod(uri);
+ get.addRequestHeader("Accept", "text/plain");
+ try
+ {
+ int status = client.executeMethod(get);
+ assertEquals(status, 200);
+ assertTrue(get.getResponseBodyAsString().contains(body));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ get.releaseConnection();
+ }
+ }
+
+ public void testPlainTextReadonlyResource(String uri, boolean body)
+ {
+ testPlainTextReadonlyResource(uri, String.valueOf(body));
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AlternativeTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AlternativeTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/AlternativeTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,13 @@
+package org.jboss.resteasy.cdi.test;
+
+import org.junit.Test;
+
+
+public class AlternativeTest extends AbstractResteasyCdiTest
+{
+ @Test
+ public void testAlternative()
+ {
+ testPlainTextReadonlyResource(BASE_URI + "alternative", "MockResource");
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ApplicationScopedResourceTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ApplicationScopedResourceTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ApplicationScopedResourceTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,42 @@
+package org.jboss.resteasy.cdi.test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ApplicationScopedResourceTest extends AbstractResourceTest
+{
+ @Override
+ protected String getTestPrefix()
+ {
+ return "applicationResource/";
+ }
+
+ @Test
+ public void testTheSameInstanceIsUsedForEveryRequest()
+ {
+ HttpClient client = new HttpClient();
+ GetMethod get1 = new GetMethod(BASE_URI + getTestPrefix());
+ get1.addRequestHeader("Accept", "text/plain");
+ GetMethod get2 = new GetMethod(BASE_URI + getTestPrefix());
+ get2.addRequestHeader("Accept", "text/plain");
+ try
+ {
+ int status1 = client.executeMethod(get1);
+ assertEquals(status1, 200);
+ String response1 = get1.getResponseBodyAsString();
+ get1.releaseConnection();
+ int status2 = client.executeMethod(get2);
+ assertEquals(status2, 200);
+ String response2 = get2.getResponseBodyAsString();
+ get2.releaseConnection();
+ assertEquals(response1, response2);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/InterceptorTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/InterceptorTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/InterceptorTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,13 @@
+package org.jboss.resteasy.cdi.test;
+
+import org.junit.Test;
+
+
+public class InterceptorTest extends AbstractResteasyCdiTest
+{
+ @Test
+ public void testInterceptor()
+ {
+ testPlainTextReadonlyResource(BASE_URI + "interceptor", true);
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ProviderTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ProviderTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ProviderTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,31 @@
+package org.jboss.resteasy.cdi.test;
+
+import org.junit.Test;
+
+
+public class ProviderTest extends AbstractResteasyCdiTest
+{
+ @Test
+ public void testCdiFieldInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + "resource/providers", "CDI field injection: true");
+ }
+
+ @Test
+ public void testCdiConstructorInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + "resource/providers", "CDI constructor injection: true");
+ }
+
+ @Test
+ public void testCdiInitializerInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + "resource/providers", "CDI initializer injection: true");
+ }
+
+ @Test
+ public void testJaxrsFieldInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + "resource/providers", "JAX-RS field injection: true");
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ResourceTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ResourceTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/ResourceTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,48 @@
+package org.jboss.resteasy.cdi.test;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+public class ResourceTest extends AbstractResourceTest
+{
+ protected String getTestPrefix()
+ {
+ return "resource/";
+ }
+
+ @Test
+ public void testJaxrsFieldInjection2()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "jaxrsFieldInjection2?foo=bar", "bar");
+ }
+
+ @Test
+ public void testNewInstanceCreatedForEveryRequest()
+ {
+ HttpClient client = new HttpClient();
+ GetMethod get1 = new GetMethod(BASE_URI + getTestPrefix() + "toString");
+ get1.addRequestHeader("Accept", "text/plain");
+ GetMethod get2 = new GetMethod(BASE_URI + getTestPrefix() + "toString");
+ get2.addRequestHeader("Accept", "text/plain");
+ try
+ {
+ int status1 = client.executeMethod(get1);
+ assertEquals(status1, 200);
+ String response1 = get1.getResponseBodyAsString();
+ get1.releaseConnection();
+ int status2 = client.executeMethod(get2);
+ assertEquals(status2, 200);
+ String response2 = get2.getResponseBodyAsString();
+ get2.releaseConnection();
+ assertFalse(response1.equals(response2));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatefulSessionBeanWithAnnotationsOnBeanClassTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatefulSessionBeanWithAnnotationsOnBeanClassTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatefulSessionBeanWithAnnotationsOnBeanClassTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,34 @@
+package org.jboss.resteasy.cdi.test;
+
+import org.junit.Test;
+
+
+public class StatefulSessionBeanWithAnnotationsOnBeanClassTest extends ResourceTest
+{
+
+ @Override
+ protected String getTestPrefix()
+ {
+ return "statefulEjbResourceWithAnnotationsOnBeanClass/";
+ }
+
+ @Test
+ public void testEjbFieldInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "ejbFieldInjection", true);
+ }
+
+ @Override
+ // WELDINT-31 This test is disabled temporarily
+ public void testCdiConstructorInjection()
+ {
+ }
+
+ @Override
+ // This test is disabled temporarily
+ public void testSubResource()
+ {
+ }
+
+
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatefulSessionBeanWithAnnotationsOnLocalInterfaceTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatefulSessionBeanWithAnnotationsOnLocalInterfaceTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatefulSessionBeanWithAnnotationsOnLocalInterfaceTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,17 @@
+package org.jboss.resteasy.cdi.test;
+
+public class StatefulSessionBeanWithAnnotationsOnLocalInterfaceTest extends StatefulSessionBeanWithAnnotationsOnBeanClassTest
+{
+
+ @Override
+ protected String getTestPrefix()
+ {
+ return "statefulEjbResourceWithAnnotationsOnLocalInterface/";
+ }
+
+ @Override
+ // WELDINT-31 This test is disabled temporarily
+ public void testCdiConstructorInjection()
+ {
+ }
+}
Added: trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatelessSessionBeanTest.java
===================================================================
--- trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatelessSessionBeanTest.java (rev 0)
+++ trunk/resteasy-int/test/cdi-test-2/src/test/java/org/jboss/resteasy/cdi/test/StatelessSessionBeanTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -0,0 +1,28 @@
+package org.jboss.resteasy.cdi.test;
+
+import org.junit.Test;
+
+
+public class StatelessSessionBeanTest extends AbstractResourceTest
+{
+
+ @Override
+ protected String getTestPrefix()
+ {
+ return "statelessEjb/";
+ }
+
+ @Test
+ public void testEjbFieldInjection()
+ {
+ testPlainTextReadonlyResource(BASE_URI + getTestPrefix() + "ejbFieldInjection", true);
+ }
+
+ @Override
+ // WELDINT-31 This test is disabled temporarily
+ public void testCdiConstructorInjection()
+ {
+ }
+
+
+}
Modified: trunk/resteasy-int/test/ejb-war/pom.xml
===================================================================
--- trunk/resteasy-int/test/ejb-war/pom.xml 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/test/ejb-war/pom.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -19,9 +19,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.javaee</groupId>
- <artifactId>jboss-ejb-api_3.1</artifactId>
- <scope>provided</scope>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
Modified: trunk/resteasy-int/test/ejb-war/src/main/java/org/jboss/resteasy/test/MyResource.java
===================================================================
--- trunk/resteasy-int/test/ejb-war/src/main/java/org/jboss/resteasy/test/MyResource.java 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/test/ejb-war/src/main/java/org/jboss/resteasy/test/MyResource.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -1,18 +1,23 @@
package org.jboss.resteasy.test;
import javax.ws.rs.GET;
+import javax.ws.rs.Path;
import javax.ws.rs.Produces;
/**
* @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
+ at Path("/scan")
public interface MyResource
{
@GET
@Produces("text/plain")
String get();
+ @GET
+ @Produces("text/plain")
+ @Path("exception")
public String testException();
}
Modified: trunk/resteasy-int/test/pom.xml
===================================================================
--- trunk/resteasy-int/test/pom.xml 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/test/pom.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -16,5 +16,6 @@
<module>application-war</module>
<module>scanned-war</module>
<module>ejb-war</module>
+ <module>cdi-test-2</module>
</modules>
</project>
Modified: trunk/resteasy-int/test/scanned-war/src/test/java/org/jboss/resteasy/test/jboss/ScanningTest.java
===================================================================
--- trunk/resteasy-int/test/scanned-war/src/test/java/org/jboss/resteasy/test/jboss/ScanningTest.java 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/test/scanned-war/src/test/java/org/jboss/resteasy/test/jboss/ScanningTest.java 2010-06-17 18:04:06 UTC (rev 106133)
@@ -28,4 +28,23 @@
String res = request.getTarget(String.class);
Assert.assertEquals(res, "42");
}
+
+
+ @Test
+ public void testItIntf() throws Exception
+ {
+ ClientRequest request = new ClientRequest("http://localhost:8080/scanned-test/scan-intf");
+ ClientResponse<String> response = request.get(String.class);
+ Assert.assertEquals(200, response.getStatus());
+ Assert.assertEquals("hello world", response.getEntity());
+
+ }
+
+ @Test
+ public void testScannedContextResolverIntf() throws Exception
+ {
+ ClientRequest request = new ClientRequest("http://localhost:8080/scanned-test/scan-intf/resolver");
+ String res = request.getTarget(String.class);
+ Assert.assertEquals(res, "42");
+ }
}
Modified: trunk/resteasy-int/zip/assembly.xml
===================================================================
--- trunk/resteasy-int/zip/assembly.xml 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/zip/assembly.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -30,6 +30,7 @@
<include>org.jboss.resteasy:resteasy-multipart-provider</include>
<include>org.jboss.resteasy:resteasy-jackson-provider</include>
<include>org.jboss.resteasy:resteasy-yaml-provider</include>
+ <include>org.jboss.resteasy:resteasy-cdi</include>
</includes>
<outputDirectory>resteasy.deployer</outputDirectory>
</dependencySet>
Modified: trunk/resteasy-int/zip/pom.xml
===================================================================
--- trunk/resteasy-int/zip/pom.xml 2010-06-17 18:03:45 UTC (rev 106132)
+++ trunk/resteasy-int/zip/pom.xml 2010-06-17 18:04:06 UTC (rev 106133)
@@ -109,8 +109,11 @@
<artifactId>resteasy-yaml-provider</artifactId>
<version>${version.org.jboss.resteasy}</version>
</dependency>
-
-
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-cdi</artifactId>
+ <version>${version.org.jboss.resteasy}</version>
+ </dependency>
</dependencies>
<build>
More information about the jboss-cvs-commits
mailing list