Skip to content

Commit

Permalink
initial merge of servlet-numberguess and numberguess
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Sep 22, 2009
1 parent 8046a55 commit 1d4d85f
Show file tree
Hide file tree
Showing 21 changed files with 293 additions and 576 deletions.
12 changes: 6 additions & 6 deletions build.xml
Expand Up @@ -37,6 +37,12 @@
</maven>
</target>

<target name="clean">
<maven target="clean" basedir="${basedir}">
<arg line="-f ${pom.file}" />
</maven>
</target>

<target name="explode" depends="package">
<mkdir dir="${jboss.home}/server/default/deploy/${example.name}.${type}" />
<copy todir="${jboss.home}/server/default/deploy/${example.name}.${type}">
Expand All @@ -61,12 +67,6 @@
<echo message="The app can be accessed at ${final.url}" />
</target>

<target name="clean">
<maven target="clean" basedir="${basedir}">
<arg line="-f ${pom.file}" />
</maven>
</target>

<target name="restart.war" depends="explode" if="war">
<touch file="${jboss.home}/server/default/deploy/${example.name}.war/WEB-INF/web.xml" />
</target>
Expand Down
12 changes: 12 additions & 0 deletions jsf/numberguess/build.xml
Expand Up @@ -4,4 +4,16 @@

<import file="../../build.xml" />

<target name="package">
<maven target="install" basedir="${basedir}">
<arg line="-Pjboss5" />
</maven>
</target>

<target name="clean">
<maven target="clean" basedir="${basedir}">
<arg line="-Pjboss5" />
</maven>
</target>

</project>
235 changes: 223 additions & 12 deletions jsf/numberguess/pom.xml
Expand Up @@ -11,19 +11,21 @@
<groupId>org.jboss.webbeans.examples.jsf</groupId>
<artifactId>webbeans-jsf-numberguess</artifactId>
<packaging>war</packaging>
<name>Web Beans Examples: Numberguess for JBoss AS 5.x</name>
<name>Web Beans Examples: Numberguess</name>

<pluginRepositories>
<pluginRepository>
<id>codehaus snapshot repository</id>
<url>http://snapshots.repository.codehaus.org/</url>
<id>codehaus repository</id>
<url>http://repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>

<!-- Common dependencies only -->
<dependencies>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand All @@ -36,35 +38,244 @@
<artifactId>jsr299-api</artifactId>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>

<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<scope>provided</scope>
</dependency>


</dependencies>

<profiles>
<profile>
<id>jboss5</id>
<dependencies>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<scope>provided</scope>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp-jboss5</directory>
<filtering>false</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>tomcat</id>
<dependencies>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>

<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</dependency>

<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.jboss.webbeans.servlet</groupId>
<artifactId>webbeans-servlet</artifactId>
<scope>runtime</scope>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp-tomcat</directory>
<filtering>false</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jetty</id>
<dependencies>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>

<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</dependency>

