Skip to content

Commit

Permalink
Merging 1.0.0.M3b from aerogear/as-quickstarts
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Oliveira committed Apr 25, 2012
1 parent 8957cd7 commit 5534381
Show file tree
Hide file tree
Showing 29 changed files with 988 additions and 11,054 deletions.
2 changes: 1 addition & 1 deletion helloworld-html5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.jboss.as.quickstarts</groupId>
<artifactId>jboss-as-helloworld-html5</artifactId>
<version>1.0.0-M2c</version>
<version>1.0.0.M3b</version>
<packaging>war</packaging>
<name>JBoss AS Quickstarts: POH5 Helloworld</name>

Expand Down
12 changes: 12 additions & 0 deletions kitchensink-html5-mobile/.settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="js/libs/*" kind="src" path="src/main/webapp"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
13 changes: 11 additions & 2 deletions kitchensink-html5-mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,18 @@ references to minification and comment or uncomment the appropriate lines.

Finally, wro4j runs in the compile phase so any standard build command like package,
install, etc. will trigger it. The plugin is in a profile with an id of "minify" so
you will want to specify that profile in your maven build. For example:
you will want to specify that profile in your maven build.

mvn clean package jboss-as:deploy -Pminify
NOTE: You must either specify the default profile for no tests or the arquillian test
profile to run tests when minifying to avoid test errors. For example:

#No Tests
mvn clean package jboss-as:deploy -Pminify,default

OR

#With Tests
mvn clean package jboss-as:deploy -Pminify,arq-jbossas-remote

Running the Arquillian tests
============================
Expand Down
89 changes: 8 additions & 81 deletions kitchensink-html5-mobile/SERVICES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kitchensink-html5-mobile: JAX-RS Services Documentation
=======================================================
Author: Jay Balunas
Author: Jay Balunas, Marius Bogoevici

This example supports various RESTFul end points which also includes JSONP support for cross domain requests.

Expand All @@ -12,30 +12,6 @@ MemberService End Points
### List all members
#### /rest/members

* Request type: GET
* Return type: XML
* Response example:

```xml
<?xml version="1.0" encoding="UTF-8"standalone="yes"?>
<collection>
<member>
<email>[email protected]</email>
<id>1</id>
<name>Jane Smith</name>
<phoneNumber>2125551212</phoneNumber>
</member>
<member>
<email>[email protected]</email>
<id>0</id>
<name>John Smith</name>
<phoneNumber>2125551212</phoneNumber>
</member>
</collection>
```

#### /rest/members/json

* Request type: GET
* Return type: JSON
* Response example:
Expand All @@ -44,14 +20,18 @@ MemberService End Points
[{"id":1,"name":"Jane Smith","email":"[email protected]","phoneNumber":"2125551212"},{"id":0,"name":"John Smith","email":"[email protected]","phoneNumber":"2125551212"}]
```

### Create a new members
### Create a new member

#### /rest/members

* Request type: POST
* Request type: application/x-www-form-urlencoded
* Request parameters: name, email, phoneNumber
* Request type: JSON
* Return type: JSON
* Request example:

```JavaScript
[{"name":"Jane Smith","email":"[email protected]","phoneNumber":"4160000000"}]

