Skip to content

Commit

Permalink
add translator example
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@542 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Dec 17, 2008
1 parent 4dce478 commit 0f0cd96
Show file tree
Hide file tree
Showing 18 changed files with 599 additions and 8 deletions.
41 changes: 33 additions & 8 deletions examples/build.xml
Expand Up @@ -6,32 +6,57 @@

<property file="${wbri.dir}/build.properties"/>

<property name="type" value="war" />

<condition property="war">
<equals arg1="${type}" arg2="war"/>
</condition>
<condition property="ear">
<equals arg1="${type}" arg2="ear"/>
</condition>

<condition property="artifact.target.dir" value="${basedir}/target">
<equals arg1="${type}" arg2="war"/>
</condition>
<condition property="artifact.target.dir" value="${basedir}/${example.name}-ear/target">
<equals arg1="${type}" arg2="ear"/>
</condition>

<property name="artifact.dir" value="${artifact.target.dir}/${example.name}" />

<target name="package">
<maven target="package" basedir="${basedir}"/>
</target>

<target name="explode" depends="package">
<mkdir dir="${jboss.home}/server/default/deploy/${example.name}.war"/>
<copy todir="${jboss.home}/server/default/deploy/${example.name}.war">
<fileset dir="${basedir}/target/${example.name}" />
<mkdir dir="${jboss.home}/server/default/deploy/${example.name}.${type}"/>
<copy todir="${jboss.home}/server/default/deploy/${example.name}.${type}">
<fileset dir="${artifact.dir}" />
</copy>
</target>

<target name="deploy" depends="package">
<copy todir="${jboss.home}/server/default/deploy/" file="${basedir}/target/${example.name}.war"/>
<copy todir="${jboss.home}/server/default/deploy/" file="${artifact.target.dir}/${example.name}.${type}"/>
</target>

<target name="clean">
<maven target="clean" basedir="${basedir}"/>
</target>

<target name="restart" depends="explode">
<target name="restart.war" depends="explode" if="war">
<touch file="${jboss.home}/server/default/deploy/${example.name}.war/WEB-INF/web.xml" />
</target>

<target name="restart.ear" depends="explode" if="ear">
<touch file="${jboss.home}/server/default/deploy/${example.name}.ear/META-INF/application.xml" />
</target>

<target name="restart" depends="restart.war, restart.ear">
</target>

<target name="undeploy">
<delete dir="${jboss.home}/server/default/deploy/${example.name}.war" failonerror="false" />
<delete file="${jboss.home}/server/default/deploy/${example.name}.war" failonerror="false" />
<delete dir="${jboss.home}/server/default/deploy/${example.name}.${type}" failonerror="false" />
<delete file="${jboss.home}/server/default/deploy/${example.name}.${type}" failonerror="false" />
</target>

<macrodef name="maven">
Expand All @@ -56,4 +81,4 @@
</sequential>
</macrodef>

</project>
</project>
9 changes: 9 additions & 0 deletions examples/pom.xml
Expand Up @@ -19,6 +19,7 @@

<modules>
<module>numberguess</module>
<module>translator</module>
</modules>

<build>
Expand All @@ -31,7 +32,15 @@
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>

</pluginManagement>
</build>

Expand Down
8 changes: 8 additions & 0 deletions examples/translator/build.xml
@@ -0,0 +1,8 @@
<project basedir="." name="Numberguess Example Build" default="restart">

<property name="example.name" value="webbeans-translator" />
<property name="type" value="ear" />

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

</project>
57 changes: 57 additions & 0 deletions examples/translator/pom.xml
@@ -0,0 +1,57 @@
<?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>
<parent>
<groupId>org.jboss.webbeans.examples</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<name>Web Beans Examples: Translator (parent)</name>

<description>
Ear Example for the reference implementation of JSR 299: Web Beans
</description>

<modules>
<module>webbeans-translator-war</module>
<module>webbeans-translator-ejb</module>
<module>webbeans-translator-ear</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>webbeans-translator-war</artifactId>
<version>${webbeans.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>webbeans-translator-ear</artifactId>
<version>${webbeans.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>webbeans-translator-ejb</artifactId>
<version>${webbeans.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>

</plugins>
</pluginManagement>
</build>

</project>

82 changes: 82 additions & 0 deletions examples/translator/webbeans-translator-ear/pom.xml
@@ -0,0 +1,82 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<groupId>org.jboss.webbeans.examples</groupId>
<artifactId>webbeans-translator-ear</artifactId>
<packaging>ear</packaging>
<name>Web Beans Examples: Translator (ear)</name>

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

<dependencies>

<dependency>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>webbeans-translator-ejb</artifactId>
<type>ejb</type>
</dependency>

<dependency>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>webbeans-translator-war</artifactId>
<type>war</type>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>

<!-- <dependency>
<groupId>org.jboss.el</groupId>
<artifactId>jboss-el</artifactId>
<exclusions>
<exclusion>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</exclusion>
</exclusions>
</dependency>-->

</dependencies>

<build>
<finalName>webbeans-translator</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<modules>
<webModule>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>webbeans-translator-war</artifactId>
<contextRoot>/webbeans-translator</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>

</project>

Empty file.
55 changes: 55 additions & 0 deletions examples/translator/webbeans-translator-ejb/pom.xml
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<groupId>org.jboss.webbeans.examples.translator</groupId>
<artifactId>webbeans-translator-ejb</artifactId>
<packaging>ejb</packaging>
<name>Web Beans Examples: Translator (ejb)</name>

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

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>

<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>webbeans-api</artifactId>
<scope>provided</scope>
</dependency>

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

</dependencies>

<build>
<finalName>webbeans-translator</finalName>
</build>

</project>

@@ -0,0 +1,82 @@
package org.jboss.webbeans.examples.numberguess;


import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.webbeans.Initializer;
import javax.webbeans.Named;
import javax.webbeans.SessionScoped;

@Named
@SessionScoped
public class Game
{
private int number;

private int guess;
private int smallest;
private int biggest;
private int remainingGuesses;

public Game()
{
}

@Initializer
Game(@Random int number, @MaxNumber int maxNumber)
{
this.number = number;
this.smallest = 1;
this.biggest = maxNumber;
this.remainingGuesses = 10;
}

public int getNumber()
{
return number;
}

public int getGuess()
{
return guess;
}

public void setGuess(int guess)
{
this.guess = guess;
}

public int getSmallest()
{
return smallest;
}

public int getBiggest()
{
return biggest;
}

public int getRemainingGuesses()
{
return remainingGuesses;
}

public String check()
{
if (guess>number)
{
biggest = guess - 1;
}
if (guess<number)
{
smallest = guess + 1;
}
if (guess == number)
{
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Correct!"));
}
remainingGuesses--;
return null;
}

}

0 comments on commit 0f0cd96

Please sign in to comment.