forked from spagop/quickstart
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/jbossas/quickstart
Conflicts: pom.xml
- Loading branch information
Showing
32 changed files
with
358 additions
and
57 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
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
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
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
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
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
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
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
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
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
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
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,51 @@ | ||
jboss-as-helloworld-singleton Example | ||
=============================== | ||
|
||
What is it? | ||
----------- | ||
|
||
This quickstart demonstrates the use of an *EJB 3.1 Singleton Bean* in JBoss AS 7.1.0. | ||
|
||
System requirements | ||
------------------- | ||
|
||
All you need to build this project is Java 6.0 (Java SDK 1.6) or better, Maven | ||
3.0 or better. | ||
|
||
The application this project produces is designed to be run on a JBoss AS 7.1.0 or EAP 6. | ||
|
||
With the prerequisites out of the way, you're ready to build and deploy. | ||
|
||
Deploying the application | ||
------------------------- | ||
|
||
First of all you need to enable the "admin" user from $JBOSS_HOME/standalone/configuration/mgmt-users.properties file, and then start JBoss AS 7 (or EAP 6). To do this, run this script | ||
|
||
$JBOSS_HOME/bin/standalone.sh | ||
|
||
or if you are using windows | ||
|
||
$JBOSS_HOME/bin/standalone.bat | ||
|
||
To deploy the application, you first need to produce the archive to deploy using | ||
the following Maven goal: | ||
|
||
mvn package | ||
|
||
You can now deploy the artifact to JBoss AS by executing the following command: | ||
|
||
mvn jboss-as:deploy | ||
|
||
This will deploy `target/jboss-as-helloworld-singleton.war`. | ||
|
||
The application will be running at the following URL <http://localhost:8080/jboss-as-helloworld-singleton>. | ||
|
||
This example demonstrates a singleton session bean that maintains state information for 2 variables: "Increment A" and "Increment B". A counter is incremented when you click on the link to the variable name. If you close and restart your browser, or if you have multiple browsers, you can see that the counter always increments the last value. These values are maintained until you restart the server. To test the singleton bean, on the home page, click on either "Increment A" or "Increment B". The result page will give you the current value of the variable. | ||
|
||
To undeploy from JBoss AS, run this command: | ||
|
||
mvn jboss-as:undeploy | ||
|
||
You can also start JBoss AS 7 and deploy the project using Eclipse. See the JBoss AS 7 | ||
Getting Started Guide for Developers for more information. | ||
|
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,96 @@ | ||
<?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> | ||
|
||
<groupId>org.jboss.as.quickstarts</groupId> | ||
<artifactId>jboss-as-helloworld-singleton</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>war</packaging> | ||
<name>JBoss AS Quickstarts: Helloworld Singleton Session Bean with JSF 2.0 as client</name> | ||
|
||
<url>http://jboss.org/jbossas</url> | ||
<licenses> | ||
<license> | ||
<name>GNU Lesser General Public License</name> | ||
<url>http://www.gnu.org/copyleft/lesser.html</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<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> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<!-- Define the version of JBoss' Java EE 6 APIs we want to use --> | ||
<!-- JBoss distributes a complete set of Java EE 6 APIs including a Bill | ||
of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection) | ||
of artifacts. We use this here so that we always get the correct versions | ||
of artifacts. Here we use the jboss-javaee-6.0 stack (you can read this as | ||
the JBoss stack of the Java EE 6 APIs). You can actually use this stack with | ||
any version of JBoss AS that implements Java EE 6, not just JBoss AS 7! --> | ||
<dependency> | ||
<groupId>org.jboss.spec</groupId> | ||
<artifactId>jboss-javaee-6.0</artifactId> | ||
<version>3.0.0.Beta1</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<!-- Import the Servlet API, we use provided scope as the API is included | ||
in JBoss EAP 6/JBoss AS 7 --> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.ejb</groupId> | ||
<artifactId>jboss-ejb-api_3.1_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- Import the CDI API, we use provided scope as the API is included in | ||
JBoss AS 7 --> | ||
<dependency> | ||
<groupId>javax.enterprise</groupId> | ||
<artifactId>cdi-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<!-- Set the name of the war, used as the context root when the app is | ||
deployed --> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>2.1.1</version> | ||
<configuration> | ||
<!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! --> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
</configuration> | ||
</plugin> | ||
<!-- JBoss AS plugin to deploy war --> | ||
<plugin> | ||
<groupId>org.jboss.as.plugins</groupId> | ||
<artifactId>jboss-as-maven-plugin</artifactId> | ||
<version>7.1.0.CR1</version> | ||
</plugin> | ||
<!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation | ||
processors --> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.1</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
34 changes: 34 additions & 0 deletions
34
helloworld-singleton/src/main/java/org/jboss/as/quickstarts/singleton/Counter.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,34 @@ | ||
package org.jboss.as.quickstarts.singleton; | ||
|
||
import javax.ejb.Singleton; | ||
import javax.inject.Named; | ||
|
||
/** | ||
* This singleton stores stores two counters which are only reset when the application is restarted. | ||
* | ||
* @author Serge Pagop (spagop@redhat.com) | ||
* | ||
*/ | ||
@Singleton | ||
@Named | ||
public class Counter { | ||
|
||
private int a = 1; | ||
private int b = 1; | ||
|
||
public void incrementA() { | ||
a++; | ||
} | ||
|
||
public void incrementB() { | ||
b++; | ||
} | ||
|
||
public int getA() { | ||
return a; | ||
} | ||
|
||
public int getB() { | ||
return b; | ||
} | ||
} |
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 @@ | ||
<!-- Marker file indicating CDI 1.0 should be enabled --> | ||
|
||
<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> |
11 changes: 11 additions & 0 deletions
11
helloworld-singleton/src/main/webapp/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'?> | ||
<!-- Marker file indicating JSF 2.0 should be enabled in the application --> | ||
|
||
<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"> | ||
|
||
</faces-config> |
Oops, something went wrong.