* Response example:
* Success: 200 OK
* Validation error: Collection of `<field name>:<error msg>` for each error
Expand All @@ -60,64 +40,11 @@ MemberService End Points
{"phoneNumber":"10-12 Numbers","email":"Invalid format"}
```

#### /rest/members/new?name=&email=&phoneNumber=
* Request type: GET
* Query parameters: name, email, phoneNumber
* Return type: JSON
* Response example: See POST example above
* Note: JSONP requests do not support error responses

### Get one member by ID

#### /rest/members/\<id>
* Request type: GET
* Return type: XML
* Response example:

```xml
<?xml version="1.0" encoding="UTF-8"standalone="yes"?>
<member>
<email>[email protected]</email>
<id>0</id>
<name>John Smith</name>
<phoneNumber>2125551212</phoneNumber>
</member>
```

#### /rest/members/\<id>/json
* Request type: GET
* Return type: JSON
* Response example:

```javascript
{"id":0,"name":"John Smith","email":"[email protected]","phoneNumber":"2125551212"}
```

JSONP Support
-------------

[JSONP](http://en.wikipedia.org/wiki/JSONP) is a technique for allowing cross domain requests from services. It pads (what the "P" stands for) the service response with a JavaScript callback function that can then access the data on the client.

In order for a request to be padded the following things must be true:

* The request is one of the GET JSON request from above
* POST requests are not support for JSONP requests
* A query parameter named *jsonpcallback* is defined
* The value of this parameter is the method that will be defined in the padding

For example:

http://\<domain:port>/jboss-as-kitchensink-html5-mobile/rest/members/json?jsonpcallback=mycallback

See jQuery's documentation for client access examples:

* http://api.jquery.com/jQuery.getJSON/
* http://api.jquery.com/jQuery.ajax/

__Validation Error Handling__

When using JSONP requests error responses are not supported. This is a known issue with JSONP, and has to do with how JSONP requests are sent to the server using \<script> tags. In the case of a validation issue, or error the success callback will not be thrown, and most client libraries (specifically jquery) will not be able to call the error callback either. There are some workarounds and options, but typically they are limited. See your specific client library for more information.

__Security Considerations__

Before using JSONP in your system be aware of some potential security issues that are possible. There are two primary concerns, cross-site request forgery, and script tag manipulation. This example show one way to add a layer of security, by only processing JSONP requests with "safe" characters, it makes it more difficult for a site to injects harmful scripts into the return. You should always consider this and other aspects of security when exposing services in this way. See the [JSON wiki](http://en.wikipedia.org/wiki/JSONP) for more information.
134 changes: 64 additions & 70 deletions kitchensink-html5-mobile/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.jboss.as.quickstarts</groupId>
<artifactId>jboss-as-kitchensink-html5-mobile</artifactId>
<version>1.0.0-M2c</version>
<version>1.0.0.M3b</version>
<packaging>war</packaging>

<name>JBoss AS Quickstarts: AeroGear HTML5/Mobile</name>
Expand All @@ -17,14 +17,13 @@
<!-- [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>

<!-- Timestamp format for the maven.build.timestamp property -->
<!-- You can reference property in pom.xml or filtered resources (must enable third-party plugin if using Maven < 2.1) -->

<!-- Define the version of JBoss' Java EE 6 APIs we want to import. Any dependencies from org.jboss.spec will have their
version defined by this BOM -->
<javaee6.web.spec.version>2.0.0.Final</javaee6.web.spec.version>
<!-- JBoss EAP Certified Versions -->
<!-- <javaee6.web.spec.version>3.0.0.Final-redhat-1</javaee6.web.spec.version> -->
<!-- <javaee6.web.spec.version>3.0.0.Beta1-redhat-1</javaee6.web.spec.version> -->
<!-- <version.org.hibernate.validator>4.2.0.Final-redhat-1</version.org.hibernate.validator> -->

<wro4j.version>1.4.4</wro4j.version>
Expand Down Expand Up @@ -176,7 +175,7 @@
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<version>2.2</version>
<configuration>
<!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
Expand All @@ -187,7 +186,7 @@
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.1.1.Final</version>
<version>7.1.0.Final</version>
</plugin>

<plugin>
Expand Down Expand Up @@ -245,7 +244,7 @@
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<version>2.2</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
<warName>ROOT</warName>
Expand Down Expand Up @@ -279,9 +278,7 @@
<artifactId>
wro4j-maven-plugin
</artifactId>
<versionRange>
[1.4.4,)
</versionRange>
<version>1.4.4</version>
<goals>
<goal>run</goal>
</goals>
Expand Down Expand Up @@ -310,7 +307,7 @@
</execution>
</executions>
<configuration>
<targetGroups>app.min,m.screen.min,screen.min</targetGroups>
<targetGroups>app.min,m.screen.min,d.screen.min</targetGroups>
<cssDestinationFolder>${project.build.directory}/${project.build.finalName}/css/</cssDestinationFolder>
<jsDestinationFolder>${project.build.directory}/${project.build.finalName}/js/</jsDestinationFolder>
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
Expand All @@ -320,36 +317,6 @@
</build>
</profile>
<profile>
<!-- We add the JBoss repository as we need the JBoss AS connectors for Arquillian -->
<repositories>
<!-- The JBoss Community public repository is a composite repository of several major repositories -->
<!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users -->
<repository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
<!-- These optional flags are designed to speed up your builds by reducing remote server calls -->
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<!-- An optional Arquillian testing profile that executes tests in your JBoss AS instance -->
<!-- This profile will start a new JBoss AS instance, and execute the test, shutting it down when done -->
<!-- Run with: mvn clean test -Parq-jbossas-managed -->
Expand All @@ -358,42 +325,13 @@
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.1.0.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

<profile>
<!-- We add the JBoss repository as we need the JBoss AS connectors for Arquillian -->
<repositories>
<!-- The JBoss Community public repository is a composite repository of several major repositories -->
<!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users -->
<repository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
<!-- These optional flags are designed to speed up your builds by reducing remote server calls -->
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
<releases>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<!-- An optional Arquillian testing profile that executes tests in a remote JBoss AS instance -->
<!-- Run with: mvn clean test -Parq-jbossas-remote -->
<id>arq-jbossas-remote</id>
Expand All @@ -406,6 +344,62 @@
</dependency>
</dependencies>
</profile>

<profile>
<id>aerogearci-jbossas-managed-7</id>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>${version.org.jboss.as.arquillian.container}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemProperties>
<arquillian.launch>jbossci</arquillian.launch>
<arquillian.jboss_home>${project.build.directory}/jboss-as-${version.org.jboss.as.arquillian.container}/
</arquillian.jboss_home>
</systemProperties>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-as7</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-dist</artifactId>
<version>7.1.1.Final</version>
<outputDirectory>${project.build.directory}</outputDirectory>
<type>zip</type>
<overWrite>false</overWrite>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Loading

0 comments on commit 5534381

Please sign in to comment.