Repository: cxf Updated Branches: refs/heads/3.1.x-fixes 06fbd75b7 -> 2ceb8351e
Updating jaxrs spring boot demos to use the application context Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/2ceb8351 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2ceb8351 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2ceb8351 Branch: refs/heads/3.1.x-fixes Commit: 2ceb8351e2cd174297c5bf11c389280a33b39fc3 Parents: 06fbd75 Author: Sergey Beryozkin <[email protected]> Authored: Thu Jun 9 12:50:37 2016 +0100 Committer: Sergey Beryozkin <[email protected]> Committed: Thu Jun 9 12:51:58 2016 +0100 ---------------------------------------------------------------------- .../rs/client/SampleRestClientApplication.java | 24 +++++++++----- .../main/resources/sample/rs/client/client.xml | 33 ++++++++++++++++++++ .../rs/client/SampleRestClientApplication.java | 22 ++++++++----- .../main/resources/sample/rs/client/client.xml | 33 ++++++++++++++++++++ 4 files changed, 97 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/2ceb8351/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 index 448861c..b0ab7f0 100644 --- 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 @@ -18,19 +18,27 @@ */ package sample.rs.client; -import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.springframework.context.support.ClassPathXmlApplicationContext; import sample.rs.service.HelloService; public final class SampleRestClientApplication { - private SampleRestClientApplication() { - - } + private HelloService helloService; + public static void main(String[] args) { - HelloService service = - JAXRSClientFactory.create("http://localhost:8080/services/helloservice/", - HelloService.class); - System.out.println(service.sayHello("ApacheCxfUser")); + ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("sample/rs/client/client.xml"); + SampleRestClientApplication clientApp = ctx.getBean(SampleRestClientApplication.class); + System.out.println(clientApp.getHelloService().sayHello("ApacheCxfUser")); + ctx.close(); + } + + public HelloService getHelloService() { + return helloService; + } + + public void setHelloService(HelloService helloService) { + this.helloService = helloService; } } + http://git-wip-us.apache.org/repos/asf/cxf/blob/2ceb8351/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/resources/sample/rs/client/client.xml ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/resources/sample/rs/client/client.xml b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/resources/sample/rs/client/client.xml new file mode 100644 index 0000000..7ba6911 --- /dev/null +++ b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot/src/main/resources/sample/rs/client/client.xml @@ -0,0 +1,33 @@ +<?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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jaxrs="http://cxf.apache.org/jaxrs-client" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://cxf.apache.org/jaxrs-client http://cxf.apache.org/schemas/jaxrs-client.xsd"> + <jaxrs:client id="helloServiceClient" + address="http://localhost:8080/services/helloservice/" + serviceClass="sample.rs.service.HelloService"/> + + <bean class="sample.rs.client.SampleRestClientApplication"> + <property name="helloService" ref="helloServiceClient"/> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/2ceb8351/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/java/sample/rs/client/SampleRestClientApplication.java ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/java/sample/rs/client/SampleRestClientApplication.java b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/java/sample/rs/client/SampleRestClientApplication.java index 430a610..183c4a8 100644 --- a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/java/sample/rs/client/SampleRestClientApplication.java +++ b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/java/sample/rs/client/SampleRestClientApplication.java @@ -18,18 +18,26 @@ */ package sample.rs.client; -import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.springframework.context.support.ClassPathXmlApplicationContext; import sample.rs.service.HelloService; public final class SampleRestClientApplication { - private SampleRestClientApplication() { - - } + private HelloService helloService; + public static void main(String[] args) { - HelloService service = JAXRSClientFactory.create("http://localhost:8080/services/helloservice/", - HelloService.class); - System.out.println(service.sayHello("ApacheCxfUser")); + ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("sample/rs/client/client.xml"); + SampleRestClientApplication clientApp = ctx.getBean(SampleRestClientApplication.class); + System.out.println(clientApp.getHelloService().sayHello("ApacheCxfUser")); + ctx.close(); + } + + public HelloService getHelloService() { + return helloService; + } + + public void setHelloService(HelloService helloService) { + this.helloService = helloService; } } http://git-wip-us.apache.org/repos/asf/cxf/blob/2ceb8351/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/resources/sample/rs/client/client.xml ---------------------------------------------------------------------- diff --git a/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/resources/sample/rs/client/client.xml b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/resources/sample/rs/client/client.xml new file mode 100644 index 0000000..7ba6911 --- /dev/null +++ b/distribution/src/main/release/samples/jax_rs/jaxrs_spring_boot_scan/src/main/resources/sample/rs/client/client.xml @@ -0,0 +1,33 @@ +<?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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jaxrs="http://cxf.apache.org/jaxrs-client" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://cxf.apache.org/jaxrs-client http://cxf.apache.org/schemas/jaxrs-client.xsd"> + <jaxrs:client id="helloServiceClient" + address="http://localhost:8080/services/helloservice/" + serviceClass="sample.rs.service.HelloService"/> + + <bean class="sample.rs.client.SampleRestClientApplication"> + <property name="helloService" ref="helloServiceClient"/> + </bean> +</beans>
