An example of services to act as a backend for distributed TodoMVC implementations, written in Java EE 6 using JBoss AS 7.1.1.Final.
Has been tested in JBoss 7.1.1.Final in OS X 10.7.4.
If the webapp is deployed in a local JBoss instance, it's RESTful service URL is: http://localhost:8080/todomvc-services-javaee6/todos
It implements the following:
- Get all records & can optionally filter with ?owner=some_value
- Get/push/put/delete a single record
Currently, it is setup to circumvent same origin policy using a CORSFilter based on this this example, but specifies Access-Control-Allow-Headers as "x-requested-with". If using this for non-public/authenticated use, you can remove the cors package and the filter+filter-mapping from its web.xml.
Example collection (note: owner is optional):
[{"id":1,"title":"this is a test","completed":false,"owner":"guest"},{"id":2,"title":"this is a test","completed":false,"owner":"guest"}]
Assuming using JBoss 7.1.1.Final, it stores values in the default H2 in-memory database with jndi name: java:jboss/datasources/ExampleDS. The JNDI name, etc. can be changed in src/main/java/resources/META-INF/persistence.xml.
- Install Java (if necessary).
- Install Maven 3
- Install JBoss AS 7.1.1
In a separate terminal window, do:
cd jboss-as-7.1.1.Final/bin
./standalone.sh
It might help to add an administrative user to be able to check that the war deployed, etc. In a separate terminal window, do:
cd jboss-as-7.1.1.Final/bin
./add-user.sh
mvn clean install
cp target/todomvc-services-javaee6.war jboss-as-7.1.1.Final/standalone/deployments/
For those with *nix, can test via curl with:
./test.sh
(Currently, that test script requires visual validation, and isn't removing all tasks it creates, due to an issue with the test script that I've not had time to fix.)
Copyright (c) 2012 Gary S. Weaver, released under the MIT license.