Ravi Srinivasan
2018-09-10 f04579d422790bfed81c843f093a58f15cd8eb2d
Chap 3 labs
26 files added
943 ■■■■■ changed files
labs/stateless-ejb/.gitignore 5 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/README.md 7 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/pom.xml 137 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/java/com/redhat/training/ejb/HelloBean.java 11 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/java/com/redhat/training/ui/Hello.java 35 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/webapp/WEB-INF/beans.xml 25 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/webapp/WEB-INF/faces-config.xml 30 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/webapp/WEB-INF/templates/default.xhtml 34 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/webapp/index.html 23 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/webapp/index.xhtml 32 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/webapp/resources/css/screen.css 79 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/src/main/webapp/resources/images/redhat.png patch | view | raw | blame | history
labs/stateless-ejb/src/test/java/com/redhat/training/ejb/EJBTest.java 52 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/.gitignore 5 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/README.md 7 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/pom.xml 137 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/java/com/redhat/training/ejb/HelloBean.java 14 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/java/com/redhat/training/ui/Hello.java 35 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/webapp/WEB-INF/beans.xml 25 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/webapp/WEB-INF/faces-config.xml 30 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/webapp/WEB-INF/templates/default.xhtml 34 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/webapp/index.html 23 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/webapp/index.xhtml 32 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/webapp/resources/css/screen.css 79 ●●●●● patch | view | raw | blame | history
solutions/stateless-ejb/src/main/webapp/resources/images/redhat.png patch | view | raw | blame | history
solutions/stateless-ejb/src/test/java/com/redhat/training/ejb/EJBTest.java 52 ●●●●● patch | view | raw | blame | history
labs/stateless-ejb/.gitignore
New file
@@ -0,0 +1,5 @@
.classpath
.project
.tern-project
.settings
target
labs/stateless-ejb/README.md
New file
@@ -0,0 +1,7 @@
# JB125 Java EE 7 Hello World web App
##This app is composed of the following architecture:
* Maven Project - builds a WAR
* Using JSF 2.2 for web interface, HTML5 facelets page, JSF backing beans, CDI scopes on beans, @Named
* Stateless EJB for Business Logic (sayHello)
labs/stateless-ejb/pom.xml
New file
@@ -0,0 +1,137 @@
<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>
  <artifactId>stateless-ejb</artifactId>
  <packaging>war</packaging>
  <name>Stateless EJB web app Project</name>
  <description>This is the Stateless EJB project</description>
  <parent>
      <groupId>com.redhat.training</groupId>
      <artifactId>parent-pom</artifactId>
      <version>1.0</version>
      <relativePath>../pom.xml</relativePath>
  </parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
    <dependencies>
        <!-- First declare the APIs we depend on and need for compilation. All
            of them are provided by JBoss EAP -->
        <!-- Import the CDI API, we use provided scope as the API is included in
            JBoss EAP -->
         <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Import the EJB API, we use provided scope as the API is included in
            JBoss EAP -->
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Import the JSF API, we use provided scope as the API is included in
            JBoss EAP -->
        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>
         <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-servlet</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Need to explicitly reference this version, or else there will be an exception
        due to a bug in Arquilian -->
        <dependency>
            <groupId>org.wildfly.arquillian</groupId>
            <artifactId>wildfly-arquillian-common</artifactId>
            <version>2.0.0.Final</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>stateless-ejb</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>${version.war.plugin}</version>
                <extensions>false</extensions>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifestEntries>
                            <Dependencies>com.google.guava,org.slf4j
                            </Dependencies>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <!-- This profile skips all tests, though you can tune
                it to run just unit tests based on a custom pattern -->
            <!-- Separate profiles are provided for running all tests, including
                Arquillian tests that execute in the specified container -->
           <!-- Use this profile if you just want to build a WAR file without running any unit tests -->
           <!-- Run like this:  mvn clean package -Pdefault -->
            <id>default</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${version.surefire.plugin}</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- An optional Arquillian testing profile that
                executes tests in a remote JBoss EAP instance -->
            <!-- Run with: mvn clean test -Parq-wildfly-remote or, simply run: mvn test -->
            <!-- To make it easy to run tests from within JBDS, this profile is set as active by default -->
            <id>arq-wildfly-remote</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly.arquillian</groupId>
                    <artifactId>wildfly-arquillian-container-remote</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