<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.jboss.webbeans.servlet</groupId>
<artifactId>webbeans-servlet</artifactId>
<scope>runtime</scope>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp-jetty</directory>
<filtering>false</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<finalName>webbeans-numberguess</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceExcludes>WEB-INF/classes/**,WEB-INF/lib/**</warSourceExcludes>
</configuration>
</plugin>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<failOnError>false</failOnError>
<filesets>
<fileset>
<!-- clean up files from war:inplace -->
<directory>WebContent</directory>
<includes>
<include>WEB-INF/classes/**</include>
<include>WEB-INF/lib/**</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<path>/${project.build.finalName}</path>
<!-- uncomment to use server configuration override; see readme.txt for details -->
<!--<server>tomcat</server>-->
<url>http://localhost:${tomcat.http.port}/manager</url>
<port>${embedded-tomcat.http.port}</port> <!-- port for embedded Tomcat only (putting this configuration in the execution for the run goal doesn't work) -->
<!-- if you don't want to use war:inplace, use this path instead -->
<!--
<warSourceDirectory>${project.build.directory}/${project.build.finalName}</warSourceDirectory>
-->
</configuration>
</plugin>

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>${jetty.http.port}</port>
<maxIdleTime>3600000</maxIdleTime>
</connector>
</connectors>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/${project.build.finalName}</contextPath>
</webAppConfig>
<!-- if you don't want to use war:inplace, use this path instead -->
<!--
<webAppSourceDirectory>${project.build.directory}/${project.build.finalName}</webAppSourceDirectory>
-->
</configuration>
</plugin>

<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>maven-cli-plugin</artifactId>
<configuration>
<userAliases>
<runjetty>compile org.apache.maven.plugins:maven-war-plugin:inplace org.mortbay.jetty:maven-jetty-plugin:run</runjetty>
<runtomcat>compile org.apache.maven.plugins:maven-war-plugin:inplace org.codehaus.mojo:tomcat-maven-plugin:run</runtomcat>
<explode>compile org.apache.maven.plugins:maven-war-plugin:inplace -o</explode>
</userAliases>
</configuration>
</plugin>

</plugins>
</build>

<properties>
<jetty.http.port>9090</jetty.http.port>
<jetty.debug.port>9190</jetty.debug.port>
<tomcat.http.port>8080</tomcat.http.port>
<embedded-tomcat.http.port>9090</embedded-tomcat.http.port>
<embedded-tomcat.debug.port>9190</embedded-tomcat.debug.port>
</properties>

</project>

33 changes: 13 additions & 20 deletions jsf/numberguess/readme.txt
Expand Up @@ -2,8 +2,9 @@ Web Beans Numberguess Example (Servlet Container)
=================================================

This example demonstrates the use of Web Beans in a Servlet container
environment (Tomcat 6 / Jetty 6) and in JBoss AS. No alterations are expected to be made to the
Servlet container. All services are self-contained within the deployment.
environment (Tomcat 6 / Jetty 6) and in JBoss AS. No alterations are
expected to be made to the Servlet container. All services are
self-contained within the deployment.

This example uses a Maven 2 build. Execute the following command to build the
WAR. The WAR will will be located in the target directory after completion of
Expand All @@ -17,19 +18,19 @@ Now you're ready to deploy.

Run this command to execute the application in an embedded Jetty 6 container:

mvn war:inplace jetty:run
mvn war:inplace jetty:run -Pjetty

You can also execute the application in an embedded Tomcat 6 container:

mvn war:inplace tomcat:run
mvn war:inplace tomcat:run -Ptomcat

In both cases, any changes to assets in WebContent take affect immediately. If
In both cases, any changes to assets in src/main/webapp take affect immediately. If
a change to a webapp configuration file is made, the application may
automatically redeploy. The redeploy behavior can be fined tuned in the plugin
configuration (at least for Jetty). If you make a change to a classpath
resource, you need to execute a build:

mvn compile war:inplace
mvn compile war:inplace {-Ptomcat,-Pjetty}

Note that war:inplace copies the compiled classes and JARs inside WebContent,
under WEB-INF/classes and WEB-INF/lib, respectively, mixing source and compiled
Expand All @@ -52,26 +53,18 @@ Maven 2 settings.xml file, set the <username> and <password> elements to the
appropriate values and uncomment the <server> element inside the
tomcat-maven-plugin configuration in the pom.xml.

You can deploy the packaged archive to Tomcat via HTTP PUT using this command:

mvn package tomcat:deploy

Then you use this command to undeploy the application:

mvn tomcat:undeploy

Instead of packaging the WAR, you can deploy it as an exploded archive
You can deploy it as an exploded archive
immediately after the war goal is finished assembling the exploded structure:

mvn compile war:exploded tomcat:exploded
mvn compile war:exploded tomcat:exploded -Ptomcat

Once the application is deployed, you can redeploy it using the following command:

mvn tomcat:redeploy
mvn tomcat:redeploy -Ptomcat

But likely you want to run one or more build goals first before you redeploy:

mvn compile tomcat:redeploy
mvn war:exploded tomcat:redeploy
mvn compile war:exploded tomcat:redeploy
mvn compile tomcat:redeploy -Ptomcat
mvn war:exploded tomcat:redeploy -Ptomcat
mvn compile war:exploded tomcat:redeploy -Ptomcat

0 comments on commit 1d4d85f

Please sign in to comment.