Repository: cxf Updated Branches: refs/heads/master fde8db305 -> db51e1a99
Minor update to the jaxrs boot demo Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/db51e1a9 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/db51e1a9 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/db51e1a9 Branch: refs/heads/master Commit: db51e1a99ab886f179c677579ba798b450069287 Parents: fde8db3 Author: Sergey Beryozkin <[email protected]> Authored: Fri May 22 17:06:02 2015 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Fri May 22 17:06:02 2015 +0100 ---------------------------------------------------------------------- .../samples/jax_rs/jaxrs_spring_boot/README | 9 ++++++- .../samples/jax_rs/jaxrs_spring_boot/pom.xml | 26 +++++++++++++++----- .../rs/client/SampleRestClientApplication.java | 14 +++++++++++ .../java/sample/rs/service/HelloService.java | 2 +- .../rs/service/SampleRestWSApplication.java | 8 +----- 5 files changed, 44 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/db51e1a9/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/README ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/README b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/README index c9487d7..68ebb93 100644 --- a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/README +++ b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/README @@ -9,5 +9,12 @@ The sample uses Maven. It can be built and run from the command line: $ mvn spring-boot:run ---- -http://localhost:8080/services/helloservice/sayHello/Elan will now display the output in the browser +http://localhost:8080/services/helloservice/sayHello/ApacheCxfUser will now display the output in the browser like "Hello Elan, Welcome to CXF RS Spring Boot World!!!" + +To run the client from a command line open a new terminal window and run: + +---- +$ mvn exec:java +---- + http://git-wip-us.apache.org/repos/asf/cxf/blob/db51e1a9/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/pom.xml ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/pom.xml b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/pom.xml index c3b56f6..5bd5bd4 100644 --- a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/pom.xml +++ b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/pom.xml @@ -35,6 +35,11 @@ </dependency> <dependency> <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> </dependency> @@ -92,12 +97,21 @@ </dependencies> <build> - <plugins> - - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <mainClass>sample.rs.service.SampleRestWsApplication</mainClass> + </configuration> </plugin> - </plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <configuration> + <mainClass>sample.rs.client.SampleRestClientApplication</mainClass> + </configuration> + </plugin> + </plugins> </build> </project> http://git-wip-us.apache.org/repos/asf/cxf/blob/db51e1a9/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java new file mode 100644 index 0000000..0b8f4be --- /dev/null +++ b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/client/SampleRestClientApplication.java @@ -0,0 +1,14 @@ +package sample.rs.client; + +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; + +import sample.rs.service.HelloService; + + +public class SampleRestClientApplication { + public static void main(String[] args) { + HelloService service = JAXRSClientFactory.create("http://locahost:8080/helloservice/", + HelloService.class); + System.out.println(service.sayHello("ApacheCxfUser")); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/db51e1a9/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java index 72e2a66..29780ae 100644 --- a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java +++ b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/HelloService.java @@ -12,7 +12,7 @@ public class HelloService { @Path("/{a}") @Produces(MediaType.TEXT_PLAIN) public String sayHello(@PathParam("a") String a) { - return "Hello "+a+", Welcome to CXF RS Spring Boot World!!!"; + return "Hello " + a + ", Welcome to CXF RS Spring Boot World!!!"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/db51e1a9/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java index 5bd90db..fa27c35 100644 --- a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java +++ b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/java/sample/rs/service/SampleRestWSApplication.java @@ -1,24 +1,18 @@ package sample.rs.service; import org.apache.cxf.Bus; +import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; import org.apache.cxf.transport.servlet.CXFServlet; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.ServletRegistrationBean; import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; -import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; - -import org.apache.cxf.endpoint.Server; -import org.apache.cxf.bus.spring.SpringBus; -import sample.rs.service.HelloService; -import org.apache.cxf.jaxrs.JAXRSBindingFactory; @Configuration @EnableAutoConfiguration
