Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6A96B200B66 for ; Mon, 11 Jul 2016 02:14:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 69907160A88; Mon, 11 Jul 2016 00:14:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5846C160A91 for ; Mon, 11 Jul 2016 02:14:08 +0200 (CEST) Received: (qmail 39079 invoked by uid 500); 11 Jul 2016 00:14:07 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 37195 invoked by uid 99); 11 Jul 2016 00:14:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jul 2016 00:14:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 72C33ED49E; Mon, 11 Jul 2016 00:14:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: reta@apache.org To: commits@cxf.apache.org Date: Mon, 11 Jul 2016 00:14:24 -0000 Message-Id: In-Reply-To: <8cbfd51cd2674d03bacf70303de6a5e9@git.apache.org> References: <8cbfd51cd2674d03bacf70303de6a5e9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [19/33] cxf git commit: Separating client and server spring boot code in a jaxrs spring boot demo archived-at: Mon, 11 Jul 2016 00:14:09 -0000 Separating client and server spring boot code in a jaxrs spring boot demo Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/bb5b35d1 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/bb5b35d1 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/bb5b35d1 Branch: refs/heads/master-jaxrs-2.1 Commit: bb5b35d1c69915db26c2718024bc90733405da53 Parents: eaf8cd3 Author: Sergey Beryozkin Authored: Fri Jul 8 12:23:33 2016 +0100 Committer: Sergey Beryozkin Committed: Fri Jul 8 12:23:33 2016 +0100 ---------------------------------------------------------------------- .../release/samples/jax_rs/spring_boot/README | 17 +------ .../release/samples/jax_rs/spring_boot/pom.xml | 41 ++++++++-------- .../rs/client/SampleRestClientApplication.java | 49 ++++++++++++++------ .../rs/service/SampleRestApplication.java | 29 ------------ .../jax_rs/spring_boot_scan/application/README | 13 ------ .../jax_rs/spring_boot_scan/application/pom.xml | 17 ------- 6 files changed, 55 insertions(+), 111 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/bb5b35d1/distribution/src/main/release/samples/jax_rs/spring_boot/README ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot/README b/distribution/src/main/release/samples/jax_rs/spring_boot/README index 03373e7..d309ad4 100644 --- a/distribution/src/main/release/samples/jax_rs/spring_boot/README +++ b/distribution/src/main/release/samples/jax_rs/spring_boot/README @@ -6,7 +6,7 @@ with Spring Boot. This demo has two JAX-RS class resources being deployed in a s The sample uses Maven. It can be built and run from the command line: ---- -$ mvn spring-boot:run +$ mvn -Pserver ---- http://localhost:8080/services/helloservice/sayHello/ApacheCxfUser @@ -23,19 +23,6 @@ description of services. To run the client from a command line open a new terminal window and run: ---- -$ mvn exec:java +$ mvn -Pclient ---- -Using Docker: -If you have Docker running on your machine (and appropriate DOCKER_HOST set), -you can run - ----- -$ mvn docker:build ----- - -to create the Docker image. Once created, you can start the container via: - ----- -docker run -p 8080:8080 -t org.apache.cxf.samples/spring-boot-sample-rs-cxf ----- http://git-wip-us.apache.org/repos/asf/cxf/blob/bb5b35d1/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml b/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml index 9eaf71b..811ef91 100644 --- a/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml +++ b/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml @@ -27,7 +27,11 @@ ${cxf.version} + + + server + spring-boot:run org.springframework.boot @@ -36,30 +40,23 @@ sample.rs.service.SampleRestApplication + + + + + client + + spring-boot:run + - org.codehaus.mojo - exec-maven-plugin - - sample.rs.client.SampleRestClientApplication - + org.springframework.boot + spring-boot-maven-plugin + + sample.rs.client.SampleRestClientApplication + - - com.spotify - docker-maven-plugin - 0.4.9 - - ${project.groupId}/${project.artifactId} - frolvlad/alpine-oraclejdk8:slim - java -Djava.security.egd=file:/dev/./urandom -jar ${project.build.finalName}.jar - - - / - ${project.build.directory} - ${project.build.finalName}.jar - - - - + + http://git-wip-us.apache.org/repos/asf/cxf/blob/bb5b35d1/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java b/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java index b0ab7f0..0fed450 100644 --- a/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java +++ b/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java @@ -18,27 +18,46 @@ */ package sample.rs.client; -import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.jaxrs.client.spring.EnableJaxRsProxyClient; +import org.apache.cxf.jaxrs.client.spring.EnableJaxRsWebClient; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.annotation.Bean; import sample.rs.service.HelloService; - -public final class SampleRestClientApplication { - private HelloService helloService; - +@SpringBootApplication +@EnableJaxRsWebClient +@EnableJaxRsProxyClient +public class SampleRestClientApplication { public static void main(String[] args) { - ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("sample/rs/client/client.xml"); - SampleRestClientApplication clientApp = ctx.getBean(SampleRestClientApplication.class); - System.out.println(clientApp.getHelloService().sayHello("ApacheCxfUser")); - ctx.close(); - } + new SpringApplicationBuilder(SampleRestClientApplication.class) + .web(false) + .run(args); + } + @Bean + CommandLineRunner initWebClientRunner(final WebClient webClient) { + + return new CommandLineRunner() { - public HelloService getHelloService() { - return helloService; + @Override + public void run(String... runArgs) throws Exception { + System.out.println(webClient.path("sayHello/ApacheCxfWebClientUser").get(String.class)); + } + }; } + @Bean + CommandLineRunner initProxyClientRunner(final HelloService client) { + + return new CommandLineRunner() { - public void setHelloService(HelloService helloService) { - this.helloService = helloService; - } + @Override + public void run(String... runArgs) throws Exception { + System.out.println(client.sayHello("ApacheCxfProxyUser")); + } + }; + } } http://git-wip-us.apache.org/repos/asf/cxf/blob/bb5b35d1/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java b/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java index 2bc20df..358ca4a 100644 --- a/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java +++ b/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java @@ -22,12 +22,8 @@ import java.util.Arrays; import org.apache.cxf.Bus; import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; -import org.apache.cxf.jaxrs.client.WebClient; -import org.apache.cxf.jaxrs.client.spring.EnableJaxRsProxyClient; -import org.apache.cxf.jaxrs.client.spring.EnableJaxRsWebClient; import org.apache.cxf.jaxrs.swagger.Swagger2Feature; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -36,8 +32,6 @@ import sample.rs.service.hello1.HelloServiceImpl1; import sample.rs.service.hello2.HelloServiceImpl2; @SpringBootApplication -@EnableJaxRsWebClient -@EnableJaxRsProxyClient public class SampleRestApplication { @Autowired private Bus bus; @@ -55,27 +49,4 @@ public class SampleRestApplication { endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); return endpoint.create(); } - - @Bean - CommandLineRunner initWebClientRunner(final WebClient webClient) { - - return new CommandLineRunner() { - - @Override - public void run(String... runArgs) throws Exception { - System.out.println(webClient.path("sayHello/ApacheCxfWebClientUser").get(String.class)); - } - }; - } - @Bean - CommandLineRunner initProxyClientRunner(final HelloService client) { - - return new CommandLineRunner() { - - @Override - public void run(String... runArgs) throws Exception { - System.out.println(client.sayHello("ApacheCxfProxyUser")); - } - }; - } } http://git-wip-us.apache.org/repos/asf/cxf/blob/bb5b35d1/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README index affe5a7..40dbcf5 100644 --- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README +++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README @@ -30,16 +30,3 @@ To run the client from a command line open a new terminal window and run: $ mvn exec:java ---- -Using Docker: -If you have Docker running on your machine (and appropriate DOCKER_HOST set), -you can run - ----- -$ mvn docker:build ----- - -to create the Docker image. Once created, you can start the container via: - ----- -docker run -p 8080:8080 -t org.apache.cxf.samples/spring-boot-sample-rs-cxf-scan ----- http://git-wip-us.apache.org/repos/asf/cxf/blob/bb5b35d1/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml index 9e75e85..cf4f057 100644 --- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml +++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml @@ -55,23 +55,6 @@ sample.rs.client.SampleRestClientApplication - - com.spotify - docker-maven-plugin - 0.4.9 - - ${project.groupId}/${project.artifactId} - frolvlad/alpine-oraclejdk8:slim - java -Djava.security.egd=file:/dev/./urandom -jar ${project.build.finalName}.jar - - - / - ${project.build.directory} - ${project.build.finalName}.jar - - - -