labs/stateless-ejb/src/main/java/com/redhat/training/ejb/HelloBean.java
New file
@@ -0,0 +1,11 @@
package com.redhat.training.ejb;
public class HelloBean {
    public String sayHello(String name) {
    // respond back with Hello, {name}.
    return "Hello, " + name;
    }
}
labs/stateless-ejb/src/main/java/com/redhat/training/ui/Hello.java
New file
@@ -0,0 +1,35 @@
package com.redhat.training.ui;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import com.redhat.training.ejb.HelloBean;
@RequestScoped
@Named("hello")
public class Hello {
    private String name;
    @EJB
    HelloBean helloEJB;
    public String greet() {
        return helloEJB.sayHello(name);
    }
    public void sayHello() {
        String response = greet();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(response));
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
labs/stateless-ejb/src/main/webapp/WEB-INF/beans.xml
New file
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
    JBoss, Home of Professional Open Source
    Copyright 2014, Red Hat, Inc. and/or its affiliates, 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.
-->
<!-- This file can be an empty text file (0 bytes) -->
<!-- We're declaring the schema to save you time if you do have to configure
    this in the future -->
<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">
</beans>
labs/stateless-ejb/src/main/webapp/WEB-INF/faces-config.xml
New file
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
    JBoss, Home of Professional Open Source
    Copyright 2014, Red Hat, Inc. and/or its affiliates, 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.
-->
<!-- This file is not required if you don't need any extra configuration. -->
<faces-config version="2.0" 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_2_0.xsd">
    <!-- This descriptor activates the JSF 2.0 Servlet -->
    <!-- Write your navigation rules here. You are encouraged to use CDI
        for creating @Named managed beans. -->
</faces-config>
labs/stateless-ejb/src/main/webapp/WEB-INF/templates/default.xhtml
New file
@@ -0,0 +1,34 @@
<!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">
<h:head>
    <title><ui:insert name="title">
                    [Title will be inserted here]
         </ui:insert>
    </title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <h:outputStylesheet name="css/screen.css" />
</h:head>
<h:body>
    <header>
        <h:graphicImage name="images/redhat.png" />
        <div class="right">
            Application:
            <ui:insert name="application_name">
                    [Application name will be inserted here]
         </ui:insert>
        </div>
    </header>
    <div id="content">
         <ui:insert name="content">
                    [Template content will be inserted here]
         </ui:insert>
    </div>
    <footer>
    JB183 - Enterprise Java Development - Red Hat Training
    </footer>
</h:body>
</html>
labs/stateless-ejb/src/main/webapp/index.html
New file
@@ -0,0 +1,23 @@
<!--
    JBoss, Home of Professional Open Source
    Copyright 2014, Red Hat, Inc. and/or its affiliates, 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.
-->
<!-- Plain HTML page that kicks us into the app -->
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=index.jsf">
</head>
</html>
labs/stateless-ejb/src/main/webapp/index.xhtml
New file
@@ -0,0 +1,32 @@
<?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="title">
    Hello World web app
    </ui:define>
    <ui:define name="application_name">
        Hello EJB web app
    </ui:define>
    <ui:define name="content">
        <h1>Hello EJB web app</h1>
        <br class="clear"/>
        <h:form id="form">
            <p class="input">
                <h:outputLabel value="Enter your name:" for="name" />
                <h:inputText value="#{hello.name}" id="name" required="true" requiredMessage="Name is required"/>
            </p>
            <br class="clear"/>
            <br class="clear"/>
            <p class="input">
                <h:commandButton action="#{hello.sayHello()}"  value="Submit" styleClass="btn" />
            </p>
            <br class="clear"/>
            <br class="clear"/>
            <h:messages styleClass="messages"/>
        </h:form>
    </ui:define>
</ui:composition>
labs/stateless-ejb/src/main/webapp/resources/css/screen.css
New file
@@ -0,0 +1,79 @@
body {
}
header {
    background-color: #C40016;
    height: 150px;
    padding: 10px;
    width: 95%;
    margin: 0 auto;
    border: 4px solid #000000;
}
header .right {
    display: inline-block;
    float: right;
    font-size: 40px;
    font-weight: bolder;
    height: 150px;
    padding: 48px;
    vertical-align: middle;
}
#content {
    background-color: #F2F2F2;
    width: 91%;
    margin: 0 auto;
    padding: 100px 50px;
    border: 2px solid #000000;
}
footer {
    border: 4px solid #000000;
    background-color: #C40016;
    height: 30px;
    padding: 10px;
    width: 95%;
    margin: 0 auto;
    text-align: center;
    font-weight: bolder;
    font-size: 27px;
}
label{
    display: inline-block;
    float: left;
    clear: left;
    width: 165px;
}
input {
  display: inline-block;
  float: left;
  width: 362px;
}
select{
    display: inline-block;
      float: left;
      width: 371px;
}
textarea{
    display: inline-block;
      float: left;
}
.clear{
    clear: both;
}
.messages{
    color: green;
    font-weight: bolder;
}
.btn{
    display: inline-block;
    float: left;
    clear: left;
    width: 165px;
}
labs/stateless-ejb/src/main/webapp/resources/images/redhat.png
labs/stateless-ejb/src/test/java/com/redhat/training/ejb/EJBTest.java
New file
@@ -0,0 +1,52 @@
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2015, Red Hat, Inc. and/or its affiliates, 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 com.redhat.training.ejb;
import static org.junit.Assert.assertEquals;
import javax.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
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 com.redhat.training.ui.Hello;
@RunWith(Arquillian.class)
public class EJBTest {
    @Inject
    private Hello hello;
    @Deployment
    public static WebArchive createDeployment() {
        return ShrinkWrap.create(WebArchive.class,"stateless-ejb-test.war").addClass(HelloBean.class).addClass(Hello.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
    }
    @Test
    public void testHelloEJB() {
            hello.setName("John Doe");
        String result = hello.greet();
        assertEquals("Hello, John Doe", result);
    }
}
solutions/stateless-ejb/.gitignore
New file
@@ -0,0 +1,5 @@
.classpath
.project
.tern-project
.settings
target
solutions/stateless-ejb/README.md
New file
@@ -0,0 +1,7 @@
# JB125 Java EE 7 Hello World web App
##This app is composed of the following architecture:
* Maven Project - builds a WAR
* Using JSF 2.2 for web interface, HTML5 facelets page, JSF backing beans, CDI scopes on beans, @Named
* Stateless EJB for Business Logic (sayHello)
solutions/stateless-ejb/pom.xml
New file
@@ -0,0 +1,137 @@
<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>
  <artifactId>stateless-ejb-solution</artifactId>
  <packaging>war</packaging>
  <name>Stateless EJB web app Project</name>
  <description>This is the Stateless EJB project</description>
  <parent>
      <groupId>com.redhat.training</groupId>
      <artifactId>parent-pom</artifactId>
      <version>1.0</version>
      <relativePath>../pom.xml</relativePath>
  </parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
    <dependencies>
        <!-- First declare the APIs we depend on and need for compilation. All
            of them are provided by JBoss EAP -->
        <!-- Import the CDI API, we use provided scope as the API is included in
            JBoss EAP -->
         <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Import the EJB API, we use provided scope as the API is included in
            JBoss EAP -->
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Import the JSF API, we use provided scope as the API is included in
            JBoss EAP -->
        <dependency>
            <groupId>org.jboss.spec.javax.faces</groupId>
            <artifactId>jboss-jsf-api_2.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>
         <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-servlet</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Need to explicitly reference this version, or else there will be an exception
        due to a bug in Arquilian -->
        <dependency>
            <groupId>org.wildfly.arquillian</groupId>
            <artifactId>wildfly-arquillian-common</artifactId>
            <version>2.0.0.Final</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>stateless-ejb</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>${version.war.plugin}</version>
                <extensions>false</extensions>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifestEntries>
                            <Dependencies>com.google.guava,org.slf4j
                            </Dependencies>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <!-- This profile skips all tests, though you can tune
                it to run just unit tests based on a custom pattern -->
            <!-- Separate profiles are provided for running all tests, including
                Arquillian tests that execute in the specified container -->
           <!-- Use this profile if you just want to build a WAR file without running any unit tests -->
           <!-- Run like this:  mvn clean package -Pdefault -->
            <id>default</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${version.surefire.plugin}</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- An optional Arquillian testing profile that
                executes tests in a remote JBoss EAP instance -->
            <!-- Run with: mvn clean test -Parq-wildfly-remote or, simply run: mvn test -->
            <!-- To make it easy to run tests from within JBDS, this profile is set as active by default -->
            <id>arq-wildfly-remote</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly.arquillian</groupId>
                    <artifactId>wildfly-arquillian-container-remote</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
solutions/stateless-ejb/src/main/java/com/redhat/training/ejb/HelloBean.java
New file
@@ -0,0 +1,14 @@
package com.redhat.training.ejb;
import javax.ejb.Stateless;
@Stateless
public class HelloBean {
    public String sayHello(String name) {
    // respond back with Hello, {name}.
    return "Hello, " + name;
    }
}
solutions/stateless-ejb/src/main/java/com/redhat/training/ui/Hello.java
New file
@@ -0,0 +1,35 @@
package com.redhat.training.ui;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import com.redhat.training.ejb.HelloBean;
@RequestScoped
@Named("hello")
public class Hello {
    private String name;
    @EJB
    HelloBean helloEJB;
    public String greet() {
        return helloEJB.sayHello(name);
    }
    public void sayHello() {
        String response = greet();
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(response));
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
solutions/stateless-ejb/src/main/webapp/WEB-INF/beans.xml
New file
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
    JBoss, Home of Professional Open Source
    Copyright 2014, Red Hat, Inc. and/or its affiliates, 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.
-->
<!-- This file can be an empty text file (0 bytes) -->
<!-- We're declaring the schema to save you time if you do have to configure
    this in the future -->
<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">
</beans>
solutions/stateless-ejb/src/main/webapp/WEB-INF/faces-config.xml
New file
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
    JBoss, Home of Professional Open Source
    Copyright 2014, Red Hat, Inc. and/or its affiliates, 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.
-->
<!-- This file is not required if you don't need any extra configuration. -->
<faces-config version="2.0" 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_2_0.xsd">
    <!-- This descriptor activates the JSF 2.0 Servlet -->
    <!-- Write your navigation rules here. You are encouraged to use CDI
        for creating @Named managed beans. -->
</faces-config>
solutions/stateless-ejb/src/main/webapp/WEB-INF/templates/default.xhtml
New file
@@ -0,0 +1,34 @@
<!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">
<h:head>
    <title><ui:insert name="title">
                    [Title will be inserted here]
         </ui:insert>
    </title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <h:outputStylesheet name="css/screen.css" />
</h:head>
<h:body>
    <header>
        <h:graphicImage name="images/redhat.png" />
        <div class="right">
            Application:
            <ui:insert name="application_name">
                    [Application name will be inserted here]
         </ui:insert>
        </div>
    </header>
    <div id="content">
         <ui:insert name="content">
                    [Template content will be inserted here]
         </ui:insert>
    </div>
    <footer>
    JB183 - Enterprise Java Development - Red Hat Training
    </footer>
</h:body>
</html>
solutions/stateless-ejb/src/main/webapp/index.html
New file
@@ -0,0 +1,23 @@
<!--
    JBoss, Home of Professional Open Source
    Copyright 2014, Red Hat, Inc. and/or its affiliates, 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.
-->
<!-- Plain HTML page that kicks us into the app -->
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=index.jsf">
</head>
</html>
solutions/stateless-ejb/src/main/webapp/index.xhtml
New file
@@ -0,0 +1,32 @@
<?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="title">
    Hello World web app
    </ui:define>
    <ui:define name="application_name">
        Hello EJB web app
    </ui:define>
    <ui:define name="content">
        <h1>Hello EJB web app</h1>
        <br class="clear"/>
        <h:form id="form">
            <p class="input">
                <h:outputLabel value="Enter your name:" for="name" />
                <h:inputText value="#{hello.name}" id="name" required="true" requiredMessage="Name is required"/>
            </p>
            <br class="clear"/>
            <br class="clear"/>
            <p class="input">
                <h:commandButton action="#{hello.sayHello()}"  value="Submit" styleClass="btn" />
            </p>
            <br class="clear"/>
            <br class="clear"/>
            <h:messages styleClass="messages"/>
        </h:form>
    </ui:define>
</ui:composition>
solutions/stateless-ejb/src/main/webapp/resources/css/screen.css
New file
@@ -0,0 +1,79 @@
body {
}
header {
    background-color: #C40016;
    height: 150px;
    padding: 10px;
    width: 95%;
    margin: 0 auto;
    border: 4px solid #000000;
}
header .right {
    display: inline-block;
    float: right;
    font-size: 40px;
    font-weight: bolder;
    height: 150px;
    padding: 48px;
    vertical-align: middle;
}
#content {
    background-color: #F2F2F2;
    width: 91%;
    margin: 0 auto;
    padding: 100px 50px;
    border: 2px solid #000000;
}
footer {
    border: 4px solid #000000;
    background-color: #C40016;
    height: 30px;
    padding: 10px;
    width: 95%;
    margin: 0 auto;
    text-align: center;
    font-weight: bolder;
    font-size: 27px;
}
label{
    display: inline-block;
    float: left;
    clear: left;
    width: 165px;
}
input {
  display: inline-block;
  float: left;
  width: 362px;
}
select{
    display: inline-block;
      float: left;
      width: 371px;
}
textarea{
    display: inline-block;
      float: left;
}
.clear{
    clear: both;
}
.messages{
    color: green;
    font-weight: bolder;
}
.btn{
    display: inline-block;
    float: left;
    clear: left;
    width: 165px;
}
solutions/stateless-ejb/src/main/webapp/resources/images/redhat.png
solutions/stateless-ejb/src/test/java/com/redhat/training/ejb/EJBTest.java
New file
@@ -0,0 +1,52 @@
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2015, Red Hat, Inc. and/or its affiliates, 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 com.redhat.training.ejb;
import static org.junit.Assert.assertEquals;
import javax.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
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 com.redhat.training.ui.Hello;
@RunWith(Arquillian.class)
public class EJBTest {
    @Inject
    private Hello hello;
    @Deployment
    public static WebArchive createDeployment() {
        return ShrinkWrap.create(WebArchive.class,"stateless-ejb-test.war").addClass(HelloBean.class).addClass(Hello.class)
            .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
    }
    @Test
    public void testHelloEJB() {
            hello.setName("John Doe");
        String result = hello.greet();
        assertEquals("Hello, John Doe", result);
    }
}