[weld-commits] Weld SVN: r7026 - in archetypes/eap51-weld-jsf-webapp/trunk: src and 45 other directories.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Tue Oct 12 15:12:51 EDT 2010
Author: dan.j.allen
Date: 2010-10-12 15:12:50 -0400 (Tue, 12 Oct 2010)
New Revision: 7026
Added:
archetypes/eap51-weld-jsf-webapp/trunk/archetype-excludes.txt
archetypes/eap51-weld-jsf-webapp/trunk/archetype-pom.xml
archetypes/eap51-weld-jsf-webapp/trunk/archetype.properties
archetypes/eap51-weld-jsf-webapp/trunk/create-archetype.sh
archetypes/eap51-weld-jsf-webapp/trunk/pom.xml
archetypes/eap51-weld-jsf-webapp/trunk/readme.txt
archetypes/eap51-weld-jsf-webapp/trunk/src/
archetypes/eap51-weld-jsf-webapp/trunk/src/deploy/
archetypes/eap51-weld-jsf-webapp/trunk/src/deploy/resources/
archetypes/eap51-weld-jsf-webapp/trunk/src/deploy/resources/default-ds.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/main/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/controller/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/controller/MemberRegistration.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/data/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/data/MemberListProducer.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/model/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/model/Member.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/MemberRepository.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/MemberRepositoryProducer.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/Transaction.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionInterceptor.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionInterceptorExtension.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionLiteral.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/UserTransactionProducer.java
archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/persistence.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/services/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/import.sql
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/beans.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/faces-config.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/templates/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/templates/default.xhtml
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/web.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/weld.tld
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/index.jsf
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/index.xhtml
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/css/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/css/screen.css
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/gfx/
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/gfx/banner.png
archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/gfx/weld.png
archetypes/eap51-weld-jsf-webapp/trunk/src/test/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASConfiguration.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASDeploymentAppender.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASRemoteContainer.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ProtocolDeploymentAppender.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/SecurityActions.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletMethodExecutor.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletProtocolDeploymentPackager.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletTestRunner.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/testenricher/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/testenricher/cdi/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/testenricher/cdi/support/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/testenricher/cdi/support/CDIInjectionSupportDeploymentAppender.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/weld/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/weld/environment/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/weld/environment/servlet/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/weld/environment/servlet/BeanManagerResourceBindingListener.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/CDISmokeIntegrationTest.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/PersistenceTxSmokeIntegrationTest.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAtClassLevelTestBean.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAttributeAtClassLevelTestBean.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAttributeAtMethodLevelTestBean.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionInterceptorIntegrationTest.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/Dependencies.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/MavenArtifactResolver.java
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/jndi.properties
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/test-persistence.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/arquillian.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/auxiliary-web.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/test-transaction-interceptor-beans.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/test-web.xml
archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/weld.tld
Modified:
archetypes/eap51-weld-jsf-webapp/trunk/
Log:
initial import
Property changes on: archetypes/eap51-weld-jsf-webapp/trunk
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Added: archetypes/eap51-weld-jsf-webapp/trunk/archetype-excludes.txt
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/archetype-excludes.txt (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/archetype-excludes.txt 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,9 @@
+.classpath
+.git
+.gitignore
+.project
+.settings
+.svn
+archetype-pom.xml
+archetype-excludes.txt
+WORKLOG
Added: archetypes/eap51-weld-jsf-webapp/trunk/archetype-pom.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/archetype-pom.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/archetype-pom.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-parent</artifactId>
+ <version>12</version>
+ </parent>
+
+ <groupId>org.jboss.weld.archetypes</groupId>
+ <artifactId>eap51-weld-jsf-webapp</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+
+ <name>JSF 1.2 and CDI webapp project for JBoss EAP 5.1</name>
+
+ <description>An archetype that generates a starter JSF 1.2 webapp project enhanced with CDI services provided by Weld Servlet</description>
+
+ <url>http://seamframework.org/Documentation/WeldQuickstartForMavenUsers</url>
+
+ <developers>
+ <developer>
+ <name>Dan Allen</name>
+ <roles>
+ <role>Weld EAP archetypes lead</role>
+ </roles>
+ <email>dan.j.allen at gmail.com</email>
+ <organization>JBoss, by Red Hat</organization>
+ <organizationUrl>http://redhat.com/jboss</organizationUrl>
+ <url>http://community.jboss.org/people/dan.j.allen</url>
+ </developer>
+ <developer>
+ <name>Pete Muir</name>
+ <roles>
+ <role>Weld project lead</role>
+ </roles>
+ <email>pete.muir at jboss.org</email>
+ <organization>Red Hat Inc.</organization>
+ <organizationUrl>http://redhat.com/jboss</organizationUrl>
+ <url>http://in.relation.to/Bloggers/Pete</url>
+ </developer>
+ </developers>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.0-alpha-5</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-5</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/archetypes/eap51-weld-jsf-webapp/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/archetypes/eap51-weld-jsf-webapp/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/weld/archetypes/eap51-weld-jsf-webapp/trunk</url>
+ </scm>
+</project>
Added: archetypes/eap51-weld-jsf-webapp/trunk/archetype.properties
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/archetype.properties (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/archetype.properties 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,9 @@
+archetype.groupId=org.jboss.weld.archetypes
+archetype.artifactId=eap51-jsf-weld-webapp
+archetype.version=1.0.0-SNAPSHOT
+# Java package of the source files; will be replaced with the ${package} expression
+archetype.package=applicationPackage
+archetype.languages=java
+# archetype.package is converted to ${package} expression in filtered files
+archetype.filteredExtensions=java,txt,html,xml,tld,AuxiliaryArchiveAppender,DeploymentPackager,ContainerConfiguration,DeployableContainer,Extension
+name=JSF 1.2 and CDI webapp project
Added: archetypes/eap51-weld-jsf-webapp/trunk/create-archetype.sh
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/create-archetype.sh (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/create-archetype.sh 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# This script generates an archetype into target/archetype from the source project.
+#
+# Two optional commands can be provided (in the order listed):
+#
+# install - which will automatically install the generated archetype in the local repository
+# generate - generate a project from the archetype into target/generated-project
+#
+
+ARCHETYPE_BUILD_DIR=target/generated-sources/archetype
+ARCHETYPE_DIR=target/archetype
+ARCHETYPE_RESOURCES_DIR=$ARCHETYPE_DIR/src/main/resources/archetype-resources
+
+echo Generating archetype from project into $ARCHETYPE_BUILD_DIR...
+if [ ! -z `which txt2html` ]; then
+ txt2html -pb 1 -p 2 readme.txt > readme.html
+else
+ echo txt2html cannot be found, skipping generation of readme.html
+fi
+mvn clean archetype:create-from-project -Darchetype.properties=archetype.properties
+echo Relocating generated archetype project to $ARCHETYPE_DIR...
+rsync -az --exclude `basename $0` --exclude-from=archetype-excludes.txt $ARCHETYPE_BUILD_DIR/src $ARCHETYPE_DIR/
+cp -f archetype-pom.xml $ARCHETYPE_DIR/pom.xml
+mvn -f $ARCHETYPE_DIR/pom.xml clean
+echo Patching generated archetype...
+# could also use col -b
+sed -i 's;
+;;' $ARCHETYPE_RESOURCES_DIR/pom.xml
+sed -i 's;
+;;' $ARCHETYPE_RESOURCES_DIR/readme.txt
+sed -i 's;<name>eap51-weld-jsf-webapp-src</name>;<name>${name}</name>;' $ARCHETYPE_RESOURCES_DIR/pom.xml
+# fix the archetype plugin being an idiot
+find $ARCHETYPE_RESOURCES_DIR -type f -exec sed -i 's;packageInPathFormat;package;g' {} \;
+# remove local file that NetBeans add to source project
+rm -f $ARCHETYPE_RESOURCES_DIR/src/main/webapp/WEB-INF/sun-web.xml
+rm -f readme.html
+# could set the release version at this point, if specified
+if [ ! -z $1 ] && [ "$1" = "install" ]; then
+ echo Installing archetype...
+ shift
+ mvn -f $ARCHETYPE_DIR/pom.xml install
+fi
+
+if [ ! -z $1 ] && [ "$1" = "generate" ]; then
+ echo Generating project from archetype...
+ cd target
+ mvn archetype:generate -B -DarchetypeCatalog=local \
+ -DarchetypeArtifactId=eap51-weld-jsf-webapp -DarchetypeGroupId=org.jboss.weld.archetypes -DarchetypeVersion=1.0.1-SNAPSHOT \
+ -DartifactId=generated-project -DgroupId=com.acme -Dversion=1.0.0-SNAPSHOT -Dname="JSF 1.2 and CDI webapp project"
+fi
Property changes on: archetypes/eap51-weld-jsf-webapp/trunk/create-archetype.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: archetypes/eap51-weld-jsf-webapp/trunk/pom.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/pom.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/pom.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,350 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+
+ <groupId>org.jboss.weld.archetypes</groupId>
+ <artifactId>eap51-weld-jsf-webapp-src</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <name>eap51-weld-jsf-webapp-src</name>
+ <description>A starter JSF 1.2 and CDI webapp project that targets JBoss EAP 5.1, generated from the eap51-weld-jsf-webapp archetype</description>
+
+ <properties>
+ <!--
+ Explicitly declaring the source encoding eliminates the following message:
+ [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
+ -->
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <!--
+ Installation location and profile configuration for deployment to JBoss EAP
+ -->
+ <jboss-eap.home>${env.JBOSS_EAP_HOME}</jboss-eap.home>
+ <jboss-eap.conf>default</jboss-eap.conf>
+
+ <!--
+ Version numbers properties defined for easy inspection
+ -->
+ <version.ejb-api>3.0</version.ejb-api>
+ <version.facelets>1.1.15.B1</version.facelets>
+ <version.hibernate-validator>3.1.0.GA</version.hibernate-validator>
+ <version.jboss-as>5.1.0.GA</version.jboss-as>
+ <version.junit>4.8.1</version.junit>
+ <version.weld-api>1.1.Beta1</version.weld-api>
+ <version.weld-servlet>1.1.0.Beta1</version.weld-servlet>
+ <version.weld-extensions>1.0.0.Alpha2</version.weld-extensions>
+ <version.arquillian>1.0.0-SNAPSHOT</version.arquillian>
+ </properties>
+
+ <repositories>
+ <!-- The JBoss public Nexus repository is a composite repository of several major repositories -->
+ <!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users -->
+ <repository>
+ <id>jboss-public-repository</id>
+ <name>JBoss Repository</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>daily</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jboss-public-repository</id>
+ <name>JBoss Repository</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>daily</updatePolicy>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Import scope will provide versions for most Java EE API dependencies -->
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-api-bom</artifactId>
+ <version>${version.weld-api}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ejb</groupId>
+ <artifactId>ejb-api</artifactId>
+ <version>${version.ejb-api}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ <version>${version.facelets}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld.servlet</groupId>
+ <artifactId>weld-servlet</artifactId>
+ <classifier>jboss5</classifier>
+ <version>${version.weld-servlet}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <version>${version.weld-extensions}</version>
+ </dependency>
+
+ <!-- Provides portable (but not standard) bean constraints -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>${version.hibernate-validator}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- BEGIN dependencies for patched container -->
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-spi</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.testenricher</groupId>
+ <artifactId>arquillian-testenricher-ejb</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.testenricher</groupId>
+ <artifactId>arquillian-testenricher-resource</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${version.jboss-as}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <!-- EAP 5.1 uses a profileservice compatible with 6.0.0.M1 -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-profileservice</artifactId>
+ <classifier>client</classifier>
+ <version>6.0.0.M1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- END dependencies for patched container -->
+
+ <!-- BEGIN dependencies for container addons -->
+ <dependency>
+ <groupId>org.jboss.arquillian.testenricher</groupId>
+ <artifactId>arquillian-testenricher-cdi</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- END dependencies for container addons -->
+
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.0-alpha-5</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <!-- Compiler plugin enforces Java 1.5 compatibility -->
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <!-- The archive must be exploded to deploy it to JBoss EAP -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1-beta-1</version>
+ <executions>
+ <execution>
+ <id>default-war</id>
+ <configuration>
+ <warName>${project.build.finalName}-packaged</warName>
+ </configuration>
+ </execution>
+ <execution>
+ <id>explode-archive</id>
+ <phase>package</phase>
+ <goals>
+ <goal>exploded</goal>
+ </goals>
+ <configuration>
+ <webappDirectory>${project.build.directory}/${project.build.finalName}.war</webappDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- Optional JBoss deployer plugin will deploy your war to a local JBoss AS container if you've declared $JBOSS_HOME in your OS -->
+ <!-- To use, set the JBOSS_HOME environment variable (or jboss-eap.home in $HOME/.m2/settings.xml) and run 'mvn package jboss:hard-deploy' -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-maven-plugin</artifactId>
+ <version>1.4.1</version>
+ <configuration>
+ <jbossHome>${jboss-eap.home}/jboss-as</jbossHome>
+ <serverName>${jboss-eap.conf}</serverName>
+ <fileNames>
+ <!-- JNDI DataSource that connects to in-memory HSQLDB to demonstrate JPA -->
+ <fileName>src/deploy/resources/default-ds.xml</fileName>
+ <!-- DataSource needs to go before the application -->
+ <fileName>${project.build.directory}/${project.build.finalName}.war</fileName>
+ </fileNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/*IntegrationTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <!-- An Arquillian testing profile that executes tests in a remote JBoss AS instance -->
+ <!-- Run with 'mvn clean test -Pitest-jbosseap-remote' -->
+ <id>itest-jbosseap-remote</id>
+ <dependencies>
+ <!-- disabled to use patched version of container -->
+ <!--
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-remote-5.1</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>arquillian-protocol-servlet-2.5</artifactId>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ -->
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-jbossas-shared</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-jbossas-remote</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
Added: archetypes/eap51-weld-jsf-webapp/trunk/readme.txt
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/readme.txt (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/readme.txt 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,169 @@
+ eap51-weld-jsf-webapp-src
+ +++++++++++++++++++++++++
+
+ #Source archetype:# eap51-weld-jsf-webapp
+
+ What is it?
+ ===========
+
+ This is your project! It's a barebones, deployable Maven 2 project to help you
+ get your foot in the door developing with CDI, provided by Weld Servlet, on
+ the JBoss EAP 5.1 platform and integration testing the application with
+ Arquillian. This configuration prepares you to eventually migrate to a full
+ Java EE 6 environment to leverage EJB 3.1, JPA 2.0, Bean Validation 1.0 and
+ other platform technologies.
+
+ System requirements
+ ===================
+
+ All you need to run this project is Java 5.0 (Java SDK 1.5) or greator and
+ Maven 2.0.10 or greater. This application is setup to be run on JBoss EAP 5.1,
+ which you'll need to have it installed in order to deploy the application.
+
+ With the prerequisites out of the way, you're ready to build and deploy.
+
+ Deploying the application
+ =========================
+
+ To deploy the application, you first need to produce the archive to deploy using
+ the following Maven goal:
+
+ mvn package
+
+ Now make sure that your JBOSS_EAP_HOME environment variable points to a EAP
+ 5.1 installation. Alternatively, you can set the Maven property jboss-eap.home
+ directly using the following profile definition in the .m2/settings.xml file,
+ found in your home directory:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <settings
+ 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/xsd/settings-1.0.0.xsd">
+
+ <profiles>
+ <profile>
+ <id>environment</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <jboss-eap.home>/path/to/jboss-eap-5.1</jboss-eap.home>
+ </properties>
+ </profile>
+ </profiles>
+
+ </settings>
+
+ Once you've set either the JBOSS_EAP_HOME environment variable or the
+ jboss-eap.home Maven property, you can deploy to JBoss EAP by executing the
+ following command:
+
+ mvn package jboss:hard-deploy
+
+ This will deploy the artifact target/eap51-weld-jsf-webapp-src.war to the
+ jboss-as/server/default/deploy directory of your EAP 5.1 distribution.
+
+ Running the Arquillian tests
+ ============================
+
+ By default, integration tests are configured to be skipped. You enable the
+ integration test by activating the Maven integration testing profile.
+
+ To run the test on JBoss EAP 5.1, first start the instance. Then, run the test
+ goal with the following profile activated:
+
+ mvn clean test -Pitest-jbosseap-remote
+
+ Consult the Arquillian reference documentation to learn how to configure the
+ container.
+
+ - http://docs.jboss.org/arquillian/reference/latest/en-US/html/containers.html#d0e678
+
+ Importing the project into an IDE
+ =================================
+
+ If you created the project using the Maven 2 archetype wizard in your IDE
+ (Eclipse, NetBeans or IntelliJ IDEA), then there is nothing to do. You should
+ already have an IDE project.
+
+ If you created the project from the commandline using archetype:generate, then
+ you need to import the project into your IDE. If you are using NetBeans 6.8 or
+ IntelliJ IDEA 9, then all you have to do is open the project as an existing
+ project. Both of these IDEs recognize Maven 2 projects natively.
+
+ To import the project into Eclipse, you need the m2eclipse plugins installed.
+ Installation instructions are provided on the m2eclipse project site:
+
+ - http://m2eclipse.sonatype.org/installing-m2eclipse.html
+
+ Here's the quick guide:
+
+ - Select Help > Install New Software...
+ - Click the Add... button
+ - Add the repository URL http://m2eclipse.sonatype.org/update
+ - Select and install the Maven Integration for Eclipse
+ - Restart as suggested
+ - Repeat the first two steps
+ - Add the repository URL http://m2eclipse.sonatype.org/sites/m2e-extras
+ - Select and install the Maven Integration for WTP (Optional)
+ - Restart as suggested
+
+ Once the m2eclipse plugins are installed, you'll be ready to import the
+ project into Eclipse and run the project on a Java EE server. We also
+ recommend that you install the JBoss Tools plugins if you plan to deploy
+ to JBoss AS - http://jboss.org/tools
+
+ NOTE:
+ If you are using Eclipse as your IDE, we we strongly recommend that you use
+ Eclipse 3.6 (Helios) - http://www.eclipse.org/helios
+
+ Select File > Import. . . and choose the Maven > Existing Maven Projects option.
+ Navigate to the root directory of your project. Eclipse should recognize the
+ Maven project and preselect it in the Project box. Click Finish and m2eclipse
+ will take it from there.
+
+ NOTE:
+ You cannot use the import option General > Existing Projects into Workspace
+ because Eclipse does not recognize Maven projects as Eclipse projects
+ natively. You must use the importer provided by m2eclipse as just described.
+
+ Once the project is imported into the IDE, you can execute the Maven commands
+ through the IDE controls to deploy the application to a container.
+
+ To run the Arquillian tests from the IDE, you need to activate the integration
+ test profile. Right click on the project in the Package Explorer and select
+ Properties. Select the Maven configuration tab and enter the following value
+ into the Active Maven Profiles field:
+
+ itest-jbosseap-remote
+
+ Press the OK button and accept the prompt that appears to update the project
+ configuration. After changing the activate Maven profiles, you need to clean
+ the project. Select Project > Clean from the main menu, ensure that only the
+ current project is selected, then click OK to execute a clean build.
+
+ Now you can execute the Arquillian tests using Run As > JUnit Test.
+
+ Downloading the sources and Javadocs
+ ====================================
+
+ If you want to be able to debug into the source code or look at the Javadocs
+ of any library in the project, you can run either of the following two
+ commands to pull them into your local repository. The IDE should then detect
+ them.
+
+ mvn dependency:sources
+ mvn dependency:resolve -Dclassifier=javadoc
+
+ Resources
+ =========
+
+ - Weld archetypes
+ - Quickstart: http://seamframework.org/Documentation/WeldQuickstartForMavenUsers
+ - Issue tracker: https://jira.jboss.org/jira/browse/WELDRAD
+ - Source code: http://anonsvn.jboss.org/repos/weld/archetypes
+ - Forums: http://seamframework.org/Community/WeldUsers
+ - JSR-299 overview: http://seamframework.org/Weld
+ - JSF community site: http://www.javaserverfaces.org
+
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/deploy/resources/default-ds.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/deploy/resources/default-ds.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/deploy/resources/default-ds.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE datasources PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>jdbc/__default</jndi-name>
+ <use-java-context>false</use-java-context>
+ <connection-url>jdbc:hsqldb:.</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ </local-tx-datasource>
+</datasources>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/controller/MemberRegistration.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/controller/MemberRegistration.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/controller/MemberRegistration.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,101 @@
+package applicationPackage.controller;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.TransactionAttribute;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Model;
+import javax.enterprise.inject.Produces;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.transaction.UserTransaction;
+
+import org.hibernate.validator.InvalidStateException;
+import org.hibernate.validator.InvalidValue;
+import org.slf4j.Logger;
+
+import applicationPackage.model.Member;
+import applicationPackage.persistence.MemberRepository;
+
+// The @Model stereotype is a convenience mechanism to make this a request-scoped bean that has an EL name
+// Read more about the @Model stereotype in this FAQ: http://seamframework.org/Documentation/WhatIsThePurposeOfTheModelAnnotation
+ at Model
+public class MemberRegistration
+{
+ @Inject
+ private Logger log;
+
+ @Inject
+ @MemberRepository
+ private EntityManager em;
+
+ @Inject
+ private UserTransaction tx;
+
+ @Inject
+ private Event<Member> memberEventSrc;
+
+ private Member newMember;
+
+ private boolean registered;
+
+ public boolean isRegistered()
+ {
+ return registered;
+ }
+
+ @TransactionAttribute
+ public void register() throws Exception
+ {
+ log.info("Registering " + newMember.getName());
+ // join the encompassing JTA transaction
+ em.joinTransaction();
+ try
+ {
+ em.persist(newMember);
+ }
+ catch (InvalidStateException ie)
+ {
+ InvalidValue[] violations = ie.getInvalidValues();
+ if (violations != null && violations.length > 0)
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ for (InvalidValue violation : violations)
+ {
+ ctx.addMessage(findMatchingClientId(ctx, violation), new FacesMessage(violation.getMessage()));
+ }
+ }
+ tx.setRollbackOnly();
+ return;
+ }
+ registered = true;
+ memberEventSrc.fire(newMember);
+ initNewMember();
+ }
+
+ private String findMatchingClientId(FacesContext ctx, InvalidValue v)
+ {
+ UIComponent c = ctx.getViewRoot().findComponent("reg:" + v.getPropertyName());
+ if (c != null)
+ {
+ return c.getClientId(ctx);
+ }
+ return null;
+ }
+
+ @Produces
+ @Named
+ public Member getNewMember()
+ {
+ return newMember;
+ }
+
+ @PostConstruct
+ public void initNewMember()
+ {
+ newMember = new Member();
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/data/MemberListProducer.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/data/MemberListProducer.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/data/MemberListProducer.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,46 @@
+package applicationPackage.data;
+
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.Reception;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+
+import applicationPackage.model.Member;
+import applicationPackage.persistence.MemberRepository;
+
+ at RequestScoped
+public class MemberListProducer
+{
+ @Inject
+ @MemberRepository
+ private EntityManager em;
+
+ private List<Member> members;
+
+ // The @Named annotation allows us to access the return value via the EL variable name "member" in the UI (e.g., Facelets or JSP view)
+ @Produces
+ @Named
+ public List<Member> getMembers()
+ {
+ return members;
+ }
+
+ public void onMemberListChanged(@Observes(receive = Reception.IF_EXISTS) final Member member)
+ //public void onMemberListChanged(@Observes(notifyObserver = Reception.IF_EXISTS) final Member member)
+ {
+ retrieveAllMembersOrderedByName();
+ }
+
+ @PostConstruct
+ @SuppressWarnings("unchecked")
+ public void retrieveAllMembersOrderedByName()
+ {
+ members = em.createQuery("select m from Member m order by m.name asc").getResultList();
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/model/Member.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/model/Member.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/model/Member.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,82 @@
+package applicationPackage.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import org.hibernate.validator.Digits;
+import org.hibernate.validator.Email;
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotEmpty;
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Pattern;
+
+ at Entity
+ at Table(name = "MEMBER", uniqueConstraints = @UniqueConstraint(columnNames = "email"))
+public class Member implements Serializable
+{
+ private Long id;
+ private String name;
+ private String email;
+ private String phoneNumber;
+
+ @Id
+ @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @NotNull
+ @Length(min = 1, max = 25)
+ @Pattern(regex = "[A-Za-z ]*", message = "must contain only letters and spaces")
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @NotNull
+ @NotEmpty
+ @Email
+ public String getEmail()
+ {
+ return email;
+ }
+
+ public void setEmail(String email)
+ {
+ this.email = email;
+ }
+
+ @NotNull
+ @Length(min = 10, max = 12)
+ @Digits(fractionalDigits = 0, integerDigits = 12)
+ @Column(name = "phone_number")
+ public String getPhoneNumber()
+ {
+ return phoneNumber;
+ }
+
+ public void setPhoneNumber(String phoneNumber)
+ {
+ this.phoneNumber = phoneNumber;
+ }
+
+ /** Default value included to remove warning. Remove or modify at will. */
+ private static final long serialVersionUID = 1L;
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/MemberRepository.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/MemberRepository.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/MemberRepository.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,21 @@
+package applicationPackage.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * A qualifier used to differentiate between multiple data repositories.
+ *
+ * If you only have 1 EntityManager, this annotation is optional
+ */
+ at Qualifier
+ at Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface MemberRepository
+{
+ /* class body intentionally left blank */
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/MemberRepositoryProducer.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/MemberRepositoryProducer.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/persistence/MemberRepositoryProducer.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,37 @@
+package applicationPackage.persistence;
+
+import javax.annotation.Resource;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+/**
+ * This class uses CDI to produce EntityManager instances qualified that are
+ * qualified as @MemberRepository.
+ *
+ * <p>
+ * Example injection on a request- or conversation-scoped managed bean field:
+ * </p>
+ *
+ * <pre>
+ * @Inject
+ * @MemberRepository
+ * private EntityManager memberRepository;
+ * </pre>
+ */
+ at RequestScoped
+public class MemberRepositoryProducer
+{
+ private static final String UNIT_NAME = "primary";
+
+ @Resource(mappedName = "java:/" + UNIT_NAME + "EntityManagerFactory")
+ private EntityManagerFactory emf;
+
+ @Produces
+ @MemberRepository
+ public EntityManager getEntityManager()
+ {
+ return emf.createEntityManager();
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/Transaction.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/Transaction.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/Transaction.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.transaction;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.ejb.TransactionAttributeType;
+import javax.enterprise.util.Nonbinding;
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * An alias of @TransactionAttribute that serves as an interceptor binding
+ * for the custom transaction interceptor in this package.
+ *
+ * @author Dan Allen
+ */
+ at InterceptorBinding
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE, ElementType.METHOD})
+public @interface Transaction
+{
+ @Nonbinding
+ TransactionAttributeType value() default TransactionAttributeType.REQUIRED;
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionInterceptor.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionInterceptor.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionInterceptor.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,264 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.transaction;
+
+import java.io.Serializable;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ejb.ApplicationException;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements transaction propagation rules for managed beans.
+ *
+ * TODO need to support meta-annotations (from stereotypes)
+ *
+ * @author Dan Allen
+ */
+ at Transaction
+ at Interceptor
+public class TransactionInterceptor implements Serializable
+{
+ private static final long serialVersionUID = -4364732984298738982L;
+
+ private static final Logger log = LoggerFactory.getLogger(TransactionInterceptor.class);
+
+ private transient Map<AnnotatedElement, TransactionMetadata> transactionMetadata = new HashMap<AnnotatedElement, TransactionMetadata>();
+
+ @Inject
+ private Instance<UserTransaction> txInstance;
+
+ @AroundInvoke
+ public Object aroundInvoke(final InvocationContext invocation) throws Exception
+ {
+ UserTransaction tx = txInstance.get();
+ int status = tx.getStatus();
+ boolean transactionActive = (status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK);
+ TransactionMetadata metadata = lookupTransactionMetadata(invocation.getMethod(), invocation.getTarget().getClass());
+ // interceptor was applied to method it shouldn't have been
+ if (!metadata.isAnnotationPresent())
+ {
+ throw new IllegalStateException("Transaction interceptor incorrectly applied to managed bean with no transaction metadata");
+ // log.warn("Interceptor is not applicable for method");
+ // return invocation.proceed();
+ }
+
+ boolean initiate = metadata.shouldInitiateTransaction(transactionActive);
+
+ if (initiate)
+ {
+ log.debug("Starting transaction");
+ tx.begin();
+ }
+
+ try
+ {
+ Object result = invocation.proceed();
+
+ if (initiate)
+ {
+ if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK)
+ {
+ log.debug("Rolling back transaction marked for rollback");
+ tx.rollback();
+ }
+ else
+ {
+ log.debug("Committing transaction");
+ tx.commit();
+ }
+ }
+
+ return result;
+ }
+ catch (Exception e)
+ {
+ if (tx.getStatus() != Status.STATUS_NO_TRANSACTION)
+ {
+ if (initiate)
+ {
+ if (exceptionCausesRollback(e))
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Rolling back transaction as the result of thrown exception: " + e.getClass());
+ }
+ tx.rollback();
+ }
+ else
+ {
+ log.debug("committing transaction after thrown exception that disables rollback: " + e.getClass());
+ tx.commit();
+ }
+ }
+ else
+ {
+ if (exceptionCausesRollback(e))
+ {
+ log.debug("Marking transaction for rollback only as the result of thrown exception: " + e.getClass());
+ tx.setRollbackOnly();
+ }
+ }
+ }
+ throw e;
+ }
+ }
+
+ protected TransactionMetadata lookupTransactionMetadata(Method method, Class<?> beanClass)
+ {
+ TransactionMetadata metadata = lookupTransactionMetadata(method);
+ if (metadata.isAnnotationPresent())
+ {
+ return metadata;
+ }
+ else
+ {
+ return lookupTransactionMetadata(beanClass);
+ }
+ }
+
+ protected TransactionMetadata lookupTransactionMetadata(AnnotatedElement element)
+ {
+ if (transactionMetadata == null)
+ {
+ transactionMetadata = new HashMap<AnnotatedElement, TransactionMetadata>();
+ }
+
+ TransactionMetadata metadata = transactionMetadata.get(element);
+
+ if (metadata == null)
+ {
+ metadata = loadTransactionMetadata(element);
+ }
+
+ return metadata;
+ }
+
+ protected synchronized TransactionMetadata loadTransactionMetadata(AnnotatedElement element)
+ {
+ if (!transactionMetadata.containsKey(element))
+ {
+ TransactionMetadata metadata = new TransactionMetadata(element);
+ transactionMetadata.put(element, metadata);
+ return metadata;
+ }
+
+ return transactionMetadata.get(element);
+ }
+
+ protected boolean exceptionCausesRollback(Exception e)
+ {
+ boolean rollback = false;
+ if (e instanceof RuntimeException)
+ {
+ rollback = true;
+ }
+ Class<?> exceptionClass = e.getClass();
+ if (exceptionClass.isAnnotationPresent(ApplicationException.class))
+ {
+ return exceptionClass.getAnnotation(ApplicationException.class).rollback();
+ }
+
+ return rollback;
+ }
+
+ public static class TransactionMetadata
+ {
+ private TransactionAttributeType propagation;
+
+ public TransactionMetadata(AnnotatedElement element)
+ {
+ if (element.isAnnotationPresent(TransactionAttribute.class))
+ {
+ propagation = element.getAnnotation(TransactionAttribute.class).value();
+ }
+ else if (element.isAnnotationPresent(Transaction.class))
+ {
+ propagation = element.getAnnotation(Transaction.class).value();
+ }
+
+ validatePropagation(element);
+ }
+
+ public boolean isAnnotationPresent()
+ {
+ return propagation != null;
+ }
+
+ public boolean shouldInitiateTransaction(boolean transactionActive)
+ {
+ if (propagation == null)
+ {
+ throw new IllegalStateException("No propagation type specified");
+ }
+ else if (propagation == TransactionAttributeType.REQUIRED)
+ {
+ return !transactionActive;
+ }
+ else if (propagation == TransactionAttributeType.SUPPORTS)
+ {
+ return false;
+ }
+ else if (propagation == TransactionAttributeType.MANDATORY)
+ {
+ if (!transactionActive)
+ {
+ throw new IllegalStateException("No transaction active when invoking method annotated @TransactionAttribute(MANDATORY)");
+ }
+ return false;
+ }
+ else if (propagation == TransactionAttributeType.NEVER)
+ {
+ if (transactionActive)
+ {
+ throw new IllegalStateException("Transaction active when invoking method annotated @TransactionAttribute(NEVER)");
+ }
+ return false;
+ }
+ throw new IllegalStateException("Cannot handle propagation type " + propagation);
+ }
+
+ private void validatePropagation(AnnotatedElement e)
+ {
+ if (propagation != null)
+ {
+ if (propagation == TransactionAttributeType.REQUIRES_NEW)
+ {
+ throw new RuntimeException("@TransactionAttribute(REQUIRED_NEW) is not allowed on non-EJB managed beans, but was found on " + e);
+ }
+ else if (propagation == TransactionAttributeType.NOT_SUPPORTED)
+ {
+ throw new RuntimeException("@TransactionAttribute(NOT_SUPPORTED) is not allowed on non-EJB managed beans, but was found on " + e);
+ }
+ }
+ }
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionInterceptorExtension.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionInterceptorExtension.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionInterceptorExtension.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,337 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.transaction;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.MessageDriven;
+import javax.ejb.Stateful;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+/**
+ * Extension that allows the user to register a transaction interceptor on a
+ * managed bean using the @TransactionAttribute annotation from the JTA
+ * API.
+ *
+ * @author Dan Allen
+ */
+public class TransactionInterceptorExtension implements Extension
+{
+ /**
+ * Looks for @TransactionAttribute annotations and if they
+ * are found adds the transaction intercepter binding
+ */
+ public <X> void processAnnotatedType(@Observes ProcessAnnotatedType<X> event)
+ {
+ AnnotatedType<X> type = event.getAnnotatedType();
+ Class<? super X> declaringType = null;
+ AnnotatedTypeTransformer<? super X, X> transformer = null;
+
+ if (type.isAnnotationPresent(TransactionAttribute.class) && !isEjb(type))
+ {
+ if (type.isAnnotationPresent(Transaction.class))
+ {
+ throw new RuntimeException("@Transaction and @TransactionAttribute not allowed on the same type: " + type);
+ }
+ TransactionAttribute annotation = type.getAnnotation(TransactionAttribute.class);
+ validateTransactionAttributeIsSupported(annotation, type);
+ transformer = AnnotatedTypeTransformer.createFrom(type, declaringType)
+ .addAnnotation(TransactionLiteral.from(annotation));
+ }
+
+ for (AnnotatedMethod<? super X> m : type.getMethods())
+ {
+ if (m.isAnnotationPresent(TransactionAttribute.class) && !isEjb(type))
+ {
+ if (type.isAnnotationPresent(Transaction.class))
+ {
+ throw new RuntimeException("@Transaction and @TransactionAttribute not allowed on the same method: " + m);
+ }
+ TransactionAttribute annotation = m.getAnnotation(TransactionAttribute.class);
+ validateTransactionAttributeIsSupported(annotation, type);
+ if (transformer == null)
+ {
+ transformer = AnnotatedTypeTransformer.createFrom(type, declaringType);
+ }
+
+ transformer.addAnnotationToMethod(m, TransactionLiteral.from(annotation));
+ }
+ }
+
+ if (transformer != null)
+ {
+ // repair Weld Extensions having included methods from Object
+ transformer.pruneMethodsFromType(Object.class);
+ event.setAnnotatedType(transformer.transform());
+ }
+ }
+
+ protected <X> boolean isEjb(AnnotatedType<X> type)
+ {
+ // TODO also check for Singleton.class
+ return type.isAnnotationPresent(Stateful.class) ||
+ type.isAnnotationPresent(Stateless.class) ||
+ type.isAnnotationPresent(MessageDriven.class);
+ }
+
+ protected <X> void validateTransactionAttributeIsSupported(TransactionAttribute annotation, Annotated e)
+ {
+ TransactionAttributeType propagation = annotation.value();
+ if (propagation == TransactionAttributeType.REQUIRES_NEW)
+ {
+ throw new RuntimeException("@TransactionAttribute(REQUIRED_NEW) is not allowed on non-EJB managed beans, but was found on " + e);
+ }
+ else if (propagation == TransactionAttributeType.NOT_SUPPORTED)
+ {
+ throw new RuntimeException("@TransactionAttribute(NOT_SUPPORTED) is not allowed on non-EJB managed beans, but was found on " + e);
+ }
+ }
+
+ private static abstract class AnnotatedElementDecorator<S, X> implements Annotated
+ {
+ private final Set<Annotation> annotations;
+ private final Map<Class<? extends Annotation>, Annotation> annotationsByType;
+
+ public AnnotatedElementDecorator(Collection<Annotation> annotations)
+ {
+ this.annotations = new HashSet<Annotation>(annotations);
+ annotationsByType =
+ new HashMap<Class<? extends Annotation>, Annotation>(annotations.size());
+ for (Annotation a : this.annotations)
+ {
+ annotationsByType.put(a.annotationType(), a);
+ }
+ }
+
+ public abstract Annotated getDelegate();
+
+ public Type getBaseType()
+ {
+ return getDelegate().getBaseType();
+ }
+
+ public Set<Type> getTypeClosure()
+ {
+ return getDelegate().getTypeClosure();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ return (T) annotationsByType.get(annotationType);
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ return annotations;
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return annotationsByType.containsKey(annotationType);
+ }
+ }
+
+ private static class AnnotatedTypeDecorator<S, X> extends AnnotatedElementDecorator<S, X> implements AnnotatedType<X>
+ {
+ private final AnnotatedType<X> delegate;
+ private final Set<AnnotatedMethod<? super X>> methods;
+
+ public AnnotatedTypeDecorator(AnnotatedType<X> delegate, Collection<Annotation> annotations,
+ Collection<AnnotatedMethod<? super X>> methods)
+ {
+ super(annotations);
+ this.delegate = delegate;
+ this.methods = new HashSet<AnnotatedMethod<? super X>>(methods);
+ }
+
+ @Override
+ public AnnotatedType<X> getDelegate()
+ {
+ return delegate;
+ }
+
+ public Class<X> getJavaClass()
+ {
+ return delegate.getJavaClass();
+ }
+
+ public Set<AnnotatedConstructor<X>> getConstructors()
+ {
+ return delegate.getConstructors();
+ }
+
+ public Set<AnnotatedMethod<? super X>> getMethods()
+ {
+ return methods;
+ }
+
+ public Set<AnnotatedField<? super X>> getFields()
+ {
+ return delegate.getFields();
+ }
+ }
+
+ private static class AnnotatedMethodDecorator<S, X> extends AnnotatedElementDecorator<S, X> implements AnnotatedMethod<S>
+ {
+ private final AnnotatedMethod<S> delegate;
+
+ public AnnotatedMethodDecorator(AnnotatedMethod<S> method, Collection<Annotation> annotations)
+ {
+ super(annotations);
+ this.delegate = method;
+ }
+
+ public List<AnnotatedParameter<S>> getParameters()
+ {
+ return delegate.getParameters();
+ }
+
+ public boolean isStatic()
+ {
+ return delegate.isStatic();
+ }
+
+ public AnnotatedType<S> getDeclaringType()
+ {
+ return delegate.getDeclaringType();
+ }
+
+ public Method getJavaMember()
+ {
+ return delegate.getJavaMember();
+ }
+
+ @Override
+ public AnnotatedMethod<S> getDelegate()
+ {
+ return delegate;
+ }
+
+ public static <S, X> AnnotatedMethodDecorator<S, X> decorate(AnnotatedMethod<S> method, Class<? super X> declaringType, Set<Annotation> annotations)
+ {
+ return new AnnotatedMethodDecorator<S, X>(method, annotations);
+ }
+ }
+
+ private static class AnnotatedTypeTransformer<S, X>
+ {
+ private AnnotatedType<X> source;
+
+ private Map<Class<? extends Annotation>, Annotation> annotationsByType;
+ private Map<Method, AnnotatedMethod<? super X>> methodsBySignature;
+
+ public AnnotatedTypeTransformer(AnnotatedType<X> source)
+ {
+ this.source = source;
+ }
+
+ public AnnotatedTypeTransformer<S, X> addAnnotation(Annotation a)
+ {
+ initAnnotationIndex();
+ annotationsByType.put(a.annotationType(), a);
+ return this;
+ }
+
+ public AnnotatedTypeTransformer<S, X> addAnnotationToMethod(AnnotatedMethod<? super X> method, Annotation a)
+ {
+ Set<Annotation> annotations = new HashSet<Annotation>(method.getAnnotations());
+ annotations.add(a);
+ replaceMethod(method, AnnotatedMethodDecorator.decorate(method, method.getDeclaringType().getJavaClass(), annotations));
+ return this;
+ }
+
+ public AnnotatedTypeTransformer<S, X> replaceMethod(AnnotatedMethod<? super X> existing, AnnotatedMethod<? super X> replacement)
+ {
+ return replaceMethod(existing.getJavaMember(), replacement);
+ }
+
+ public AnnotatedTypeTransformer<S, X> replaceMethod(Method existing, AnnotatedMethod<? super X> replacement)
+ {
+ initMethodIndex();
+ methodsBySignature.put(existing, replacement);
+ return this;
+ }
+
+ public AnnotatedTypeTransformer<S, X> pruneMethodsFromType(Class<? extends Object> type)
+ {
+ initMethodIndex();
+ for (Method m : type.getMethods())
+ {
+ methodsBySignature.remove(m);
+ }
+ return this;
+ }
+
+ public AnnotatedType<X> transform()
+ {
+ return new AnnotatedTypeDecorator<S, X>(source,
+ annotationsByType != null ? annotationsByType.values() : source.getAnnotations(),
+ methodsBySignature != null ? methodsBySignature.values() : source.getMethods()
+ );
+ }
+
+ public static <S, X> AnnotatedTypeTransformer<S, X> createFrom(AnnotatedType<X> source, Class<? super X> declaringType)
+ {
+ return new AnnotatedTypeTransformer<S, X>(source);
+ }
+
+ private void initAnnotationIndex()
+ {
+ if (annotationsByType == null)
+ {
+ annotationsByType = new HashMap<Class<? extends Annotation>, Annotation>();
+ for (Annotation a : source.getAnnotations())
+ {
+ annotationsByType.put(a.annotationType(), a);
+ }
+ }
+ }
+
+ private void initMethodIndex()
+ {
+ if (methodsBySignature == null)
+ {
+ methodsBySignature =
+ new HashMap<Method, AnnotatedMethod<? super X>>();
+ for (AnnotatedMethod<? super X> m : source.getMethods())
+ {
+ methodsBySignature.put(m.getJavaMember(), m);
+ }
+ }
+ }
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionLiteral.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionLiteral.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/TransactionLiteral.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.transaction;
+
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.enterprise.util.AnnotationLiteral;
+
+/**
+ * An annotation literal for creating instances of the Transaction
+ * annotation for use in extensions.
+ *
+ * @author Dan Allen
+ */
+public class TransactionLiteral extends AnnotationLiteral<Transaction> implements Transaction
+{
+ private final TransactionAttributeType value;
+
+ public TransactionLiteral()
+ {
+ this(TransactionAttributeType.REQUIRED);
+ }
+
+ public TransactionLiteral(TransactionAttributeType value)
+ {
+ this.value = value;
+ }
+
+ public TransactionAttributeType value()
+ {
+ return value;
+ }
+
+ public static Transaction from(TransactionAttribute source)
+ {
+ return new TransactionLiteral(source.value());
+ }
+
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/UserTransactionProducer.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/UserTransactionProducer.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/java/applicationPackage/transaction/UserTransactionProducer.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.transaction;
+
+import javax.enterprise.inject.Produces;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+
+/**
+ * A CDI producer bean that retrieves the {@link UserTransaction} resource from
+ * JNDI (under a name specific to JBoss EAP) and produces the result as a
+ * dependent-scoped managed bean of type {@link UserTransaction}.
+ */
+public class UserTransactionProducer
+{
+ @Produces
+ public UserTransaction getUserTransaction() throws NamingException
+ {
+ return (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/persistence.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/persistence.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/persistence.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="primary">
+ <!-- DataSource defined in default-ds.xml -->
+ <jta-data-source>jdbc/__default</jta-data-source>
+ <properties>
+ <!-- Properties for Hibernate (default provider for JBoss AS) -->
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <property name="hibernate.format_sql" value="false"/>
+ <property name="jboss.entity.manager.factory.jndi.name" value="java:/primaryEntityManagerFactory"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1 @@
+applicationPackage.transaction.TransactionInterceptorExtension
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/import.sql
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/import.sql (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/resources/import.sql 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1 @@
+insert into MEMBER (id, name, email, phone_number) VALUES (1, 'John Smith', 'john.smith at mailinator.com', '2125551212');
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/beans.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/beans.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/beans.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,11 @@
+<?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/>
+ <decorators/>
+ <interceptors>
+ <class>applicationPackage.transaction.TransactionInterceptor</class>
+ </interceptors>
+</beans>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/faces-config.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="1.2"
+ 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/web-facesconfig_1_2.xsd">
+
+ <application>
+ <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
+ </application>
+
+ <!-- Write your navigation rules here. You are encouraged to use CDI for creating @Named managed beans. -->
+
+</faces-config>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/templates/default.xhtml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/templates/default.xhtml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/templates/default.xhtml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,52 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <head>
+ <title>JSF 1.2 and CDI Starter Application</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <link rel="stylesheet" href="#{request.contextPath}/resources/css/screen.css" type="text/css"/>
+ </head>
+ <body>
+ <div id="container">
+ <div id="content">
+ <div id="sidebar">
+ <h3>Find out more</h3>
+ <p>
+ Explore JavaServer Faces.
+ </p>
+ <ul>
+ <li><a href="http://www.javaserverfaces.org">JSF community site</a></li>
+ </ul>
+ <p>
+ Learn more about CDI and the extensions provided by Weld and Seam.
+ </p>
+ <ul>
+ <li><a href="http://seamframework.org/Weld">Overview</a></li>
+ <li><a href="http://seamframework.org">Project site</a></li>
+ <li><a href="http://seamframework.org/Documentation/SeamDocumentation#H-WeldReferenceDocumentation">Documentation</a></li>
+ <li><a href="http://seamframework.org/Community/Forums">User forums</a></li>
+ <li><a href="http://seamframework.org/Community/MailingLists">Mailing lists</a></li>
+ <li><a href="https://jira.jboss.org/browse/WELDRAD">Issue tracker</a></li>
+ </ul>
+ <p>
+ If you have an add-on, please <a href="http://seamframework.org/Community/Forums">let us know</a> and
+ consider <a href="http://seamframework.org/Community/Contribute">contributing</a> it back to the
+ community!
+ </p>
+ </div>
+ <ui:insert name="content">
+ [Template content will be inserted here]
+ </ui:insert>
+ </div>
+ <div id="footer">
+ <h:graphicImage value="/resources/gfx/weld.png" alt="Weld logo"/>
+ <p>
+ This project was generated from a Maven archetype maintained by the Weld team.<br/>
+ Weld is the reference implementation of CDI, released under the Apache License, Version 2.0.<br/>
+ </p>
+ </div>
+ </div>
+ </body>
+</html>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/web.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <welcome-file-list>
+ <welcome-file>index.jsf</welcome-file>
+ </welcome-file-list>
+</web-app>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/weld.tld
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/weld.tld (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/WEB-INF/weld.tld 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<taglib 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/web-jsptaglibrary_2_0.xsd"
+ version="2.0">
+ <description>
+ A shell tag library that registers a listener to bootstrap Weld in a Servlet or pre-Java EE 6 environment
+ </description>
+ <tlib-version>1.0</tlib-version>
+ <short-name>w</short-name>
+ <uri>http://jboss.org/weld</uri>
+
+ <!--
+ Bootstraps the runtime environment of the CDI Reference Implementation (Weld)
+ -->
+ <listener>
+ <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
+ </listener>
+
+</taglib>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/index.jsf
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/index.jsf (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/index.jsf 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,8 @@
+The contents of this file will not be displayed!
+
+Having this file is a trick to get JBoss AS to redirect to the path index.jsf
+when the root application URL is requested (or any subdirectory).
+
+See https://jira.jboss.org/browse/JBAS-8224
+
+If you are using other containers, such as Glassfish, this file will be ignored and you may delete at will.
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/index.xhtml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/index.xhtml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/index.xhtml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/WEB-INF/templates/default.xhtml">
+ <ui:define name="content">
+ <h1>Welcome to JSF 1.2 with CDI!</h1>
+
+ <p>You have successfully deployed a JSF 1.2 web application that uses CDI for the programming model.</p>
+
+ <h:form id="reg">
+ <h2>Register</h2>
+ <table>
+ <tr>
+ <th style="text-align: right;">
+ <h:outputLabel for="name" value="Name:"/>
+ </th>
+ <td>
+ <h:inputText id="name" value="#{newMember.name}"/>
+ <h:message for="name" errorClass="invalid"/>
+ </td>
+ </tr>
+ <tr>
+ <th style="text-align: right;">
+ <h:outputLabel for="email" value="Email:"/>
+ </th>
+ <td>
+ <h:inputText id="email" value="#{newMember.email}"/>
+ <h:message for="email" errorClass="invalid"/>
+ </td>
+ </tr>
+ <tr>
+ <th style="text-align: right;">
+ <h:outputLabel for="phoneNumber" value="Phone #:"/>
+ </th>
+ <td>
+ <h:inputText id="phoneNumber" value="#{newMember.phoneNumber}"/>
+ <h:message for="phoneNumber" errorClass="invalid"/>
+ </td>
+ </tr>
+ </table>
+ <p>
+ <h:commandButton id="register" action="#{memberRegistration.register}" value="Register"/>
+ <h:outputText value=" Registered!" rendered="#{memberRegistration.registered}" style="color: green;"/>
+ </p>
+ </h:form>
+ <h2>Members</h2>
+ <h:panelGroup rendered="#{empty members}">
+ <em>No registered members.</em>
+ </h:panelGroup>
+ <h:dataTable var="_member" value="#{members}" rendered="#{not empty members}">
+ <h:column>
+ <f:facet name="header">Id</f:facet>
+ #{_member.id}
+ </h:column>
+ <h:column>
+ <f:facet name="header">Name</f:facet>
+ #{_member.name}
+ </h:column>
+ <h:column>
+ <f:facet name="header">Email</f:facet>
+ #{_member.email}
+ </h:column>
+ <h:column>
+ <f:facet name="header">Phone #</f:facet>
+ #{_member.phoneNumber}
+ </h:column>
+ </h:dataTable>
+ </ui:define>
+</ui:composition>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/css/screen.css
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/css/screen.css (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/css/screen.css 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,40 @@
+body {
+ margin: 0;
+ padding: 0;
+ background-color: #EAECEE;
+ font-family: Verdana, sans-serif;
+ font-size: 0.9em;
+}
+#container {
+ margin: 0 auto;
+ padding: 0 20px 10px 20px;
+ border: 1px solid #666666;
+ width: 865px; /* subtract 40px from banner width for padding */
+ background: #FFFFFF url(../gfx/banner.png) no-repeat;
+ padding-top: 110px;
+}
+#sidebar {
+ font-size: 0.9em;
+ width: 225px;
+ float: right;
+ border: 1px solid #666666;
+ background: #EAECEE;
+ padding: 0 15px 5px 15px;
+}
+#sidebar ul {
+ padding-left: 30px;
+}
+#footer {
+ clear: both;
+ text-align: center;
+ color: #666666;
+ font-size: 0.85em;
+ padding: 3em 0 0 0;
+}
+code {
+ font-size: 1.1em;
+}
+span.invalid {
+ padding-left: 3px;
+ color: red;
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/gfx/banner.png
===================================================================
(Binary files differ)
Property changes on: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/gfx/banner.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/gfx/weld.png
===================================================================
(Binary files differ)
Property changes on: archetypes/eap51-weld-jsf-webapp/trunk/src/main/webapp/resources/gfx/weld.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASConfiguration.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASConfiguration.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASConfiguration.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.arquillian.container.jbossas.remote_5_1;
+
+import org.jboss.arquillian.spi.ContainerConfiguration;
+import org.jboss.arquillian.spi.ContainerProfile;
+
+/**
+ * A {@link org.jboss.arquillian.spi.ContainerConfiguration} implementation for
+ * the JBoss AS container.
+ *
+ * @author <a href="mailto:german.escobarc at gmail.com">German Escobar</a>
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @author Dan Allen
+ */
+public class JBossASConfiguration implements ContainerConfiguration
+{
+ /**
+ * ProfileService profileKey. Used to load the correct profile into the DeploymentManager.
+ */
+ private String profileName = "default";
+
+ /**
+ * Used by Servlet Protocol to connect to deployment.
+ * // TODO: these belongs to the configuration of Servlet Protocol. Extract out.
+ */
+ private String remoteServerAddress = "localhost";
+
+ /**
+ * Used by Servlet Protocol to connect to deployment.
+ */
+ private int remoteServerHttpPort = 8080;
+
+ /**
+ * Bind Address for HTTP server for serving deployments to the remote server.
+ * Address should be reachable from remote server.
+ */
+ private String localDeploymentBindAddress = "localhost";
+
+ /**
+ * Bind Port for HTTP server for serving deployments to remote server.
+ * Port must be reachable from remote server.
+ */
+ private int localDeploymentBindPort = 9999;
+
+ /**
+ * Flag indicating whether the archive should be exploded when it is deployed
+ * to the server.
+ *
+ * <p>
+ * <strong>NOTE</strong> This flag will only work on JBoss EAP 5.1, not JBoss
+ * AS 5.1 Community Edition. The deployment option feature never got merged
+ * into the commmunity edition branch as described in this issue:
+ * <a href="https://jira.jboss.org/browse/JBAS-6693">JBAS-6693</a>
+ * </p>
+ */
+ private boolean deployExploded = false;
+
+ public ContainerProfile getContainerProfile()
+ {
+ return ContainerProfile.CLIENT;
+ }
+
+ public String getProfileName()
+ {
+ return profileName;
+ }
+
+ public void setProfileName(String profileName)
+ {
+ this.profileName = profileName;
+ }
+
+ public String getRemoteServerAddress()
+ {
+ return remoteServerAddress;
+ }
+
+ public void setRemoteServerAddress(String remoteServerAddress)
+ {
+ this.remoteServerAddress = remoteServerAddress;
+ }
+
+ public int getRemoteServerHttpPort()
+ {
+ return remoteServerHttpPort;
+ }
+
+ public void setRemoteServerHttpPort(int remoteServerHttpPort)
+ {
+ this.remoteServerHttpPort = remoteServerHttpPort;
+ }
+
+ public String getLocalDeploymentBindAddress()
+ {
+ return localDeploymentBindAddress;
+ }
+
+ public void setLocalDeploymentBindAddress(String localDeploymentBindAddress)
+ {
+ this.localDeploymentBindAddress = localDeploymentBindAddress;
+ }
+
+ public int getLocalDeploymentBindPort()
+ {
+ return localDeploymentBindPort;
+ }
+
+ public void setLocalDeploymentBindPort(int localDeploymentBindPort)
+ {
+ this.localDeploymentBindPort = localDeploymentBindPort;
+ }
+
+ public boolean isDeployExploded()
+ {
+ return deployExploded;
+ }
+
+ public void setDeployExploded(boolean deployExploded)
+ {
+ this.deployExploded = deployExploded;
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASDeploymentAppender.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASDeploymentAppender.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASDeploymentAppender.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.arquillian.container.jbossas.remote_5_1;
+
+import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
+import org.jboss.arquillian.spi.TestEnricher;
+import org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher;
+import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * EmbeddedDeploymentAppender
+ *
+ * Package the required dependencies needed by the Jboss Embedded Container plugin
+ * to run in container.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ */
+public class JBossASDeploymentAppender implements AuxiliaryArchiveAppender
+{
+
+ public Archive<?> createAuxiliaryArchive()
+ {
+ JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "arquillian-jboss-testenrichers.jar")
+ .addPackages(
+ true,
+ EJBInjectionEnricher.class.getPackage(),
+ ResourceInjectionEnricher.class.getPackage())
+ .addServiceProvider(
+ TestEnricher.class,
+ EJBInjectionEnricher.class,
+ ResourceInjectionEnricher.class);
+ return archive;
+ }
+
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASRemoteContainer.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASRemoteContainer.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/container/jbossas/remote_5_1/JBossASRemoteContainer.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,297 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.arquillian.container.jbossas.remote_5_1;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.InitialContext;
+
+import org.jboss.arquillian.spi.Configuration;
+import org.jboss.arquillian.spi.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.DeployableContainer;
+import org.jboss.arquillian.spi.DeploymentException;
+import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.profileservice.spi.DeploymentOption;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.virtual.VFS;
+
+import applicationPackage.patch.arquillian.protocol.servlet_2_5.ServletMethodExecutor;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+/**
+ * JbossRemoteContainer
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @author Dan Allen
+ */
+public class JBossASRemoteContainer implements DeployableContainer
+{
+ private final List<String> failedUndeployments = new ArrayList<String>();
+ private DeploymentManager deploymentManager;
+
+ private HttpServer httpFileServer;
+
+ private JBossASConfiguration configuration;
+
+ public void setup(Context context, Configuration configuration)
+ {
+ this.configuration = configuration.getContainerConfig(JBossASConfiguration.class);
+ }
+
+ public void start(Context context) throws LifecycleException
+ {
+ try
+ {
+ // TODO: configure http bind address
+ httpFileServer = HttpServer.create();
+ httpFileServer.bind(
+ new InetSocketAddress(
+ InetAddress.getByName(configuration.getLocalDeploymentBindAddress()),
+ configuration.getLocalDeploymentBindPort()),
+ -1);
+ httpFileServer.start();
+ initDeploymentManager();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not connect to container", e);
+ }
+ }
+
+ public void stop(Context context) throws LifecycleException
+ {
+ try
+ {
+ httpFileServer.stop(0);
+ removeFailedUnDeployments();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not clean up", e);
+ }
+ }
+
+ public ContainerMethodExecutor deploy(Context context, final Archive<?> archive) throws DeploymentException
+ {
+ if(archive == null)
+ {
+ throw new IllegalArgumentException("Archive must be specified");
+ }
+ if (deploymentManager == null)
+ {
+ throw new IllegalStateException("start has not been called!");
+ }
+ String deploymentName = archive.getName();
+
+ Exception failure = null;
+ try
+ {
+ httpFileServer.createContext("/" + deploymentName, new HttpHandler()
+ {
+ public void handle(HttpExchange exchange) throws IOException
+ {
+ InputStream zip = archive.as(ZipExporter.class).exportZip();
+ ByteArrayOutputStream zipStream = new ByteArrayOutputStream();
+ JBossASRemoteContainer.copy(zip, zipStream);
+ zip.close();
+
+ byte[] zipArray = zipStream.toByteArray();
+ exchange.sendResponseHeaders(200, zipArray.length);
+
+ OutputStream out = exchange.getResponseBody();
+ out.write(zipArray);
+ out.close();
+
+ }
+ });
+ URL fileServerUrl = createFileServerURL(deploymentName);
+
+ DeploymentProgress distribute;
+ if (configuration.isDeployExploded())
+ {
+ distribute = deploymentManager.distribute(deploymentName, fileServerUrl, DeploymentOption.Explode);
+ }
+ else
+ {
+ distribute = deploymentManager.distribute(deploymentName, fileServerUrl, true);
+ }
+ distribute.run();
+ DeploymentStatus uploadStatus = distribute.getDeploymentStatus();
+ if(uploadStatus.isFailed())
+ {
+ failure = uploadStatus.getFailure();
+ undeploy(deploymentName);
+ }
+ else
+ {
+ DeploymentProgress progress = deploymentManager.start(deploymentName);
+ progress.run();
+ DeploymentStatus status = progress.getDeploymentStatus();
+ if (status.isFailed())
+ {
+ failure = status.getFailure();
+ undeploy(deploymentName);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not deploy " + deploymentName, e);
+ }
+ if (failure != null)
+ {
+ throw new DeploymentException("Failed to deploy " + deploymentName, failure);
+ }
+ try
+ {
+ return new ServletMethodExecutor(
+ new URL(
+ "http",
+ configuration.getRemoteServerAddress(),
+ configuration.getRemoteServerHttpPort(),
+ "/")
+ );
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create ContianerMethodExecutor", e);
+ }
+ }
+
+ public void undeploy(Context context, Archive<?> archive) throws DeploymentException
+ {
+ if(archive == null)
+ {
+ throw new IllegalArgumentException("Archive must be specified");
+ }
+ undeploy(archive.getName());
+ }
+
+ private void undeploy(String name) throws DeploymentException
+ {
+ try
+ {
+ DeploymentProgress stopProgress = deploymentManager.stop(name);
+ stopProgress.run();
+
+ DeploymentProgress undeployProgress = deploymentManager.remove(name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ failedUndeployments.add(name);
+ }
+ httpFileServer.removeContext("/" + name);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not undeploy " + name, e);
+ }
+ }
+
+ private void initDeploymentManager() throws Exception
+ {
+ String profileName = configuration.getProfileName();
+ InitialContext ctx = new InitialContext();
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ deploymentManager = ps.getDeploymentManager();
+ ProfileKey defaultKey = new ProfileKey(profileName);
+ deploymentManager.loadProfile(defaultKey);
+ VFS.init();
+ }
+
+ private URL createFileServerURL(String archiveName)
+ {
+ try
+ {
+ InetSocketAddress address = httpFileServer.getAddress();
+ return new URL(
+ "http",
+ address.getHostName(),
+ address.getPort(),
+ "/" + archiveName);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Could not create fileserver url", e);
+ }
+ }
+
+ private void removeFailedUnDeployments() throws IOException
+ {
+ List<String> remainingDeployments = new ArrayList<String>();
+ for (String name : failedUndeployments)
+ {
+ try
+ {
+ DeploymentProgress undeployProgress = deploymentManager.remove(name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ remainingDeployments.add(name);
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ if (remainingDeployments.size() > 0)
+ {
+ //log.error("Failed to undeploy these artifacts: " + remainingDeployments);
+ }
+ failedUndeployments.clear();
+ }
+
+ private static void copy(InputStream source, OutputStream destination) throws IOException
+ {
+ if (source == null)
+ {
+ throw new IllegalArgumentException("source must be specified");
+ }
+ if (destination == null)
+ {
+ throw new IllegalArgumentException("destination must be specified");
+ }
+ byte[] readBuffer = new byte[2156];
+ int bytesIn = 0;
+ while((bytesIn = source.read(readBuffer)) != -1)
+ {
+ destination.write(readBuffer, 0, bytesIn);
+ }
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ProtocolDeploymentAppender.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ProtocolDeploymentAppender.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ProtocolDeploymentAppender.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.arquillian.protocol.servlet_2_5;
+
+import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * ProtocolDeploymentAppender
+ *
+ * DeploymentAppender to add required resources for the protocol servlet to run
+ * in container.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @author Dan Allen
+ */
+public class ProtocolDeploymentAppender implements AuxiliaryArchiveAppender
+{
+ public Archive<?> createAuxiliaryArchive()
+ {
+ return ShrinkWrap.create(JavaArchive.class, "arquillian-protocol.jar")
+ .addManifestResource("auxiliary-web.xml", "auxiliary-web.xml")
+ .addClasses(SecurityActions.class, ServletTestRunner.class);
+ }
+
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/SecurityActions.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/SecurityActions.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/SecurityActions.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.arquillian.protocol.servlet_2_5;
+
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * SecurityActions
+ *
+ * A set of privileged actions that are not to leak out
+ * of this package
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+final class SecurityActions
+{
+
+ //-------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * No instantiation
+ */
+ private SecurityActions()
+ {
+ throw new UnsupportedOperationException("No instantiation");
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Utility Methods --------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Thread Context ClassLoader
+ */
+ static ClassLoader getThreadContextClassLoader()
+ {
+ return AccessController.doPrivileged(GetTcclAction.INSTANCE);
+ }
+
+ /**
+ * Obtains the Constructor specified from the given Class and argument types
+ * @param clazz
+ * @param argumentTypes
+ * @return
+ * @throws NoSuchMethodException
+ */
+ static Constructor<?> getConstructor(final Class<?> clazz, final Class<?>... argumentTypes)
+ throws NoSuchMethodException
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>()
+ {
+ public Constructor<?> run() throws NoSuchMethodException
+ {
+ return clazz.getConstructor(argumentTypes);
+ }
+ });
+ }
+ // Unwrap
+ catch (final PrivilegedActionException pae)
+ {
+ final Throwable t = pae.getCause();
+ // Rethrow
+ if (t instanceof NoSuchMethodException)
+ {
+ throw (NoSuchMethodException) t;
+ }
+ else
+ {
+ // No other checked Exception thrown by Class.getConstructor
+ try
+ {
+ throw (RuntimeException) t;
+ }
+ // Just in case we've really messed up
+ catch (final ClassCastException cce)
+ {
+ throw new RuntimeException("Obtained unchecked Exception; this code should never be reached", t);
+ }
+ }
+ }
+ }
+
+ /**
+ * Create a new instance by finding a constructor that matches the argumentTypes signature
+ * using the arguments for instantiation.
+ *
+ * @param className Full classname of class to create
+ * @param argumentTypes The constructor argument types
+ * @param arguments The constructor arguments
+ * @return a new instance
+ * @throws IllegalArgumentException if className, argumentTypes, or arguments are null
+ * @throws RuntimeException if any exceptions during creation
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+ static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments,
+ final Class<T> expectedType)
+ {
+ if (className == null)
+ {
+ throw new IllegalArgumentException("ClassName must be specified");
+ }
+ if (argumentTypes == null)
+ {
+ throw new IllegalArgumentException("ArgumentTypes must be specified. Use empty array if no arguments");
+ }
+ if (arguments == null)
+ {
+ throw new IllegalArgumentException("Arguments must be specified. Use empty array if no arguments");
+ }
+ final Object obj;
+ try
+ {
+ final ClassLoader tccl = getThreadContextClassLoader();
+ final Class<?> implClass = Class.forName(className, false, tccl);
+ Constructor<?> constructor = getConstructor(implClass, argumentTypes);
+ obj = constructor.newInstance(arguments);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create new instance of " + className
+ + ", missing package from classpath?", e);
+ }
+
+ // Cast
+ try
+ {
+ return expectedType.cast(obj);
+ }
+ catch (final ClassCastException cce)
+ {
+ // Reconstruct so we get some useful information
+ throw new ClassCastException("Incorrect expected type, " + expectedType.getName() + ", defined for "
+ + obj.getClass().getName());
+ }
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Inner Classes ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Single instance to get the TCCL
+ */
+ private enum GetTcclAction implements PrivilegedAction<ClassLoader> {
+ INSTANCE;
+
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ }
+
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletMethodExecutor.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletMethodExecutor.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletMethodExecutor.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.arquillian.protocol.servlet_2_5;
+
+import java.io.ObjectInputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.jboss.arquillian.spi.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.TestMethodExecutor;
+import org.jboss.arquillian.spi.TestResult;
+
+/**
+ * ServletMethodExecutor
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ */
+public class ServletMethodExecutor implements ContainerMethodExecutor
+{
+ private URL baseURL;
+
+ public ServletMethodExecutor(URL baseURL)
+ {
+ this.baseURL = baseURL;
+ }
+
+ public TestResult invoke(TestMethodExecutor testMethodExecutor)
+ {
+ if(testMethodExecutor == null)
+ {
+ throw new IllegalArgumentException("TestMethodExecutor must be specified");
+ }
+
+ Class<?> testClass = testMethodExecutor.getInstance().getClass();
+ String url = baseURL.toExternalForm() + "test/ArquillianServletRunner" +
+ "?outputMode=serializedObject&className=" + testClass.getName() +
+ "&methodName=" + testMethodExecutor.getMethod().getName();
+
+ try
+ {
+ return execute(url);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Error launching test " + testClass.getName() + " " + testMethodExecutor.getMethod(), e);
+ }
+ }
+
+ private TestResult execute(String url) throws Exception
+ {
+ long timeoutTime = System.currentTimeMillis() + 1000;
+ boolean interrupted = false;
+ while (timeoutTime > System.currentTimeMillis())
+ {
+ URLConnection connection = new URL(url).openConnection();
+ if (!(connection instanceof HttpURLConnection))
+ {
+ throw new IllegalStateException("Not an http connection! " + connection);
+ }
+ HttpURLConnection httpConnection = (HttpURLConnection) connection;
+ httpConnection.setUseCaches(false);
+ httpConnection.setDefaultUseCaches(false);
+ try
+ {
+ httpConnection.connect();
+ if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK)
+ {
+ ObjectInputStream ois = new ObjectInputStream(httpConnection.getInputStream());
+ Object o;
+ try
+ {
+ o = ois.readObject();
+ }
+ finally
+ {
+ ois.close();
+ }
+
+ if (!(o instanceof TestResult))
+ {
+ throw new IllegalStateException("Error reading test results - expected a TestResult but got " + o);
+ }
+ return (TestResult) o;
+ }
+ else if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_NOT_FOUND)
+ {
+ throw new IllegalStateException(
+ "Error launching test at " + url + ". " +
+ "Got " + httpConnection.getResponseCode() + " ("+ httpConnection.getResponseMessage() + ")");
+ }
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (InterruptedException e)
+ {
+ interrupted = true;
+ }
+ }
+ finally
+ {
+ httpConnection.disconnect();
+ }
+ }
+ if (interrupted)
+ {
+ Thread.currentThread().interrupt();
+ }
+ throw new IllegalStateException("Error launching test at " + url + ". Kept on getting 404s.");
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletProtocolDeploymentPackager.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletProtocolDeploymentPackager.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletProtocolDeploymentPackager.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.arquillian.protocol.servlet_2_5;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.arquillian.spi.DeploymentPackager;
+import org.jboss.arquillian.spi.TestDeployment;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Filter;
+import org.jboss.shrinkwrap.api.Node;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ArchiveAsset;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+/**
+ * ServletProtocolDeploymentPackager
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @author Dan Allen
+ */
+public class ServletProtocolDeploymentPackager implements DeploymentPackager
+{
+ private static final ArchivePath AUXILIARY_WEB_XML_JAR_PATH = ArchivePaths.create("META-INF/auxiliary-web.xml");
+
+ private static final ArchivePath WEB_XML_WAR_PATH = ArchivePaths.create("WEB-INF/web.xml");
+
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.DeploymentPackager#generateDeployment(org.jboss.arquillian.spi.TestDeployment)
+ */
+ public Archive<?> generateDeployment(TestDeployment testDeployment)
+ {
+ Archive<?> protocol = new ProtocolDeploymentAppender().createAuxiliaryArchive();
+
+ Archive<?> applicationArchive = testDeployment.getApplicationArchive();
+ Collection<Archive<?>> auxiliaryArchives = testDeployment.getAuxiliaryArchives();
+
+ Archive<?> archive;
+ if (EnterpriseArchive.class.isInstance(applicationArchive))
+ {
+ archive = handleArchive(EnterpriseArchive.class.cast(applicationArchive), auxiliaryArchives, protocol);
+ }
+ else if (WebArchive.class.isInstance(applicationArchive))
+ {
+ archive = handleArchive(WebArchive.class.cast(applicationArchive), auxiliaryArchives, protocol);
+ }
+ else if (JavaArchive.class.isInstance(applicationArchive))
+ {
+ archive = handleArchive(JavaArchive.class.cast(applicationArchive), auxiliaryArchives, protocol);
+ }
+ else
+ {
+ throw new IllegalArgumentException(ServletProtocolDeploymentPackager.class.getName() +
+ " can not handle archive of type " + applicationArchive.getClass().getName());
+ }
+
+ //System.out.println(archive.toString(true));
+ return archive;
+ }
+
+ private Archive<?> handleArchive(WebArchive applicationArchive, Collection<Archive<?>> auxiliaryArchives, Archive<?> protocol)
+ {
+ return importProtocolArchive(applicationArchive, protocol).addLibraries(auxiliaryArchives.toArray(new Archive<?>[0]));
+ }
+
+ private Archive<?> handleArchive(JavaArchive applicationArchive, Collection<Archive<?>> auxiliaryArchives, Archive<?> protocol)
+ {
+ return ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
+ .addModule(applicationArchive)
+ .addModule(importProtocolArchive(ShrinkWrap.create(WebArchive.class, "test.war"), protocol))
+ .addLibraries(auxiliaryArchives.toArray(new Archive[0]));
+ }
+
+ private Archive<?> handleArchive(EnterpriseArchive applicationArchive, Collection<Archive<?>> auxiliaryArchives, Archive<?> protocol)
+ {
+ WebArchive applicationWebArchive = null;
+ Map<ArchivePath, Node> rootNodes = applicationArchive.getContent(new Filter<ArchivePath>()
+ {
+ public boolean include(ArchivePath object)
+ {
+ return object.getParent() == null || object.getParent().get().equals("/");
+ }
+ });
+
+ for (Map.Entry<ArchivePath, Node> c : rootNodes.entrySet())
+ {
+ Asset a = c.getValue().getAsset();
+ if (a instanceof ArchiveAsset && ((ArchiveAsset) a).getArchive() instanceof WebArchive)
+ {
+ applicationWebArchive = importProtocolArchive((WebArchive) ((ArchiveAsset) a).getArchive(), protocol);
+ break;
+ }
+ }
+
+ if (applicationWebArchive == null)
+ {
+ applicationArchive.addModule(importProtocolArchive(ShrinkWrap.create(WebArchive.class, "test.war"), protocol));
+ }
+
+ return applicationArchive.addLibraries(auxiliaryArchives.toArray(new Archive<?>[0]));
+ }
+
+ private WebArchive importProtocolArchive(WebArchive to, Archive<?> protocol)
+ {
+ if (protocol.contains(AUXILIARY_WEB_XML_JAR_PATH))
+ {
+ if (to.contains(WEB_XML_WAR_PATH))
+ {
+ to.setWebXML(mergeWebXmlFragment(to.get(WEB_XML_WAR_PATH).getAsset(),
+ protocol.get(AUXILIARY_WEB_XML_JAR_PATH).getAsset()));
+ }
+ else
+ {
+ to.setWebXML(protocol.get(AUXILIARY_WEB_XML_JAR_PATH).getAsset());
+ }
+ protocol.delete(AUXILIARY_WEB_XML_JAR_PATH);
+ }
+ to.addLibrary(protocol);
+ return to;
+ }
+
+ private Asset mergeWebXmlFragment(Asset master, Asset fragment)
+ {
+ try
+ {
+ DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document masterDoc = b.parse(master.openStream());
+ masterDoc.setXmlStandalone(true);
+ Document fragmentDoc = b.parse(fragment.openStream());
+ NodeList children = fragmentDoc.getDocumentElement().getChildNodes();
+ for (int i = 0, len = children.getLength(); i < len; i++)
+ {
+ masterDoc.getDocumentElement().appendChild(masterDoc.importNode(children.item(i), true));
+ }
+
+ Transformer t = TransformerFactory.newInstance().newTransformer();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ t.transform(new DOMSource(masterDoc), new StreamResult(os));
+ return new ByteArrayAsset(os.toByteArray());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to merge protocol's auxiliary-web.xml into application web.xml: ", e);
+ }
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletTestRunner.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletTestRunner.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/protocol/servlet_2_5/ServletTestRunner.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.arquillian.protocol.servlet_2_5;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.arquillian.spi.TestResult;
+import org.jboss.arquillian.spi.TestRunner;
+import org.jboss.arquillian.spi.TestResult.Status;
+import org.jboss.arquillian.spi.util.TestRunners;
+
+/**
+ * ServletTestRunner
+ *
+ * The server side executor for the Servlet protocol impl.
+ *
+ * Supports multiple output modes ("outputmode"):
+ * - html
+ * - serializedObject
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ */
+public class ServletTestRunner extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ public static final String PARA_METHOD_NAME = "methodName";
+ public static final String PARA_CLASS_NAME = "className";
+ public static final String PARA_OUTPUT_MODE = "outputMode";
+
+ public static final String OUTPUT_MODE_SERIALIZED = "serializedObject";
+ public static final String OUTPUT_MODE_HTML = "html";
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ String outputMode = OUTPUT_MODE_HTML;
+ try
+ {
+ String className = null;
+ String methodName = null;
+
+ if (request.getParameter(PARA_OUTPUT_MODE) != null)
+ {
+ outputMode = request.getParameter(PARA_OUTPUT_MODE);
+ }
+ className = request.getParameter(PARA_CLASS_NAME);
+ if (className == null)
+ {
+ throw new IllegalArgumentException(PARA_CLASS_NAME + " must be specified");
+ }
+ methodName = request.getParameter(PARA_METHOD_NAME);
+ if ( methodName == null)
+ {
+ throw new IllegalArgumentException(PARA_METHOD_NAME + " must be specified");
+ }
+
+ Class<?> testClass = SecurityActions.getThreadContextClassLoader().loadClass(className);
+
+ TestRunner runner = TestRunners.getTestRunner();
+
+ TestResult testResult = runner.execute(testClass, methodName);
+
+ if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
+ {
+ writeObject(testResult, response);
+ }
+ else
+ {
+ // TODO: implement a html view of the result
+ response.setContentType("text/html");
+ response.setStatus(HttpServletResponse.SC_OK);
+ PrintWriter writer = response.getWriter();
+ writer.write("<html>\n");
+ writer.write("<head><title>TCK Report</title></head>\n");
+ writer.write("<body>\n");
+ writer.write("<h2>Configuration</h2>\n");
+ writer.write("<table>\n");
+ writer.write("<tr>\n");
+ writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
+ writer.write("</tr>\n");
+
+ writer.write("</table>\n");
+ writer.write("<h2>Tests</h2>\n");
+ writer.write("<table>\n");
+ writer.write("<tr>\n");
+ writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
+ writer.write("</tr>\n");
+
+ writer.write("</table>\n");
+ writer.write("</body>\n");
+ }
+
+ }
+ catch(Exception e)
+ {
+ if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
+ {
+ writeObject(createFailedResult(e), response);
+ }
+ else
+ {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ }
+ }
+
+ private void writeObject(Object object, HttpServletResponse response)
+ {
+ try
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
+ oos.writeObject(object);
+ response.setStatus(HttpServletResponse.SC_OK);
+ oos.flush();
+ oos.close();
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ catch (Exception e2)
+ {
+ throw new RuntimeException("Could not write to output", e2);
+ }
+ }
+ }
+
+ private TestResult createFailedResult(Throwable throwable)
+ {
+ return new TestResult(Status.FAILED, throwable);
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/testenricher/cdi/support/CDIInjectionSupportDeploymentAppender.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/testenricher/cdi/support/CDIInjectionSupportDeploymentAppender.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/arquillian/testenricher/cdi/support/CDIInjectionSupportDeploymentAppender.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,26 @@
+package applicationPackage.patch.arquillian.testenricher.cdi.support;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
+import org.jboss.arquillian.spi.TestEnricher;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * Adds the CDI test enricher to the deployment.
+ *
+ * @author Dan Allen
+ */
+public class CDIInjectionSupportDeploymentAppender implements AuxiliaryArchiveAppender
+{
+ public Archive<?> createAuxiliaryArchive()
+ {
+ return ShrinkWrap.create(JavaArchive.class, "arquillian-cdi-enricher.jar")
+ // CDI SPI required if the container doesn't have CDI and it's not included in the archive
+ .addPackages(true, InjectionPoint.class.getPackage())
+ .addPackages(true, org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.class.getPackage())
+ .addServiceProvider(TestEnricher.class, org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.class);
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/weld/environment/servlet/BeanManagerResourceBindingListener.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/weld/environment/servlet/BeanManagerResourceBindingListener.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/patch/weld/environment/servlet/BeanManagerResourceBindingListener.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.patch.weld.environment.servlet;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.jboss.weld.resources.ManagerObjectFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Emulates the behavior of the naming resource binding that is typically done using configuration in Tomcat and Jetty.
+ * JBoss AS does not provide a way to register naming resources at the application level, but it does provide a read-write
+ * naming director, so a listener will suffice.
+ *
+ * @author Dan Allen
+ */
+public class BeanManagerResourceBindingListener implements ServletContextListener
+{
+ private static final Logger log = LoggerFactory.getLogger(BeanManagerResourceBindingListener.class);
+
+ private static final String RESOURCES_CONTEXT = "java:comp/env";
+
+ private static final String BEAN_MANAGER_JNDI_NAME = "BeanManager";
+
+ private static final String QUALIFIED_BEAN_MANAGER_JNDI_NAME = RESOURCES_CONTEXT + "/" + BEAN_MANAGER_JNDI_NAME;
+
+ public void contextInitialized(ServletContextEvent sce)
+ {
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ boolean present = false;
+ try
+ {
+ NamingEnumeration<NameClassPair> entries = ctx.list(RESOURCES_CONTEXT);
+ while (entries.hasMoreElements())
+ {
+ NameClassPair e = entries.next();
+ if (e.getName().equals(BEAN_MANAGER_JNDI_NAME) && e.getClassName().equals(BeanManager.class))
+ {
+ present = true;
+ break;
+ }
+ }
+ }
+ catch (NamingException e)
+ {
+ log.info("Could not perform lookup to detect BeanManager reference in JNDI: " + e.getExplanation());
+ }
+
+ if (!present)
+ {
+ try
+ {
+ // we rebind just in case it really is there and we just couldn't read it
+ ctx.rebind(QUALIFIED_BEAN_MANAGER_JNDI_NAME,
+ new Reference(BeanManager.class.getName(), ManagerObjectFactory.class.getName(), null));
+ log.info("BeanManager reference bound to " + QUALIFIED_BEAN_MANAGER_JNDI_NAME);
+ }
+ catch (NamingException e)
+ {
+ log.warn("Could not bind BeanManager reference to JNDI: " + e.getExplanation() + " \n" +
+ "If the naming context is read-only, you may need to use configuration to bind the entry, such as Tomcat's context.xml or Jetty's jetty-web.xml.");
+ }
+ }
+ }
+ catch (NamingException e)
+ {
+ log.warn("Could not create InitialContext to check for BeanManager reference in JNDI: " + e.getExplanation());
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent arg0)
+ {
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/CDISmokeIntegrationTest.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/CDISmokeIntegrationTest.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/CDISmokeIntegrationTest.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,48 @@
+package applicationPackage.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import applicationPackage.patch.weld.environment.servlet.BeanManagerResourceBindingListener;
+import applicationPackage.test.util.Dependencies;
+import applicationPackage.test.util.MavenArtifactResolver;
+
+/**
+ * A basic integration test case that verifies the Weld boots properly and
+ * provides a working CDI environment.
+ */
+ at RunWith(Arquillian.class)
+public class CDISmokeIntegrationTest
+{
+ @Deployment
+ public static Archive<?> createDeployment()
+ {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClass(BeanManagerResourceBindingListener.class)
+ .addLibrary(MavenArtifactResolver.resolve(Dependencies.WELD_SERVLET_JBOSS5_ARTIFACT))
+ // uncomment beans.xml to scan for bean classes in archive
+ //.addManifestResource(EmptyAsset.INSTANCE, "beans.xml")
+ // this placeholder TLD adds the Servlet listeners to bootstrap Weld
+ .addWebResource("weld.tld");
+ }
+
+ @Inject BeanManager beanManager;
+
+ @Test
+ public void cdi_environment_should_be_loaded()
+ {
+ assertNotNull(beanManager);
+ assertFalse(beanManager.getBeans(BeanManager.class).isEmpty());
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/PersistenceTxSmokeIntegrationTest.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/PersistenceTxSmokeIntegrationTest.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/PersistenceTxSmokeIntegrationTest.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,55 @@
+package applicationPackage.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import applicationPackage.patch.weld.environment.servlet.BeanManagerResourceBindingListener;
+import applicationPackage.persistence.MemberRepository;
+import applicationPackage.persistence.MemberRepositoryProducer;
+import applicationPackage.test.util.Dependencies;
+import applicationPackage.test.util.MavenArtifactResolver;
+import applicationPackage.transaction.UserTransactionProducer;
+
+
+ at RunWith(Arquillian.class)
+public class PersistenceTxSmokeIntegrationTest
+{
+ @Deployment
+ public static Archive<?> createDeployment()
+ {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(MemberRepository.class, MemberRepositoryProducer.class, UserTransactionProducer.class,
+ BeanManagerResourceBindingListener.class)
+ .addLibraries(MavenArtifactResolver.resolve(Dependencies.WELD_SERVLET_JBOSS5_ARTIFACT))
+ .addManifestResource("test-persistence.xml", "persistence.xml")
+ .addWebResource(EmptyAsset.INSTANCE, "beans.xml")
+ .setWebXML("test-web.xml");
+ }
+
+ @Inject @MemberRepository EntityManager em;
+
+ @Inject UserTransaction tx;
+
+ @Test
+ public void entity_manager_should_be_produced() throws Throwable
+ {
+ assertNotNull(em);
+ assertNotNull(em.getDelegate());
+ assertNotNull(tx);
+ assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAtClassLevelTestBean.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAtClassLevelTestBean.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAtClassLevelTestBean.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,12 @@
+package applicationPackage.test.transaction;
+
+import applicationPackage.transaction.Transaction;
+
+ at Transaction
+public class TransactionAtClassLevelTestBean
+{
+ public void transactionalMethod(TransactionInterceptorIntegrationTest.TransactionStatusMonitor m)
+ {
+ m.captureStatus();
+ }
+}
\ No newline at end of file
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAttributeAtClassLevelTestBean.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAttributeAtClassLevelTestBean.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAttributeAtClassLevelTestBean.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,12 @@
+package applicationPackage.test.transaction;
+
+import javax.ejb.TransactionAttribute;
+
+ at TransactionAttribute
+public class TransactionAttributeAtClassLevelTestBean
+{
+ public void transactionalMethod(TransactionInterceptorIntegrationTest.TransactionStatusMonitor m)
+ {
+ m.captureStatus();
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAttributeAtMethodLevelTestBean.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAttributeAtMethodLevelTestBean.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionAttributeAtMethodLevelTestBean.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,25 @@
+package applicationPackage.test.transaction;
+
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+public class TransactionAttributeAtMethodLevelTestBean
+{
+ @TransactionAttribute
+ public void transactionalMethod(TransactionInterceptorIntegrationTest.TransactionStatusMonitor m)
+ {
+ m.captureStatus();
+ }
+
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void nonTransactionalMethod(TransactionInterceptorIntegrationTest.TransactionStatusMonitor m)
+ {
+ m.captureStatus();
+ }
+
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public void neverTransactionalMethod()
+ {
+ }
+}
+
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionInterceptorIntegrationTest.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionInterceptorIntegrationTest.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/transaction/TransactionInterceptorIntegrationTest.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,129 @@
+package applicationPackage.test.transaction;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import applicationPackage.patch.weld.environment.servlet.BeanManagerResourceBindingListener;
+import applicationPackage.test.util.Dependencies;
+import applicationPackage.test.util.MavenArtifactResolver;
+import applicationPackage.transaction.Transaction;
+import applicationPackage.transaction.TransactionInterceptorExtension;
+
+
+ at RunWith(Arquillian.class)
+public class TransactionInterceptorIntegrationTest
+{
+ @Deployment
+ public static Archive<?> createDeployment()
+ {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addPackage(Transaction.class.getPackage())
+ .addClasses(TransactionAtClassLevelTestBean.class, TransactionAttributeAtClassLevelTestBean.class, TransactionAttributeAtMethodLevelTestBean.class)
+ .addServiceProvider(Extension.class, TransactionInterceptorExtension.class)
+ .addLibraries(MavenArtifactResolver.resolve(Dependencies.WELD_SERVLET_JBOSS5_ARTIFACT))
+ .addClass(BeanManagerResourceBindingListener.class)
+ .addWebResource("test-transaction-interceptor-beans.xml", "beans.xml")
+ .addWebResource("weld.tld");
+ //.setWebXML("test-web.xml");
+ }
+
+ @Inject Instance<TransactionAttributeAtMethodLevelTestBean> builtInAtMethodLevelBeanRef;
+
+ @Inject Instance<TransactionAttributeAtClassLevelTestBean> buildInAtClassLevelBeanRef;
+
+ @Inject Instance<TransactionAttributeAtClassLevelTestBean> aliasAtClassLevelBeanRef;
+
+ @Inject Instance<UserTransaction> txRef;
+
+ @Test
+ public void transaction_should_be_active_in_method_marked_transactional_on_method()
+ {
+ TransactionStatusMonitor m = new TransactionStatusMonitor(txRef.get());
+ builtInAtMethodLevelBeanRef.get().transactionalMethod(m);
+ assertEquals(Status.STATUS_ACTIVE, m.getCapturedStatus());
+ }
+
+ @Test
+ public void transaction_should_not_be_active_in_method_marked_non_transactional_on_method()
+ {
+ TransactionStatusMonitor m = new TransactionStatusMonitor(txRef.get());
+ builtInAtMethodLevelBeanRef.get().nonTransactionalMethod(m);
+ assertEquals(Status.STATUS_NO_TRANSACTION, m.getCapturedStatus());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void should_throw_exception_if_method_marked_never_transactional_on_method() throws Throwable
+ {
+ UserTransaction tx = txRef.get();
+ try
+ {
+ tx.begin();
+ builtInAtMethodLevelBeanRef.get().neverTransactionalMethod();
+ }
+ finally
+ {
+ if (tx.getStatus() == Status.STATUS_ACTIVE)
+ {
+ tx.rollback();
+ }
+ }
+ }
+
+ @Test
+ public void transaction_should_be_active_in_method_marked_transactional_on_class()
+ {
+ TransactionStatusMonitor m = new TransactionStatusMonitor(txRef.get());
+ buildInAtClassLevelBeanRef.get().transactionalMethod(m);
+ assertEquals(Status.STATUS_ACTIVE, m.getCapturedStatus());
+ }
+
+ @Test
+ public void transaction_should_be_active_in_method_marked_transaction_alias_on_class()
+ {
+ TransactionStatusMonitor m = new TransactionStatusMonitor(txRef.get());
+ aliasAtClassLevelBeanRef.get().transactionalMethod(m);
+ assertEquals(Status.STATUS_ACTIVE, m.getCapturedStatus());
+ }
+
+ static class TransactionStatusMonitor
+ {
+ private int status = Status.STATUS_UNKNOWN;
+
+ private UserTransaction tx;
+
+ public TransactionStatusMonitor(UserTransaction tx)
+ {
+ this.tx = tx;
+ }
+
+ public void captureStatus()
+ {
+ try
+ {
+ status = tx.getStatus();
+ }
+ catch (SystemException e)
+ {
+ }
+ }
+
+ public int getCapturedStatus()
+ {
+ return status;
+ }
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/Dependencies.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/Dependencies.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/Dependencies.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,8 @@
+package applicationPackage.test.util;
+
+public interface Dependencies
+{
+ public static final String WELD_SERVLET_VERSION = "1.1.0.Beta1";
+
+ public static final String WELD_SERVLET_JBOSS5_ARTIFACT = "org.jboss.weld.servlet:weld-servlet:" + WELD_SERVLET_VERSION + ":jboss5";
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/MavenArtifactResolver.java
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/MavenArtifactResolver.java (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/java/applicationPackage/test/util/MavenArtifactResolver.java 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package applicationPackage.test.util;
+
+import java.io.File;
+
+/**
+ * A temporary resolver that converts a Maven artifact reference
+ * into a {@link java.io.File} object.
+ *
+ * <p>This approach is an interim solution for Maven projects
+ * until the open feature request to add formally add artifacts
+ * to a test (<a href="https://jira.jboss.org/browse/ARQ-66">ARQ-66</a>) is implementated.</p>
+ *
+ * <p>The testCompile goal will resolve any test dependencies and
+ * put them in your local Maven repository. By the time the test
+ * executes, you can be sure that the JAR files you need will be
+ * in your local repository.</p>
+ *
+ * <p>Example usage:</p>
+ *
+ * <pre>
+ * WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
+ * .addLibrary(MavenArtifactResolver.resolve("commons-lang:commons-lang:2.5"));
+ * </pre>
+
+ * <p>If you are using an alternate local Maven repository, you need to pass it
+ * to the Maven surefire plugin using the following stanza in the plugin
+ * configuration element:</p>
+ *
+ * <pre>
+ * <systemProperties>
+ * <property>
+ * <name>maven.repo.local</name>
+ * <value>${maven.repo.local}</value>
+ * </property>
+ * </systemProperties>
+ * </pre>
+ *
+ * <p>Another approach to pull in a library is to add packages recursively from the
+ * root library package.</p>
+ *
+ * @author Dan Allen
+ */
+public class MavenArtifactResolver
+{
+ private static final String LOCAL_MAVEN_REPO_PROPERTY = "maven.repo.local";
+
+ private static final String USER_HOME_PROPERTY = "user.home";
+
+ private static final String LOCAL_MAVEN_REPO =
+ System.getProperty(LOCAL_MAVEN_REPO_PROPERTY) != null ?
+ System.getProperty(LOCAL_MAVEN_REPO_PROPERTY) :
+ (System.getProperty(USER_HOME_PROPERTY) + File.separatorChar +
+ ".m2" + File.separatorChar + "repository");
+
+ public static File resolve(final String groupId, final String artifactId, final String version)
+ {
+ return resolve(groupId, artifactId, version, null);
+ }
+
+ public static File resolve(final String groupId, final String artifactId,
+ final String version, final String classifier)
+ {
+ return new File(LOCAL_MAVEN_REPO + File.separatorChar +
+ groupId.replace(".", File.separator) + File.separatorChar +
+ artifactId + File.separatorChar +
+ version + File.separatorChar +
+ artifactId + "-" + version +
+ (classifier != null ? ("-" + classifier) : "") + ".jar");
+ }
+
+ public static File resolve(final String qualifiedArtifactId)
+ {
+ String[] segments = qualifiedArtifactId.split(":");
+ if (segments.length == 3)
+ {
+ return resolve(segments[0], segments[1], segments[2]);
+ }
+ else if (segments.length == 4)
+ {
+ return resolve(segments[0], segments[1], segments[2], segments[3]);
+ }
+ throw new IllegalArgumentException("Invalid format for qualified artifactId: " + qualifiedArtifactId);
+ }
+
+ public static File[] resolve(final String... qualifiedArtifactIds)
+ {
+ int n = qualifiedArtifactIds.length;
+ File[] artifacts = new File[n];
+ for (int i = 0; i < n; i++)
+ {
+ artifacts[i] = resolve(qualifiedArtifactIds[i]);
+ }
+
+ return artifacts;
+ }
+}
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1 @@
+applicationPackage.patch.arquillian.testenricher.cdi.support.CDIInjectionSupportDeploymentAppender
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/META-INF/services/org.jboss.arquillian.spi.DeploymentPackager 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1 @@
+applicationPackage.patch.arquillian.protocol.servlet_2_5.ServletProtocolDeploymentPackager
\ No newline at end of file
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/arquillian.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/arquillian.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/arquillian.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<arquillian xmlns="http://jboss.com/arquillian"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jbossas-remote="urn:arq:applicationPackage.patch.arquillian.container.jbossas.remote_5_1">
+
+ <!-- Uncomment to have test archives exported to the file system for inspection -->
+ <engine>
+ <deploymentExportPath>target/</deploymentExportPath>
+ </engine>
+
+ <jbossas-remote:container>
+ <!-- uncomment and update to specify the port on which JBoss EAP is running -->
+ <!--
+ <jbossas-remote:remoteServerHttpPort>8080</jbossas-remote:remoteServerHttpPort>
+ -->
+ <!-- required when deploying EARs containing bean archives -->
+ <jbossas-remote:deployExploded>true</jbossas-remote:deployExploded>
+ </jbossas-remote:container>
+
+</arquillian>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/auxiliary-web.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/auxiliary-web.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/auxiliary-web.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,16 @@
+<?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
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+ <servlet>
+ <servlet-name>ServletTestRunner</servlet-name>
+ <servlet-class>applicationPackage.patch.arquillian.protocol.servlet_2_5.ServletTestRunner</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ServletTestRunner</servlet-name>
+ <url-pattern>/ArquillianServletRunner</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/test-transaction-interceptor-beans.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/test-transaction-interceptor-beans.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/test-transaction-interceptor-beans.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,10 @@
+<?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">
+ <interceptors>
+ <class>applicationPackage.transaction.TransactionInterceptor</class>
+ </interceptors>
+</beans>
\ No newline at end of file
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/test-web.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/test-web.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/test-web.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,15 @@
+<?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
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+ <listener>
+ <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
+ </listener>
+
+ <listener>
+ <listener-class>applicationPackage.patch.weld.environment.servlet.BeanManagerResourceBindingListener</listener-class>
+ </listener>
+</web-app>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/weld.tld
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/weld.tld (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources/weld.tld 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<taglib 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/web-jsptaglibrary_2_0.xsd"
+ version="2.0">
+ <description>
+ A shell tag library that registers a listener to bootstrap Weld in a Servlet or pre-Java EE 6 environment
+ </description>
+ <tlib-version>1.0</tlib-version>
+ <short-name>w</short-name>
+ <uri>http://jboss.org/weld</uri>
+
+ <!--
+ Bootstraps the runtime environment of the CDI Reference Implementation (Weld)
+ -->
+ <listener>
+ <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
+ </listener>
+
+ <!--
+ Binds the Weld BeanManager as a naming resource (JNDI)
+ -->
+ <listener>
+ <listener-class>applicationPackage.patch.weld.environment.servlet.BeanManagerResourceBindingListener</listener-class>
+ </listener>
+
+</taglib>
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1 @@
+applicationPackage.patch.arquillian.container.jbossas.remote_5_1.JBossASDeploymentAppender
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1 @@
+applicationPackage.patch.arquillian.container.jbossas.remote_5_1.JBossASConfiguration
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.DeployableContainer (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-remote/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1 @@
+applicationPackage.patch.arquillian.container.jbossas.remote_5_1.JBossASRemoteContainer
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/jndi.properties
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/jndi.properties (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/jndi.properties 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=jnp://localhost:1099
Added: archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/test-persistence.xml
===================================================================
--- archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/test-persistence.xml (rev 0)
+++ archetypes/eap51-weld-jsf-webapp/trunk/src/test/resources-jbossas-shared/test-persistence.xml 2010-10-12 19:12:50 UTC (rev 7026)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="primary">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <!-- Properties for Hibernate (default provider for JBoss AS) -->
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <property name="hibernate.format_sql" value="false"/>
+ <property name="jboss.entity.manager.factory.jndi.name" value="java:/primaryEntityManagerFactory"/>
+ </properties>
+ </persistence-unit>
+</persistence>
More information about the weld-commits
mailing list