| <!DOCTYPE html> |
| <html lang="en"> |
| |
| <head> |
| <meta charset="UTF-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <title>Apache TomEE</title> |
| <meta name="description" |
| content="Apache TomEE is a lightweight, yet powerful, JavaEE Application server with feature rich tooling." /> |
| <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" /> |
| <meta name="author" content="Luka Cvetinovic for Codrops" /> |
| <link rel="icon" href="../../../favicon.ico"> |
| <link rel="icon" type="image/png" href="../../../favicon.png"> |
| <meta name="msapplication-TileColor" content="#80287a"> |
| <meta name="theme-color" content="#80287a"> |
| <link rel="stylesheet" type="text/css" href="../../../css/normalize.css"> |
| <link rel="stylesheet" type="text/css" href="../../../css/bootstrap.css"> |
| <link rel="stylesheet" type="text/css" href="../../../css/owl.css"> |
| <link rel="stylesheet" type="text/css" href="../../../css/animate.css"> |
| <link rel="stylesheet" type="text/css" href="../../../fonts/font-awesome-4.1.0/css/font-awesome.min.css"> |
| <link rel="stylesheet" type="text/css" href="../../../fonts/eleganticons/et-icons.css"> |
| <link rel="stylesheet" type="text/css" href="../../../css/jqtree.css"> |
| <link rel="stylesheet" type="text/css" href="../../../css/idea.css"> |
| <link rel="stylesheet" type="text/css" href="../../../css/cardio.css"> |
| |
| <script type="text/javascript"> |
| <!-- Matomo --> |
| var _paq = window._paq = window._paq || []; |
| /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ |
| /* We explicitly disable cookie tracking to avoid privacy issues */ |
| _paq.push(['disableCookies']); |
| _paq.push(['trackPageView']); |
| _paq.push(['enableLinkTracking']); |
| (function () { |
| var u = "//matomo.privacy.apache.org/"; |
| _paq.push(['setTrackerUrl', u + 'matomo.php']); |
| _paq.push(['setSiteId', '5']); |
| var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; |
| g.async = true; |
| g.src = u + 'matomo.js'; |
| s.parentNode.insertBefore(g, s); |
| })(); |
| <!-- End Matomo Code --> |
| </script> |
| </head> |
| |
| <body> |
| <div class="preloader"> |
| <img src="../../../img/loader.gif" alt="Preloader image"> |
| </div> |
| <nav class="navbar"> |
| <div class="container"> |
| <div class="row"> <div class="col-md-12"> |
| |
| <!-- Brand and toggle get grouped for better mobile display --> |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| <a class="navbar-brand" href="/" title="Apache TomEE"> |
| <span> |
| |
| |
| <img |
| src="../../../img/apache_tomee-logo.svg" |
| onerror="this.src='../../../img/apache_tomee-logo.jpg'" |
| height="50" |
| > |
| |
| |
| </span> |
| </a> |
| </div> |
| <!-- Collect the nav links, forms, and other content for toggling --> |
| <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> |
| <ul class="nav navbar-nav navbar-right main-nav"> |
| <li><a href="../../../docs.html">Documentation</a></li> |
| <li><a href="../../../community/index.html">Community</a></li> |
| <li><a href="../../../security/security.html">Security</a></li> |
| <li><a class="btn btn-accent accent-orange no-shadow" href="../../../download.html">Downloads</a></li> |
| </ul> |
| </div> |
| <!-- /.navbar-collapse --> |
| </div></div> |
| </div> |
| <!-- /.container-fluid --> |
| </nav> |
| |
| |
| <div id="main-block" class="container main-block"> |
| <div class="row title"> |
| <div class="col-md-12"> |
| <div class='page-header'> |
| |
| <h1>REST Simples</h1> |
| </div> |
| </div> |
| </div> |
| <div class="row"> |
| |
| <div class="col-md-12"> |
| <div id="preamble"> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Definir um serviço REST é muito fácil, simplesmente adicionamos a anotação @Path para a |
| classe, então definimos nos métodos, o método HTTP para usar (@GET, @POST, …).</p> |
| </div> |
| <div class="paragraph"> |
| <p>O Código</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_o_serviço_rest_path_produces_consumes">O serviço REST: @Path, @Produces, @Consumes</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Aqui nós vemos um bean que usa as anotações @Path, @Produces e @Consumes. |
| A anotação @Path identifica o modelo de caminho URI ao qual o recurso responde e é especificado no nível de classe de um recurso. O valor da anotação @Path |
| é um modelo de caminho de URI parcial relativo ao URI de base do servidor no qual o recurso está implementado, o contexto raiz do WAR e o padrão de URL |
| para o qual o servlet auxiliar Jersey responde. |
| A anotação @Produces é usada para especificar os tipos de mídia MIME ou representações que um recurso pode produzir e enviar de volta ao cliente. Se @Produces |
| for aplicado no nível da classe, todos os métodos em um recurso podem produzir os tipos MIME especificados por padrão. Se for aplicado no nível de método, substitui |
| quaisquer anotações @Produces aplicadas no nível da classe. |
| A anotação @Consumes é usada para especificar quais tipos de mídia MIME de representações um recurso pode aceitar ou consumir do cliente. Se @Consumes for |
| aplicado no nível da classe, todos os métodos de resposta aceitarão os tipos MIME especificados por padrão. Se @Consumes for aplicado no nível do método, ele |
| substituirá qualquer anotação @Consumes aplicadas no nível da classe.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Na realidade linhas:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre>@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) |
| @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })</pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>são opcionais, uma vez que é a configuração padrão. E essas linhas, podem |
| ser configuradas pelo método também, se você precisar para ser mais preciso.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre>@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()); |
| } |
| }</pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_testando">Testando</h2> |
| <div class="sectionbody"> |
| <div class="sect2"> |
| <h3 id="_teste_para_o_serviço_jaxrs">Teste para o serviço JAXRS</h3> |
| <div class="paragraph"> |
| <p>O teste utiliza o OpenEJB ApplicationComposer para torná-lo trivial.</p> |
| </div> |
| <div class="paragraph"> |
| <p>A idea é primeiro ativar os serviços jaxrs. Isso é feito usando a |
| anotação @EnableServices.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Em seguida, criamos rapidamente o aplicativo, simplesmente retornando um objeto |
| representando o web.xml. Aqui nós, simplesmente usamos isso para definir o contexto |
| root, mas você pode usá-lo para definir sua Aplicação REST também. E para |
| finalizar a definição da aplicação, nós adicionamos a anotação @Classes, para definir |
| o grupo de classes para ser usado nessa aplicação.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Finalmente para testá-lo, usamos a API cliente cxf, para chamar o serviço |
| REST em métodos get() e post().</p> |
| </div> |
| <div class="paragraph"> |
| <p>Observação: para mostrar que usamos JSON ou XML, dependendo no método de teste nós |
| ativamos em EnableServices o atributo httpDebug, que imprime as |
| mensagens http nos logs.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre>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.testing.EnableServices; |
| import org.apache.openejb.testing.Module; |
| import org.junit.Test; |
| import org.junit.runner.RunWith; |
| |
| import jakarta.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); |
| } |
| }</pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>#Executando</p> |
| </div> |
| <div class="paragraph"> |
| <p>Executar o exemplo é bastante simples. No diretório ``rest-xml-json'' |
| executa:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre>$ mvn clean install</pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>Que deve criar saída como a seguinte.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre>/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/jakartaee-api/6.0-4/jakartaee-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/openejb-cxf-rs-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-http/4.5.1/openejb-http-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-core/4.5.1/openejb-core-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/mbean-annotation-api/4.5.1/mbean-annotation-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jpa-integration/4.5.1/openejb-jpa-integration-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-api/4.5.1/openejb-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-loader/4.5.1/openejb-loader-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-javaagent/4.5.1/openejb-javaagent-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jee/4.5.1/openejb-jee-4.5.1.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/org/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/xbean/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/openwebbeans-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/openejb-server-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-client/4.5.1/openejb-client-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-ejbd/4.5.1/openejb-ejbd-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-rest/4.5.1/openejb-rest-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-transport/4.5.1/openejb-cxf-transport-4.5.1.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/jakarta.ws.rs-api/2.0-m10/jakarta.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.jar:/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 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 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 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 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</pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_apis_used">APIs Used</h2> |
| <div class="sectionbody"> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><a href="../../../master/javadoc/org/apache/openejb/jee/WebApp.html">org.apache.openejb.jee.WebApp</a></p> |
| </li> |
| <li> |
| <p><a href="../../../master/javadoc/org/apache/openejb/junit/ApplicationComposer.html">org.apache.openejb.junit.ApplicationComposer</a></p> |
| </li> |
| <li> |
| <p><a href="../../../master/javadoc/org/apache/openejb/junit/Classes.html">org.apache.openejb.junit.Classes</a></p> |
| </li> |
| <li> |
| <p><a href="../../../master/javadoc/org/apache/openejb/testing/Classes.html">org.apache.openejb.testing.Classes</a></p> |
| </li> |
| <li> |
| <p><a href="../../../master/javadoc/org/apache/openejb/testing/EnableServices.html">org.apache.openejb.testing.EnableServices</a></p> |
| </li> |
| <li> |
| <p><a href="../../../master/javadoc/org/apache/openejb/testing/Module.html">org.apache.openejb.testing.Module</a></p> |
| </li> |
| <li> |
| <p><a href="../../../jakartaee-9.0/javadoc/jakarta/ws/rs/Consumes.html">jakarta.ws.rs.Consumes</a></p> |
| </li> |
| <li> |
| <p><a href="../../../jakartaee-9.0/javadoc/jakarta/ws/rs/GET.html">jakarta.ws.rs.GET</a></p> |
| </li> |
| <li> |
| <p><a href="../../../jakartaee-9.0/javadoc/jakarta/ws/rs/POST.html">jakarta.ws.rs.POST</a></p> |
| </li> |
| <li> |
| <p><a href="../../../jakartaee-9.0/javadoc/jakarta/ws/rs/Path.html">jakarta.ws.rs.Path</a></p> |
| </li> |
| <li> |
| <p><a href="../../../jakartaee-9.0/javadoc/jakarta/ws/rs/Produces.html">jakarta.ws.rs.Produces</a></p> |
| </li> |
| <li> |
| <p><a href="../../../jakartaee-9.0/javadoc/jakarta/ws/rs/core/MediaType.html">jakarta.ws.rs.core.MediaType</a></p> |
| </li> |
| <li> |
| <p><a href="../../../jakartaee-9.0/javadoc/jakarta/xml/bind/annotation/XmlRootElement.html">jakarta.xml.bind.annotation.XmlRootElement</a></p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| </div> |
| </div> |
| <div style="margin-bottom: 30px;"></div> |
| <footer> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-sm-6 text-center-mobile"> |
| <h3 class="white">Be simple. Be certified. Be Tomcat.</h3> |
| <h5 class="light regular light-white">"A good application in a good server"</h5> |
| <ul class="social-footer"> |
| <li><a href="https://www.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li> |
| <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li> |
| </ul> |
| <h5 class="light regular light-white"> |
| <a href="../../../privacy-policy.html" class="white">Privacy Policy</a> |
| </h5> |
| </div> |
| <div class="col-sm-6 text-center-mobile"> |
| <div class="row opening-hours"> |
| <div class="col-sm-3 text-center-mobile"> |
| <h5><a href="../../../latest/docs/" class="white">Documentation</a></h5> |
| <ul class="list-unstyled"> |
| <li><a href="../../../latest/docs/admin/configuration/index.html" class="regular light-white">How to configure</a></li> |
| <li><a href="../../../latest/docs/admin/file-layout.html" class="regular light-white">Dir. Structure</a></li> |
| <li><a href="../../../latest/docs/developer/testing/index.html" class="regular light-white">Testing</a></li> |
| <li><a href="../../../latest/docs/admin/cluster/index.html" class="regular light-white">Clustering</a></li> |
| </ul> |
| </div> |
| <div class="col-sm-3 text-center-mobile"> |
| <h5><a href="../../../latest/examples/" class="white">Examples</a></h5> |
| <ul class="list-unstyled"> |
| <li><a href="../../../latest/examples/simple-cdi-interceptor.html" class="regular light-white">CDI Interceptor</a></li> |
| <li><a href="../../../latest/examples/rest-cdi.html" class="regular light-white">REST with CDI</a></li> |
| <li><a href="../../../latest/examples/ejb-examples.html" class="regular light-white">EJB</a></li> |
| <li><a href="../../../latest/examples/jsf-managedBean-and-ejb.html" class="regular light-white">JSF</a></li> |
| </ul> |
| </div> |
| <div class="col-sm-3 text-center-mobile"> |
| <h5><a href="../../../community/index.html" class="white">Community</a></h5> |
| <ul class="list-unstyled"> |
| <li><a href="../../../community/contributors.html" class="regular light-white">Contributors</a></li> |
| <li><a href="../../../community/social.html" class="regular light-white">Social</a></li> |
| <li><a href="../../../community/sources.html" class="regular light-white">Sources</a></li> |
| </ul> |
| </div> |
| <div class="col-sm-3 text-center-mobile"> |
| <h5><a href="../../../security/index.html" class="white">Security</a></h5> |
| <ul class="list-unstyled"> |
| <li><a href="https://apache.org/security" target="_blank" class="regular light-white">Apache Security</a></li> |
| <li><a href="https://apache.org/security/projects.html" target="_blank" class="regular light-white">Security Projects</a></li> |
| <li><a href="https://cve.mitre.org" target="_blank" class="regular light-white">CVE</a></li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="row bottom-footer text-center-mobile"> |
| <div class="col-sm-12 light-white"> |
| <p>Copyright © 1999-2022 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p> |
| </div> |
| </div> |
| </div> |
| </footer> |
| <!-- Holder for mobile navigation --> |
| <div class="mobile-nav"> |
| <ul> |
| <li><a hef="../../../latest/docs/admin/index.html">Administrators</a> |
| <li><a hef="../../../latest/docs/developer/index.html">Developers</a> |
| <li><a hef="../../../latest/docs/advanced/index.html">Advanced</a> |
| <li><a hef="../../../community/index.html">Community</a> |
| </ul> |
| <a href="#" class="close-link"><i class="arrow_up"></i></a> |
| </div> |
| <!-- Scripts --> |
| <script src="../../../js/jquery-1.11.1.min.js"></script> |
| <script src="../../../js/owl.carousel.min.js"></script> |
| <script src="../../../js/bootstrap.min.js"></script> |
| <script src="../../../js/wow.min.js"></script> |
| <script src="../../../js/typewriter.js"></script> |
| <script src="../../../js/jquery.onepagenav.js"></script> |
| <script src="../../../js/tree.jquery.js"></script> |
| <script src="../../../js/highlight.pack.js"></script> |
| <script src="../../../js/main.js"></script> |
| </body> |
| |
| </html> |
| |