-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now with fixes for some of the issues identified by Pete Muir in the pull request.
- Loading branch information
Showing
16 changed files
with
642 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 |
---|---|---|
|
@@ -16,3 +16,4 @@ bin | |
/helloworld-jsp | ||
README.html | ||
CONTRIBUTING.html | ||
.errai |
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,73 @@ | ||
helloworld-errai: Hello World Using the Errai Framework | ||
======================================================= | ||
|
||
What is it? | ||
----------- | ||
|
||
This example demonstrates the use of *CDI 1.0* and *JAX-RS* in *JBoss AS 7* with a GWT front-end client. | ||
GWT is basically a typesafe, statically checked programming model for producing HTML5+CSS3+JavaScript | ||
front-ends. In this example, we use RESTful services on the backend. The client communicates with the | ||
backend using stubs that are generated based on the JAX-RS resources when the application is compiled. | ||
|
||
You can test the REST endpoint at the URL http://localhost:8080/jboss-as-helloworld-errai/hello/json/David | ||
|
||
|
||
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. | ||
|
||
NOTE: | ||
This project retrieves artifacts from the JBoss Community Maven repository, a | ||
superset of the Maven central repository. | ||
|
||
With the prerequisites out of the way, you're ready to build and deploy. | ||
|
||
|
||
Deploying the Application | ||
------------------------- | ||
|
||
First you need to start JBoss AS 7. To do this, run | ||
|
||
$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 clean 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-errai.war`. | ||
|
||
The application will be running at the following URL <http://localhost:8080/jboss-as-helloworld-errai/>. | ||
|
||
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. | ||
|
||
|
||
Running the Application in GWT Dev Mode | ||
--------------------------------------- | ||
|
||
GWT Dev Mode provides an edit-save-refresh development experience. If you plan to try | ||
modifying this demo, we recommend you start the application in Dev Mode so you don't | ||
have to repackage the whole application every time you change it. | ||
|
||
Deploy the war file and start JBoss AS 7 as described above. | ||
|
||
Then execute the command: | ||
|
||
mvn gwt:run |
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,186 @@ | ||
<?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-errai</artifactId> | ||
<version>7.0.2-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
<name>JBoss AS Quickstarts: Errai Hello World</name> | ||
|
||
<url>http://jboss.org/jbossas</url> | ||
<licenses> | ||
<license> | ||
<name>Apache License, Version 2.0</name> | ||
<distribution>repo</distribution> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url> | ||
</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> | ||
<dependency> | ||
<groupId>org.jboss.bom</groupId> | ||
<artifactId>jboss-javaee-6.0-with-errai</artifactId> | ||
<version>1.0.0.M4</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
|
||
<!-- 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> | ||
|
||
<!-- Import the Common Annotations API (JSR-250), we use provided scope as the API is included in | ||
JBoss AS 7 --> | ||
<dependency> | ||
<groupId>org.jboss.spec.javax.annotation</groupId> | ||
<artifactId>jboss-annotations-api_1.1_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- GWT --> | ||
<dependency> | ||
<groupId>com.google.gwt</groupId> | ||
<artifactId>gwt-user</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Errai --> | ||
<!-- Project Dependencies --> | ||
|
||
<dependency> | ||
<groupId>org.jboss.errai</groupId> | ||
<artifactId>errai-bus</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.errai</groupId> | ||
<artifactId>errai-ioc</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.errai</groupId> | ||
<artifactId>errai-tools</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.errai</groupId> | ||
<artifactId>errai-jaxrs-client</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.errai</groupId> | ||
<artifactId>errai-jaxrs-provider</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.spec.javax.ws.rs</groupId> | ||
<artifactId>jboss-jaxrs-api_1.1_spec</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> | ||
<!-- Exclude client only classes from the deployment. As these classes compile down to JavaScript, | ||
they are not needed at runtime. They would only introduce runtime dependencies to GWT development libraries. --> | ||
<packagingExcludes>**/client/local/**/*.class</packagingExcludes> | ||
</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> | ||
|
||
<!-- GWT plugin to compile client-side java code to javascript and to run GWT development mode --> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>gwt-maven-plugin</artifactId> | ||
<version>2.4.0</version> | ||
<configuration> | ||
<inplace>true</inplace> | ||
<logLevel>INFO</logLevel> | ||
<extraJvmArgs>-Xmx512m</extraJvmArgs> | ||
<!-- Configure GWT's development mode (formerly known as hosted mode) to not start the default | ||
server (embedded jetty), but to download the HTML host page from the configured runTarget. --> | ||
<noServer>true</noServer> | ||
<runTarget>http://localhost:8080/jboss-as-helloworld-errai/HelloWorldApp.html</runTarget> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>gwt-compile</id> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>gwt-clean</id> | ||
<phase>clean</phase> | ||
<goals> | ||
<goal>clean</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>2.4.1</version> | ||
<configuration> | ||
<filesets> | ||
<fileset> | ||
<directory>${basedir}</directory> | ||
<includes> | ||
<include>www-test/**</include> | ||
<include>.gwt/**</include> | ||
<include>.errai/**</include> | ||
<include>war/WEB-INF/deploy/**</include> | ||
<include>war/WEB-INF/lib/**</include> | ||
<include>src/main/webapp/WEB-INF/deploy/**</include> | ||
<include>**/gwt-unitCache/**</include> | ||
<include>**/*.JUnit/**</include> | ||
</includes> | ||
</fileset> | ||
</filesets> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
14 changes: 14 additions & 0 deletions
14
...oworld-errai/src/main/java/org/jboss/as/quickstarts/erraihelloworld/HelloWorldApp.gwt.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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6//EN" | ||
"http://google-web-toolkit.googlecode.com/svn/releases/1.6/distro-source/core/src/gwt-module.dtd"> | ||
<!-- GWT module definition: the rename-to attribute is used to have a shorter | ||
module name that doesn't reflect the actual package structure. --> | ||
<module rename-to="HelloWorldApp"> | ||
<inherits name="com.google.gwt.user.User" /> | ||
<inherits name="com.google.gwt.http.HTTP" /> | ||
<inherits name="com.google.gwt.json.JSON" /> | ||
|
||
<inherits name="org.jboss.errai.bus.ErraiBus" /> | ||
<inherits name="org.jboss.errai.ioc.Container" /> | ||
<inherits name="org.jboss.errai.enterprise.Jaxrs" /> | ||
</module> |
51 changes: 51 additions & 0 deletions
51
...ai/src/main/java/org/jboss/as/quickstarts/erraihelloworld/client/local/HelloWorldApp.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,51 @@ | ||
package org.jboss.as.quickstarts.erraihelloworld.client.local; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.inject.Inject; | ||
|
||
import org.jboss.as.quickstarts.erraihelloworld.client.shared.HelloWorldResource; | ||
import org.jboss.errai.ioc.client.api.Caller; | ||
import org.jboss.errai.ioc.client.api.EntryPoint; | ||
|
||
import com.google.gwt.user.client.ui.RootPanel; | ||
|
||
/** | ||
* This is the entry point to the client portion of the web application. At | ||
* compile time, Errai finds the {@code @EntryPoint} annotation on this class | ||
* and generates bootstrap code that creates an instance of this class when the | ||
* page loads. This client-side bootstrap code will also call the | ||
* {@link #init()} method because it is annotated with the | ||
* {@code @PostConstruct} CDI annotation. | ||
* | ||
* @author Jonathan Fuerth <jfuerth@redhat.com> | ||
* @author Christian Sadilek <csadilek@redhat.com> | ||
*/ | ||
@EntryPoint | ||
public class HelloWorldApp { | ||
|
||
/** | ||
* Errai's JAX-RS module generates a stub class that makes AJAX calls back to | ||
* the server for each resource method on the {@link HelloWorldResource} | ||
* interface. The paths and HTTP methods for the AJAX calls are determined | ||
* automatically based on the JAX-RS annotations ({@code @Path}, {@code @GET}, | ||
* {@code @POST}, and so on) on the resource. | ||
* <p> | ||
* You can create additional JAX-RS proxies by following the same pattern | ||
* ({@code @Inject Caller<MyResourceType>}) with your own JAX-RS resource | ||
* classes. | ||
*/ | ||
@Inject | ||
private Caller<HelloWorldResource> helloWorldCaller; | ||
|
||
/** | ||
* This method creates an instance of the UiBinder UI {@link HelloWorldClient} | ||
* and attaches it to the RootPanel, the top-level DOM node that is an | ||
* ancestor to all GWT widgets on the page (the {@code <body>} element of the | ||
* HTML document). | ||
*/ | ||
@PostConstruct | ||
public void init() { | ||
RootPanel.get().add(new HelloWorldClient(helloWorldCaller).getElement()); | ||
} | ||
|
||
} |
Oops, something went wrong.