Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?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> | ||
<jboss> | ||
<loader-repository>webbeans.jboss.org:loader=webbeans-translator</loader-repository> | ||
</jboss> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.ejb</groupId> | ||
<artifactId>ejb-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<finalName>webbeans-translator</finalName> | ||
</build> | ||
|
||
</project> | ||
|
14 changes: 14 additions & 0 deletions
14
...s-translator-ejb/src/main/java/org/jboss/webbeans/examples/translator/SentenceParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jboss.webbeans.examples.translator; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class SentenceParser | ||
{ | ||
|
||
public List<String> parse(String text) | ||
{ | ||
return Arrays.asList( text.split("[.?]") ); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...anslator-ejb/src/main/java/org/jboss/webbeans/examples/translator/SentenceTranslator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jboss.webbeans.examples.translator; | ||
|
||
import javax.ejb.Stateless; | ||
|
||
@Stateless | ||
public class SentenceTranslator implements Translator | ||
{ | ||
|
||
public String translate(String sentence) | ||
{ | ||
return "Lorem ipsum dolor sit amet"; | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...s-translator-ejb/src/main/java/org/jboss/webbeans/examples/translator/TextTranslator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.jboss.webbeans.examples.translator; | ||
|
||
import javax.webbeans.Initializer; | ||
|
||
public class TextTranslator | ||
{ | ||
private SentenceParser sentenceParser; | ||
private Translator sentenceTranslator; | ||
|
||
@Initializer | ||
TextTranslator(SentenceParser sentenceParser, Translator sentenceTranslator) | ||
{ | ||
this.sentenceParser = sentenceParser; | ||
this.sentenceTranslator = sentenceTranslator; | ||
} | ||
|
||
public String translate(String text) | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
for (String sentence: sentenceParser.parse(text)) | ||
{ | ||
sb.append(sentenceTranslator.translate(sentence)).append(". "); | ||
} | ||
return sb.toString().trim(); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...beans-translator-ejb/src/main/java/org/jboss/webbeans/examples/translator/Translator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.jboss.webbeans.examples.translator; | ||
|
||
import javax.ejb.Local; | ||
|
||
@Local | ||
public interface Translator | ||
{ | ||
|
||
public String translate(String sentence); | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...slator-ejb/src/main/java/org/jboss/webbeans/examples/translator/TranslatorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.jboss.webbeans.examples.translator; | ||
|
||
public interface TranslatorController | ||
{ | ||
|
||
public String getText(); | ||
|
||
public void setText(String text); | ||
|
||
public void translate(); | ||
|
||
public String getTranslatedText(); | ||
|
||
public void remove(); | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...or-ejb/src/main/java/org/jboss/webbeans/examples/translator/TranslatorControllerBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.jboss.webbeans.examples.translator; | ||
|
||
import javax.ejb.Remove; | ||
import javax.ejb.Stateful; | ||
import javax.webbeans.Current; | ||
import javax.webbeans.Named; | ||
import javax.webbeans.RequestScoped; | ||
|
||
@Stateful | ||
@RequestScoped | ||
@Named("translator") | ||
public class TranslatorControllerBean implements TranslatorController | ||
{ | ||
|
||
@Current TextTranslator translator; | ||
|
||
private String inputText; | ||
|
||
private String translatedText; | ||
|
||
public String getText() | ||
{ | ||
return inputText; | ||
} | ||
|
||
public void setText(String text) | ||
{ | ||
this.inputText = text; | ||
} | ||
|
||
public void translate() | ||
{ | ||
translatedText = translator.translate(inputText); | ||
} | ||
|
||
public String getTranslatedText() | ||
{ | ||
return translatedText; | ||
} | ||
|
||
@Remove | ||
public void remove() | ||
{ | ||
|
||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
translator/webbeans-translator-ejb/src/main/resources/META-INF/ejb-jar.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ejb-jar 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/ejb-jar_3_0.xsd" | ||
version="3.0"> | ||
|
||
<interceptors> | ||
<interceptor> | ||
<interceptor-class>org.jboss.webbeans.ejb.SessionBeanInterceptor</interceptor-class> | ||
</interceptor> | ||
</interceptors> | ||
|
||
<assembly-descriptor> | ||
<interceptor-binding> | ||
<ejb-name>*</ejb-name> | ||
<interceptor-class>org.jboss.webbeans.ejb.SessionBeanInterceptor</interceptor-class> | ||
</interceptor-binding> | ||
</assembly-descriptor> | ||
|
||
</ejb-jar> |
Empty file.
11 changes: 11 additions & 0 deletions
11
translator/webbeans-translator-war/WebContent/WEB-INF/faces-config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?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> | ||
|
||
</faces-config> |
Oops, something went wrong.