You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/11/09 16:57:48 UTC

svn commit: r1407511 - in /openejb/trunk/openejb/examples: ./ rest-xml-json/ rest-xml-json/src/ rest-xml-json/src/main/ rest-xml-json/src/main/java/ rest-xml-json/src/main/java/org/ rest-xml-json/src/main/java/org/superbiz/ rest-xml-json/src/main/java/...

Author: rmannibucau
Date: Fri Nov  9 15:57:46 2012
New Revision: 1407511

URL: http://svn.apache.org/viewvc?rev=1407511&view=rev
Log:
more rest examples

Added:
    openejb/trunk/openejb/examples/rest-xml-json/
    openejb/trunk/openejb/examples/rest-xml-json/README.md
    openejb/trunk/openejb/examples/rest-xml-json/pom.xml
    openejb/trunk/openejb/examples/rest-xml-json/src/
    openejb/trunk/openejb/examples/rest-xml-json/src/main/
    openejb/trunk/openejb/examples/rest-xml-json/src/main/java/
    openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/
    openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/
    openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/
    openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/GreetingService.java
    openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Request.java
    openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Response.java
    openejb/trunk/openejb/examples/rest-xml-json/src/test/
    openejb/trunk/openejb/examples/rest-xml-json/src/test/java/
    openejb/trunk/openejb/examples/rest-xml-json/src/test/java/org/
    openejb/trunk/openejb/examples/rest-xml-json/src/test/java/org/superbiz/
    openejb/trunk/openejb/examples/rest-xml-json/src/test/java/org/superbiz/rest/
    openejb/trunk/openejb/examples/rest-xml-json/src/test/java/org/superbiz/rest/GreetingServiceTest.java
    openejb/trunk/openejb/examples/simple-rest/
    openejb/trunk/openejb/examples/simple-rest/README.md
    openejb/trunk/openejb/examples/simple-rest/pom.xml
    openejb/trunk/openejb/examples/simple-rest/src/
    openejb/trunk/openejb/examples/simple-rest/src/main/
    openejb/trunk/openejb/examples/simple-rest/src/main/java/
    openejb/trunk/openejb/examples/simple-rest/src/main/java/org/
    openejb/trunk/openejb/examples/simple-rest/src/main/java/org/superbiz/
    openejb/trunk/openejb/examples/simple-rest/src/main/java/org/superbiz/rest/
    openejb/trunk/openejb/examples/simple-rest/src/main/java/org/superbiz/rest/GreetingService.java
    openejb/trunk/openejb/examples/simple-rest/src/test/
    openejb/trunk/openejb/examples/simple-rest/src/test/java/
    openejb/trunk/openejb/examples/simple-rest/src/test/java/org/
    openejb/trunk/openejb/examples/simple-rest/src/test/java/org/superbiz/
    openejb/trunk/openejb/examples/simple-rest/src/test/java/org/superbiz/rest/
    openejb/trunk/openejb/examples/simple-rest/src/test/java/org/superbiz/rest/GreetingServiceTest.java
Modified:
    openejb/trunk/openejb/examples/index.md
    openejb/trunk/openejb/examples/pom.xml

