Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BF453103E0 for ; Sun, 18 Jan 2015 03:24:37 +0000 (UTC) Received: (qmail 74634 invoked by uid 500); 18 Jan 2015 03:24:39 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 74480 invoked by uid 500); 18 Jan 2015 03:24:39 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 74460 invoked by uid 99); 18 Jan 2015 03:24:38 -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; Sun, 18 Jan 2015 03:24:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B7367E03BC; Sun, 18 Jan 2015 03:24:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ningjiang@apache.org To: commits@camel.apache.org Date: Sun, 18 Jan 2015 03:24:38 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] camel git commit: CAMEL-8245 Support model reference in CXFRS endpoint with thanks to Sergey Repository: camel Updated Branches: refs/heads/master 53f2df112 -> 1ca7fea70 CAMEL-8245 Support model reference in CXFRS endpoint with thanks to Sergey Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/46c5abcb Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/46c5abcb Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/46c5abcb Branch: refs/heads/master Commit: 46c5abcb760c4b1bbe5a8de9cff7f97bc4a767cc Parents: 53f2df1 Author: Willem Jiang Authored: Sun Jan 18 11:00:52 2015 +0800 Committer: Willem Jiang Committed: Sun Jan 18 11:13:43 2015 +0800 ---------------------------------------------------------------------- .../component/cxf/jaxrs/CxfRsEndpoint.java | 12 ++++++- .../component/cxf/jaxrs/CxfRsConsumerTest.java | 37 ++++++++++++-------- .../testbean/CustomerServiceNoAnnotations.java | 27 ++++++++++++++ .../cxf/jaxrs/CustomerServiceModel.xml | 23 ++++++++++++ 4 files changed, 84 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/46c5abcb/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java index b89eded..b032e1b 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java @@ -116,7 +116,8 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate private long continuationTimeout = 30000; @UriParam(defaultValue = "false") private boolean isSetDefaultBus; - + @UriParam + private String modelRef; private List features = new ModCountCopyOnWriteArrayList(); private InterceptorHolder interceptorHolder = new InterceptorHolder(); private Map properties; @@ -213,6 +214,9 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate if (getAddress() != null) { sfb.setAddress(getAddress()); } + if (modelRef != null) { + sfb.setModelRef(modelRef); + } if (getResourceClasses() != null) { sfb.setResourceClasses(getResourceClasses()); } @@ -234,6 +238,9 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate if (address != null) { cfb.setAddress(address); } + if (modelRef != null) { + cfb.setModelRef(modelRef); + } if (getResourceClasses() != null && !getResourceClasses().isEmpty()) { cfb.setResourceClass(getResourceClasses().get(0)); cfb.getServiceFactory().setResourceClasses(getResourceClasses()); @@ -351,6 +358,9 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate public void setAddress(String address) { this.address = address; } + public void setModelRef(String ref) { + this.modelRef = ref; + } public String getAddress() { return resolvePropertyPlaceholders(address); http://git-wip-us.apache.org/repos/asf/camel/blob/46c5abcb/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java index b37cefa..fe1071a 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java @@ -48,8 +48,14 @@ public class CxfRsConsumerTest extends CamelTestSupport { private static final String PUT_REQUEST = "Mary123"; private static final String CXT = CXFTestSupport.getPort1() + "/CxfRsConsumerTest"; // START SNIPPET: example - private static final String CXF_RS_ENDPOINT_URI = "cxfrs://http://localhost:" + CXT + "/rest?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceResource"; - private static final String CXF_RS_ENDPOINT_URI2 = "cxfrs://http://localhost:" + CXT + "/rest2?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"; + private static final String CXF_RS_ENDPOINT_URI = + "cxfrs://http://localhost:" + CXT + "/rest?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceResource"; + private static final String CXF_RS_ENDPOINT_URI2 = + "cxfrs://http://localhost:" + CXT + "/rest2?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"; + private static final String CXF_RS_ENDPOINT_URI3 = + "cxfrs://http://localhost:" + CXT + "/rest3?" + + "resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerServiceNoAnnotations&" + + "modelRef=classpath:/org/apache/camel/component/cxf/jaxrs/CustomerServiceModel.xml"; protected RouteBuilder createRouteBuilder() throws Exception { final Processor testProcessor = new TestProcessor(); @@ -58,6 +64,7 @@ public class CxfRsConsumerTest extends CamelTestSupport { errorHandler(new NoErrorHandlerBuilder()); from(CXF_RS_ENDPOINT_URI).process(testProcessor); from(CXF_RS_ENDPOINT_URI2).process(testProcessor); + from(CXF_RS_ENDPOINT_URI3).process(testProcessor); } }; } @@ -79,22 +86,24 @@ public class CxfRsConsumerTest extends CamelTestSupport { } @Test - public void testGetCustomer() throws Exception { - invokeGetCustomer("http://localhost:" + CXT + "/rest/customerservice/customers/126", - "{\"Customer\":{\"id\":126,\"name\":\"Willem\"}}"); - invokeGetCustomer("http://localhost:" + CXT + "/rest/customerservice/customers/123", - "customer response back!"); - invokeGetCustomer("http://localhost:" + CXT + "/rest/customerservice/customers/400", - "The remoteAddress is 127.0.0.1"); - + public void testGetCustomerInterface() throws Exception { + doTestGetCustomer("rest"); } @Test - public void testGetCustomer2() throws Exception { - invokeGetCustomer("http://localhost:" + CXT + "/rest2/customerservice/customers/126", + public void testGetCustomerImpl() throws Exception { + doTestGetCustomer("rest2"); + } + @Test + public void testGetCustomerInterfaceAndModel() throws Exception { + doTestGetCustomer("rest3"); + } + + private void doTestGetCustomer(String contextUri) throws Exception { + invokeGetCustomer("http://localhost:" + CXT + "/" + contextUri + "/customerservice/customers/126", "{\"Customer\":{\"id\":126,\"name\":\"Willem\"}}"); - invokeGetCustomer("http://localhost:" + CXT + "/rest2/customerservice/customers/123", + invokeGetCustomer("http://localhost:" + CXT + "/" + contextUri + "/customerservice/customers/123", "customer response back!"); - invokeGetCustomer("http://localhost:" + CXT + "/rest2/customerservice/customers/400", + invokeGetCustomer("http://localhost:" + CXT + "/" + contextUri + "/customerservice/customers/400", "The remoteAddress is 127.0.0.1"); } http://git-wip-us.apache.org/repos/asf/camel/blob/46c5abcb/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceNoAnnotations.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceNoAnnotations.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceNoAnnotations.java new file mode 100644 index 0000000..b8b97ed --- /dev/null +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerServiceNoAnnotations.java @@ -0,0 +1,27 @@ +/** + * 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.apache.camel.component.cxf.jaxrs.testbean; + + + +// START SNIPPET: example +public interface CustomerServiceNoAnnotations { + + Customer getCustomer(String id); + +} +// END SNIPPET: example http://git-wip-us.apache.org/repos/asf/camel/blob/46c5abcb/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CustomerServiceModel.xml ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CustomerServiceModel.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CustomerServiceModel.xml new file mode 100644 index 0000000..4d4e392 --- /dev/null +++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CustomerServiceModel.xml @@ -0,0 +1,23 @@ + + + + + + + +