Modified: openejb/trunk/openejb/examples/index.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/index.md?rev=1407511&r1=1407510&r2=1407511&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/index.md (original)
+++ openejb/trunk/openejb/examples/index.md Fri Nov  9 15:57:46 2012
@@ -69,9 +69,11 @@ All the examples show code, but some are
 {span-one-third
 ### REST
 
- - [rest-example-with-application](rest-example-with-application/README.html)
+ - [simple-rest](simple-rest/README.html)
  - [rest-example](rest-example/README.html)
+ - [rest-example-with-application](rest-example-with-application/README.html)
  - [rest-on-ejb](rest-on-ejb/README.html)
+ - [rest-xml-json](rest-example/README.html)
 }
 
 {span-one-third

Modified: openejb/trunk/openejb/examples/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/pom.xml?rev=1407511&r1=1407510&r2=1407511&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/pom.xml (original)
+++ openejb/trunk/openejb/examples/pom.xml Fri Nov  9 15:57:46 2012
@@ -38,16 +38,17 @@
     <module>async-methods</module>
     <module>bean-validation-design-by-contract</module>
     <module>cdi-alternative-and-stereotypes</module>
+    <module>cdi-application-scope</module>
     <module>cdi-basic</module>
     <module>cdi-ejbcontext-jaas</module>
     <module>cdi-events</module>
     <module>cdi-interceptors</module>
-    <module>cdi-request-scope</module>
-    <module>cdi-application-scope</module>
     <module>cdi-produces-disposes</module>
     <module>cdi-produces-field</module>
     <module>cdi-query</module>
     <module>cdi-realm</module>
+    <module>cdi-request-scope</module>
+    <module>cdi-session-scope</module>
     <module>change-jaxws-url</module>
     <module>component-interfaces</module>
     <module>client-resource-lookup-preview</module>
@@ -103,6 +104,7 @@
     <module>rest-on-ejb</module>
     <module>rest-example</module>
     <module>rest-example-with-application</module>
+    <module>rest-xml-json</module>
     <module>scala-basic</module>
     <module>schedule-expression</module>
     <module>schedule-events</module>
@@ -115,6 +117,7 @@
     <module>simple-mdb</module>
     <module>simple-mdb-with-descriptor</module>
     <module>simple-osgi</module>
+    <module>simple-rest</module>
     <module>simple-singleton</module>
     <module>simple-stateful</module>
     <module>simple-stateful-callbacks</module>
@@ -122,6 +125,7 @@
     <module>simple-stateless-callbacks</module>
     <module>simple-stateless-with-descriptor</module>
     <module>simple-webservice</module>
+    <module>simple-webservice-without-interface</module>
     <module>spring-data-proxy</module>
     <module>spring-data-proxy-meta</module>
     <module>struts</module>

Added: openejb/trunk/openejb/examples/rest-xml-json/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/rest-xml-json/README.md?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/rest-xml-json/README.md (added)
+++ openejb/trunk/openejb/examples/rest-xml-json/README.md Fri Nov  9 15:57:46 2012
@@ -0,0 +1,373 @@
+Title: Simple REST
+
+Defining a REST service is pretty easy, simply ad @Path annotation to a class then define on methods
+the HTTP method to use (@GET, @POST, ...).
+
+#The Code
+
+## The REST service: @Path, @Produces, @Consumes
+
+Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.
+
+Actually lines:
+
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+
+are optional since it is the default configuration. And these lines can be configured by method too
+if you need to be more precise.
+
+    @Path("/greeting")
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public class GreetingService {
+        @GET
+        public Response message() {
+            return new Response("Hi REST!");
+        }
+    
+        @POST
+        public Response lowerCase(final Request message) {
+            return new Response(message.getValue().toLowerCase());
+        }
+    }
+
+# Testing
+
+## Test for the JAXRS service
+
+The test uses the OpenEJB ApplicationComposer to make it trivial.
+
+The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.
+
+Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.
+
+Finally to test it we use cxf client API to call the REST service in get() and post() methods.
+
+Side note: to show we use JSON or XML depending on the test method we activated on EnableServices the attribute httpDebug
+which prints the http messages in the logs.
+
+    package org.superbiz.rest;
+    
+    import org.apache.cxf.jaxrs.client.WebClient;
+    import org.apache.openejb.jee.WebApp;
+    import org.apache.openejb.junit.ApplicationComposer;
+    import org.apache.openejb.junit.Classes;
+    import org.apache.openejb.junit.EnableServices;
+    import org.apache.openejb.junit.Module;
+    import org.junit.Test;
+    import org.junit.runner.RunWith;
+    
+    import javax.ws.rs.core.MediaType;
+    import java.io.IOException;
+    
+    import static org.junit.Assert.assertEquals;
+    
+    @EnableServices(value = "jaxrs", httpDebug = true)
+    @RunWith(ApplicationComposer.class)
+    public class GreetingServiceTest {
+        @Module
+        @Classes(GreetingService.class)
+        public WebApp app() {
+            return new WebApp().contextRoot("test");
+        }
+    
+        @Test
+        public void getXml() throws IOException {
+            final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+                    .accept(MediaType.APPLICATION_XML_TYPE)
+                    .get(Response.class).getValue();
+            assertEquals("Hi REST!", message);
+        }
+    
+        @Test
+        public void postXml() throws IOException {
+            final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+                    .accept(MediaType.APPLICATION_XML_TYPE)
+                    .post(new Request("Hi REST!"), Response.class).getValue();
+            assertEquals("hi rest!", message);
+        }
+    
+        @Test
+        public void getJson() throws IOException {
+            final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+                    .accept(MediaType.APPLICATION_JSON_TYPE)
+                    .get(Response.class).getValue();
+            assertEquals("Hi REST!", message);
+        }
+    
+        @Test
+        public void postJson() throws IOException {
+            final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+                    .accept(MediaType.APPLICATION_JSON_TYPE)
+                    .post(new Request("Hi REST!"), Response.class).getValue();
+            assertEquals("hi rest!", message);
+        }
+    }
+
+
+#Running
+
+Running the example is fairly simple. In the "rest-xml-json" directory run:
+
+    $ mvn clean install
+
+Which should create output like the following.
+
+    /opt/softs/java/jdk1.6.0_30/bin/java -ea -Didea.launcher.port=7534 -Didea.launcher.bin.path=/opt/softs/idea/bin -Dfile.encoding=UTF-8 -classpath /opt/softs/idea/lib/idea_rt.jar:/opt/softs/idea/plugins/junit/lib/junit-rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/plugin.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/javaws.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jce.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/charsets.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/resources.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/deploy.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/management-agent.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jsse.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/localedata.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunjce_provider.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunpkcs11.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/dnsns.jar:/opt/dev/openejb/openejb-trunk/examples/rest-xml-json/target/test-classes:/opt/dev/openejb/openejb-trunk/examples
 /rest-xml-json/target/classes:/home/rmannibucau/.m2/repository/org/apache/openejb/javaee-api/6.0-4/javaee-api-6.0-4.jar:/home/rmannibucau/.m2/repository/junit/junit/4.10/junit-4.10.jar:/home/rmannibucau/.m2/repository/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-rs/4.5.1-SNAPSHOT/openejb-cxf-rs-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-http/4.5.1-SNAPSHOT/openejb-http-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-core/4.5.1-SNAPSHOT/openejb-core-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/mbean-annotation-api/4.5.1-SNAPSHOT/mbean-annotation-api-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jpa-integration/4.5.1-SNAPSHOT/openejb-jpa-integration-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar:/home/rmannibucau/.m2/re
 pository/org/apache/openejb/openejb-api/4.5.1-SNAPSHOT/openejb-api-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-loader/4.5.1-SNAPSHOT/openejb-loader-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-javaagent/4.5.1-SNAPSHOT/openejb-javaagent-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jee/4.5.1-SNAPSHOT/openejb-jee-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.13/jaxb-impl-2.1.13.jar:/home/rmannibucau/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-ra/5.7.0/activemq-ra-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-core/5.7.0/activemq-core-5.7.0.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/kahadb/5.7.0/kahadb-5.7.0.jar:/home/rmannibucau/.m2/repository/o
 rg/apache/activemq/protobuf/activemq-protobuf/1.1/activemq-protobuf-1.1.jar:/home/rmannibucau/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/rmannibucau/.m2/repository/commons-net/commons-net/3.1/commons-net-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-connector/3.1.1/geronimo-connector-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-transaction/3.1.1/geronimo-transaction-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-connector_1.6_spec/1.0/geronimo-j2ee-connector_1.6_spec-1.0.jar:/home/rmannibucau/.m2/repository/org/objectweb/howl/howl/1.0.1-1/howl-1.0.1-1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.8.2/geronimo-javamail_1.4_mail-1.8.2.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-asm-shaded/3.12/xbean-asm-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xb
 ean/xbean-finder-shaded/3.12/xbean-finder-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-reflect/3.12/xbean-reflect-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-naming/3.12/xbean-naming-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-bundleutils/3.12/xbean-bundleutils-3.12.jar:/home/rmannibucau/.m2/repository/org/hsqldb/hsqldb/2.2.8/hsqldb-2.2.8.jar:/home/rmannibucau/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:/home/rmannibucau/.m2/repository/commons-pool/commons-pool/1.5.7/commons-pool-1.5.7.jar:/home/rmannibucau/.m2/repository/org/codehaus/swizzle/swizzle-stream/1.6.1/swizzle-stream-1.6.1.jar:/home/rmannibucau/.m2/repository/wsdl4j/wsdl4j/1.6.2/wsdl4j-1.6.2.jar:/home/rmannibucau/.m2/repository/org/quartz-scheduler/quartz/2.1.6/quartz-2.1.6.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-jdk14/1.7.2/slf4j-jdk14-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbe
 ans-impl/1.1.6/openwebbeans-impl-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-spi/1.1.6/openwebbeans-spi-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ejb/1.1.6/openwebbeans-ejb-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee/1.1.6/openwebbeans-ee-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee-common/1.1.6/openwebbeans-ee-common-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-web/1.1.6/openwebbeans-web-1.1.6.jar:/home/rmannibucau/.m2/repository/org/javassist/javassist/3.15.0-GA/javassist-3.15.0-GA.jar:/home/rmannibucau/.m2/repository/org/apache/openjpa/openjpa/2.2.0/openjpa-2.2.0.jar:/home/rmannibucau/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/home/rmannibucau/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/rmannibucau/.m2/repository/
 net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar:/home/rmannibucau/.m2/repository/asm/asm/3.2/asm-3.2.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-core/0.5/bval-core-0.5.jar:/home/rmannibucau/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-core-1.8.3.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-jsr303/0.5/bval-jsr303-0.5.jar:/home/rmannibucau/.m2/repository/org/fusesource/jansi/jansi/1.8/jansi-1.8.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-server/4.5.1-SNAPSHOT/openejb-server-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-client/4.5.1-SNAPSHOT/openejb-client-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-ejbd/4.5.1-SNAPSHOT/openejb-ejbd-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-rest/4.5.1-SNAPSHOT/openejb-rest-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-transp
 ort/4.5.1-SNAPSHOT/openejb-cxf-transport-4.5.1-SNAPSHOT.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-transports-http/2.7.0/cxf-rt-transports-http-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-api/2.7.0/cxf-api-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/ws/xmlschema/xmlschema-core/2.0.3/xmlschema-core-2.0.3.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-core/2.7.0/cxf-rt-core-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-frontend-jaxrs/2.7.0/cxf-rt-frontend-jaxrs-2.7.0.jar:/home/rmannibucau/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0-m10/javax.ws.rs-api-2.0-m10.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-bindings-xml/2.7.0/cxf-rt-bindings-xml-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-providers/2.7.0/cxf-rt-rs-extension-providers-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-search/2.7.0/cxf-rt-rs-extension-search-2.7.0.j
 ar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-cors/2.7.0/cxf-rt-rs-security-cors-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-oauth2/2.7.0/cxf-rt-rs-security-oauth2-2.7.0.jar:/home/rmannibucau/.m2/repository/org/codehaus/jettison/jettison/1.3/jettison-1.3.jar:/home/rmannibucau/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 org.superbiz.rest.GreetingServiceTest
+    INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
+    INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+    INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+    INFO - Creating TransactionManager(id=Default Transaction Manager)
+    INFO - Creating SecurityService(id=Default Security Service)
+    INFO - Initializing network services
+    INFO - Creating ServerService(id=httpejbd)
+    INFO - Using 'print=true'
+    INFO - Using 'indent.xml=true'
+    INFO - Creating ServerService(id=cxf-rs)
+    INFO - Initializing network services
+    INFO - Starting service httpejbd
+    INFO - Started service httpejbd
+    INFO - Starting service cxf-rs
+    INFO - Started service cxf-rs
+    INFO -   ** Bound Services **
+    INFO -   NAME                 IP              PORT  
+    INFO -   httpejbd             127.0.0.1       4204  
+    INFO - -------
+    INFO - Ready!
+    INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+    INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: Container(type=MANAGED, id=Default Managed Container)
+    INFO - Creating Container(id=Default Managed Container)
+    INFO - Using directory /tmp for stateful session passivation
+    INFO - Enterprise application "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+    INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Existing thread singleton service in SystemInstance() null
+    INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+    INFO - Succeeded in installing singleton service
+    INFO - OpenWebBeans Container is starting...
+    INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+    INFO - All injection points are validated successfully.
+    INFO - OpenWebBeans Container has started, it took 102 ms.
+    INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+    INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+    INFO - REST Service: http://127.0.0.1:4204/test/greeting/.*  -> Pojo org.superbiz.rest.GreetingService
+    FINE - ******************* REQUEST ******************
+    GET http://localhost:4204/test/greeting/
+    Host=localhost:4204
+    User-Agent=Apache CXF 2.7.0
+    Connection=keep-alive
+    Accept=application/xml
+    Content-Type=*/*
+    Pragma=no-cache
+    Cache-Control=no-cache
+    
+    
+    **********************************************
+    
+    FINE - HTTP/1.1 200 OK
+    Date: Fri, 09 Nov 2012 11:59:00 GMT
+    Content-Length: 44
+    Set-Cookie: EJBSESSIONID=fc5037fa-641c-495d-95ca-0755cfa50beb; Path=/
+    Content-Type: application/xml
+    Connection: close
+    Server: OpenEJB/4.5.1-SNAPSHOT Linux/3.2.0-23-generic (amd64)
+    
+    <response><value>Hi REST!</value></response>
+    INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Stopping network services
+    INFO - Stopping server services
+    INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
+    INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+    INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+    INFO - Creating TransactionManager(id=Default Transaction Manager)
+    INFO - Creating SecurityService(id=Default Security Service)
+    INFO - Initializing network services
+    INFO - Creating ServerService(id=httpejbd)
+    INFO - Using 'print=true'
+    INFO - Using 'indent.xml=true'
+    INFO - Creating ServerService(id=cxf-rs)
+    INFO - Initializing network services
+    INFO - Starting service httpejbd
+    INFO - Started service httpejbd
+    INFO - Starting service cxf-rs
+    INFO - Started service cxf-rs
+    INFO -   ** Bound Services **
+    INFO -   NAME                 IP              PORT  
+    INFO -   httpejbd             127.0.0.1       4204  
+    INFO - -------
+    INFO - Ready!
+    INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+    INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: Container(type=MANAGED, id=Default Managed Container)
+    INFO - Creating Container(id=Default Managed Container)
+    INFO - Using directory /tmp for stateful session passivation
+    INFO - Enterprise application "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+    INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Existing thread singleton service in SystemInstance() null
+    INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+    INFO - Succeeded in installing singleton service
+    INFO - OpenWebBeans Container is starting...
+    INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+    INFO - All injection points are validated successfully.
+    INFO - OpenWebBeans Container has started, it took 11 ms.
+    INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+    INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+    INFO - REST Service: http://127.0.0.1:4204/test/greeting/.*  -> Pojo org.superbiz.rest.GreetingService
+    FINE - ******************* REQUEST ******************
+    POST http://localhost:4204/test/greeting/
+    Host=localhost:4204
+    Content-Length=97
+    User-Agent=Apache CXF 2.7.0
+    Connection=keep-alive
+    Accept=application/xml
+    Content-Type=application/xml
+    Pragma=no-cache
+    Cache-Control=no-cache
+    
+    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+    **********************************************
+    
+    FINE - HTTP/1.1 200 OK
+    Date: Fri, 09 Nov 2012 11:59:00 GMT
+    Content-Length: 44
+    Set-Cookie: EJBSESSIONID=7cb2246d-5738-4a85-aac5-c0fb5340d36a; Path=/
+    Content-Type: application/xml
+    Connection: close
+    Server: OpenEJB/4.5.1-SNAPSHOT Linux/3.2.0-23-generic (amd64)
+    
+    <response><value>hi rest!</value></response>
+    INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Stopping network services
+    INFO - Stopping server services
+    INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
+    INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+    INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+    INFO - Creating TransactionManager(id=Default Transaction Manager)
+    INFO - Creating SecurityService(id=Default Security Service)
+    INFO - Initializing network services
+    INFO - Creating ServerService(id=httpejbd)
+    INFO - Using 'print=true'
+    INFO - Using 'indent.xml=true'
+    INFO - Creating ServerService(id=cxf-rs)
+    INFO - Initializing network services
+    INFO - Starting service httpejbd
+    INFO - Started service httpejbd
+    INFO - Starting service cxf-rs
+    INFO - Started service cxf-rs
+    INFO -   ** Bound Services **
+    INFO -   NAME                 IP              PORT  
+    INFO -   httpejbd             127.0.0.1       4204  
+    INFO - -------
+    INFO - Ready!
+    INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+    INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: Container(type=MANAGED, id=Default Managed Container)
+    INFO - Creating Container(id=Default Managed Container)
+    INFO - Using directory /tmp for stateful session passivation
+    INFO - Enterprise application "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+    INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Existing thread singleton service in SystemInstance() null
+    INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+    INFO - Succeeded in installing singleton service
+    INFO - OpenWebBeans Container is starting...
+    INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+    INFO - All injection points are validated successfully.
+    INFO - OpenWebBeans Container has started, it took 10 ms.
+    INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+    INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+    INFO - REST Service: http://127.0.0.1:4204/test/greeting/.*  -> Pojo org.superbiz.rest.GreetingService
+    FINE - ******************* REQUEST ******************
+    GET http://localhost:4204/test/greeting/
+    Host=localhost:4204
+    User-Agent=Apache CXF 2.7.0
+    Connection=keep-alive
+    Accept=application/json
+    Content-Type=*/*
+    Pragma=no-cache
+    Cache-Control=no-cache
+    
+    
+    **********************************************
+    
+    FINE - HTTP/1.1 200 OK
+    Date: Fri, 09 Nov 2012 11:59:00 GMT
+    Content-Length: 33
+    Set-Cookie: EJBSESSIONID=7112a057-fc4c-4f52-a556-1617320d2275; Path=/
+    Content-Type: application/json
+    Connection: close
+    Server: OpenEJB/4.5.1-SNAPSHOT Linux/3.2.0-23-generic (amd64)
+    
+    {"response":{"value":"Hi REST!"}}
+    INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Stopping network services
+    INFO - Stopping server services
+    INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
+    INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+    INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+    INFO - Creating TransactionManager(id=Default Transaction Manager)
+    INFO - Creating SecurityService(id=Default Security Service)
+    INFO - Initializing network services
+    INFO - Creating ServerService(id=httpejbd)
+    INFO - Using 'print=true'
+    INFO - Using 'indent.xml=true'
+    INFO - Creating ServerService(id=cxf-rs)
+    INFO - Initializing network services
+    INFO - Starting service httpejbd
+    INFO - Started service httpejbd
+    INFO - Starting service cxf-rs
+    INFO - Started service cxf-rs
+    INFO -   ** Bound Services **
+    INFO -   NAME                 IP              PORT  
+    INFO -   httpejbd             127.0.0.1       4204  
+    INFO - -------
+    INFO - Ready!
+    INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+    INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: Container(type=MANAGED, id=Default Managed Container)
+    INFO - Creating Container(id=Default Managed Container)
+    INFO - Using directory /tmp for stateful session passivation
+    INFO - Enterprise application "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+    INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Existing thread singleton service in SystemInstance() null
+    INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+    INFO - Succeeded in installing singleton service
+    INFO - OpenWebBeans Container is starting...
+    INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+    INFO - All injection points are validated successfully.
+    INFO - OpenWebBeans Container has started, it took 10 ms.
+    INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+    INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+    INFO - REST Service: http://127.0.0.1:4204/test/greeting/.*  -> Pojo org.superbiz.rest.GreetingService
+    FINE - ******************* REQUEST ******************
+    POST http://localhost:4204/test/greeting/
+    Host=localhost:4204
+    Content-Length=97
+    User-Agent=Apache CXF 2.7.0
+    Connection=keep-alive
+    Accept=application/json
+    Content-Type=application/xml
+    Pragma=no-cache
+    Cache-Control=no-cache
+    
+    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+    **********************************************
+    
+    FINE - HTTP/1.1 200 OK
+    Date: Fri, 09 Nov 2012 11:59:01 GMT
+    Content-Length: 33
+    Set-Cookie: EJBSESSIONID=50cf1d2b-a940-4afb-8993-fff7f9cc6d83; Path=/
+    Content-Type: application/json
+    Connection: close
+    Server: OpenEJB/4.5.1-SNAPSHOT Linux/3.2.0-23-generic (amd64)
+    
+    {"response":{"value":"hi rest!"}}
+    INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Stopping network services
+    INFO - Stopping server services
+    
+
+
+

Added: openejb/trunk/openejb/examples/rest-xml-json/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/rest-xml-json/pom.xml?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/rest-xml-json/pom.xml (added)
+++ openejb/trunk/openejb/examples/rest-xml-json/pom.xml Fri Nov  9 15:57:46 2012
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<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.superbiz</groupId>
+  <artifactId>rest-xml-json</artifactId>
+  <version>1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Examples :: REST XML JSON</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <defaultGoal>install</defaultGoal>
+
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.4</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </repository>
+  </repositories>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>6.0-4</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.10</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!--
+    The <scope>test</scope> guarantees that non of your runtime
+    code is dependent on any OpenEJB classes.
+    -->
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-cxf-rs</artifactId>
+      <version>4.5.1-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+</project>

Added: openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/GreetingService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/GreetingService.java?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/GreetingService.java (added)
+++ openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/GreetingService.java Fri Nov  9 15:57:46 2012
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.superbiz.rest;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/greeting")
+@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+public class GreetingService {
+    @GET
+    public Response message() {
+        return new Response("Hi REST!");
+    }
+
+    @POST
+    public Response lowerCase(final Request message) {
+        return new Response(message.getValue().toLowerCase());
+    }
+}

Added: openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Request.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Request.java?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Request.java (added)
+++ openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Request.java Fri Nov  9 15:57:46 2012
@@ -0,0 +1,24 @@
+package org.superbiz.rest;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Request {
+    private String value;
+
+    public Request() {
+        //no-op
+    }
+
+    public Request(final String s) {
+        value = s;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

Added: openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Response.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Response.java?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Response.java (added)
+++ openejb/trunk/openejb/examples/rest-xml-json/src/main/java/org/superbiz/rest/Response.java Fri Nov  9 15:57:46 2012
@@ -0,0 +1,24 @@
+package org.superbiz.rest;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Response {
+    private String value;
+
+    public Response() {
+        // no-op
+    }
+
+    public Response(final String s) {
+        value = s;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

Added: openejb/trunk/openejb/examples/rest-xml-json/src/test/java/org/superbiz/rest/GreetingServiceTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/rest-xml-json/src/test/java/org/superbiz/rest/GreetingServiceTest.java?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/rest-xml-json/src/test/java/org/superbiz/rest/GreetingServiceTest.java (added)
+++ openejb/trunk/openejb/examples/rest-xml-json/src/test/java/org/superbiz/rest/GreetingServiceTest.java Fri Nov  9 15:57:46 2012
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Classes;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs", httpDebug = true)
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+    @Module
+    @Classes(GreetingService.class)
+    public WebApp app() {
+        return new WebApp().contextRoot("test");
+    }
+
+    @Test
+    public void getXml() throws IOException {
+        final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+                .accept(MediaType.APPLICATION_XML_TYPE)
+                .get(Response.class).getValue();
+        assertEquals("Hi REST!", message);
+    }
+
+    @Test
+    public void postXml() throws IOException {
+        final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+                .accept(MediaType.APPLICATION_XML_TYPE)
+                .post(new Request("Hi REST!"), Response.class).getValue();
+        assertEquals("hi rest!", message);
+    }
+
+    @Test
+    public void getJson() throws IOException {
+        final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+                .accept(MediaType.APPLICATION_JSON_TYPE)
+                .get(Response.class).getValue();
+        assertEquals("Hi REST!", message);
+    }
+
+    @Test
+    public void postJson() throws IOException {
+        final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+                .accept(MediaType.APPLICATION_JSON_TYPE)
+                .post(new Request("Hi REST!"), Response.class).getValue();
+        assertEquals("hi rest!", message);
+    }
+}

Added: openejb/trunk/openejb/examples/simple-rest/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/simple-rest/README.md?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/simple-rest/README.md (added)
+++ openejb/trunk/openejb/examples/simple-rest/README.md Fri Nov  9 15:57:46 2012
@@ -0,0 +1,131 @@
+Title: Simple REST
+
+Defining a REST service is pretty easy, simply ad @Path annotation to a class then define on methods
+the HTTP method to use (@GET, @POST, ...).
+
+#The Code
+
+## The REST service: @Path, @GET, @POST
+
+Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.
+
+    package org.superbiz.rest;
+
+    import javax.ws.rs.GET;
+    import javax.ws.rs.POST;
+    import javax.ws.rs.Path;
+
+    @Path("/greeting")
+    public class GreetingService {
+        @GET
+        public String message() {
+            return "Hi REST!";
+        }
+
+        @POST
+        public String lowerCase(final String message) {
+            return "Hi REST!".toLowerCase();
+        }
+    }
+
+# Testing
+
+## Test for the JAXRS service
+
+The test uses the OpenEJB ApplicationComposer to make it trivial.
+
+The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.
+
+Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.
+
+Finally to test it we use cxf client API to call the REST service in get() and post() methods.
+
+    package org.superbiz.rest;
+
+    import org.apache.cxf.jaxrs.client.WebClient;
+    import org.apache.openejb.jee.SingletonBean;
+    import org.apache.openejb.junit.ApplicationComposer;
+    import org.apache.openejb.junit.EnableServices;
+    import org.apache.openejb.junit.Module;
+    import org.junit.Test;
+    import org.junit.runner.RunWith;
+
+    import java.io.IOException;
+
+    import static org.junit.Assert.assertEquals;
+
+    @EnableServices(value = "jaxrs")
+    @RunWith(ApplicationComposer.class)
+    public class GreetingServiceTest {
+        @Module
+        public SingletonBean app() {
+            return (SingletonBean) new SingletonBean(GreetingService.class).localBean();
+        }
+
+        @Test
+        public void get() throws IOException {
+            final String message = WebClient.create("http://localhost:4204").path("/GreetingServiceTest/greeting/").get(String.class);
+            assertEquals("Hi REST!", message);
+        }
+
+        @Test
+        public void post() throws IOException {
+            final String message = WebClient.create("http://localhost:4204").path("/GreetingServiceTest/greeting/").post("Hi REST!", String.class);
+            assertEquals("hi rest!", message);
+        }
+    }
+
+#Running
+
+Running the example is fairly simple. In the "simple-rest" directory run:
+
+    $ mvn clean install
+
+Which should create output like the following.
+
+    INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
+    INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+    INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+    INFO - Creating TransactionManager(id=Default Transaction Manager)
+    INFO - Creating SecurityService(id=Default Security Service)
+    INFO - Initializing network services
+    INFO - Creating ServerService(id=httpejbd)
+    INFO - Creating ServerService(id=cxf-rs)
+    INFO - Initializing network services
+    INFO - Starting service httpejbd
+    INFO - Started service httpejbd
+    INFO - Starting service cxf-rs
+    INFO - Started service cxf-rs
+    INFO -   ** Bound Services **
+    INFO -   NAME                 IP              PORT
+    INFO -   httpejbd             127.0.0.1       4204
+    INFO - -------
+    INFO - Ready!
+    INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+    INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: Container(type=MANAGED, id=Default Managed Container)
+    INFO - Creating Container(id=Default Managed Container)
+    INFO - Using directory /tmp for stateful session passivation
+    INFO - Enterprise application "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+    INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Existing thread singleton service in SystemInstance() null
+    INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@12c9b196
+    INFO - Succeeded in installing singleton service
+    INFO - OpenWebBeans Container is starting...
+    INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+    INFO - All injection points are validated successfully.
+    INFO - OpenWebBeans Container has started, it took 11 ms.
+    INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+    INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+    INFO - REST Service: http://127.0.0.1:4204/test/greeting/.*  -> Pojo org.superbiz.rest.GreetingService
+    INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+    INFO - Stopping network services
+    INFO - Stopping server services
+    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
+
+    Results :
+
+    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+

Added: openejb/trunk/openejb/examples/simple-rest/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/simple-rest/pom.xml?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/simple-rest/pom.xml (added)
+++ openejb/trunk/openejb/examples/simple-rest/pom.xml Fri Nov  9 15:57:46 2012
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<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.superbiz</groupId>
+  <artifactId>simple-rest</artifactId>
+  <version>1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Examples :: Simple REST</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <defaultGoal>install</defaultGoal>
+
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.4</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </repository>
+  </repositories>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>6.0-4</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.10</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!--
+    The <scope>test</scope> guarantees that non of your runtime
+    code is dependent on any OpenEJB classes.
+    -->
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-cxf-rs</artifactId>
+      <version>4.5.1-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+</project>

Added: openejb/trunk/openejb/examples/simple-rest/src/main/java/org/superbiz/rest/GreetingService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/simple-rest/src/main/java/org/superbiz/rest/GreetingService.java?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/simple-rest/src/main/java/org/superbiz/rest/GreetingService.java (added)
+++ openejb/trunk/openejb/examples/simple-rest/src/main/java/org/superbiz/rest/GreetingService.java Fri Nov  9 15:57:46 2012
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.superbiz.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("/greeting")
+public class GreetingService {
+    @GET
+    public String message() {
+        return "Hi REST!";
+    }
+
+    @POST
+    public String lowerCase(final String message) {
+        return "Hi REST!".toLowerCase();
+    }
+}

Added: openejb/trunk/openejb/examples/simple-rest/src/test/java/org/superbiz/rest/GreetingServiceTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/simple-rest/src/test/java/org/superbiz/rest/GreetingServiceTest.java?rev=1407511&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/simple-rest/src/test/java/org/superbiz/rest/GreetingServiceTest.java (added)
+++ openejb/trunk/openejb/examples/simple-rest/src/test/java/org/superbiz/rest/GreetingServiceTest.java Fri Nov  9 15:57:46 2012
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Classes;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs")
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+    @Module
+    @Classes(GreetingService.class)
+    public WebApp app() {
+        return new WebApp().contextRoot("test");
+    }
+
+    @Test
+    public void get() throws IOException {
+        final String message = WebClient.create("http://localhost:4204").path("/test/greeting/").get(String.class);
+        assertEquals("Hi REST!", message);
+    }
+
+    @Test
+    public void post() throws IOException {
+        final String message = WebClient.create("http://localhost:4204").path("/test/greeting/").post("Hi REST!", String.class);
+        assertEquals("hi rest!", message);
+    }
+}