Author: wtam Date: Tue Feb 3 04:51:02 2009 New Revision: 740209 URL: http://svn.apache.org/viewvc?rev=740209&view=rev Log: [CAMEL-1308] camel-cxf to support jaxrs consumer (WIP)
Added: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsComponent.java (with props) camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumer.java (with props) camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsEndpoint.java (with props) camel/trunk/components/camel-cxf/src/main/resources/META-INF/services/org/apache/camel/component/cxf-jaxrs camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest.java (with props) camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Customer.java (with props) camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java (with props) camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Order.java (with props) camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Product.java (with props) camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest-context.xml (with props) Modified: camel/trunk/components/camel-cxf/pom.xml camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java Modified: camel/trunk/components/camel-cxf/pom.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/pom.xml?rev=740209&r1=740208&r2=740209&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/pom.xml (original) +++ camel/trunk/components/camel-cxf/pom.xml Tue Feb 3 04:51:02 2009 @@ -101,6 +101,13 @@ </dependency> <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <version>3.1</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> </dependency> @@ -112,6 +119,12 @@ <dependency> <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf-version}</version> + </dependency> + + <dependency> + <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-core</artifactId> <version>${cxf-version}</version> <exclusions> Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java?rev=740209&r1=740208&r2=740209&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java (original) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java Tue Feb 3 04:51:02 2009 @@ -117,7 +117,7 @@ if (embedded != null) { if (type.isInstance(embedded)) { - return (T)embedded; + return type.cast(embedded); } else { TypeConverter tc = registry.lookup(type, embedded.getClass()); if (tc != null) { Added: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsComponent.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsComponent.java?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsComponent.java (added) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsComponent.java Tue Feb 3 04:51:02 2009 @@ -0,0 +1,38 @@ +/** + * 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; + +import java.util.Map; + +import org.apache.camel.Endpoint; +import org.apache.camel.impl.DefaultComponent; + +/** + * A CXF Component that supports JAX-RS endpoints. + * + * @version $Revision$ + */ +public class CxfJaxrsComponent extends DefaultComponent { + + @Override + protected Endpoint createEndpoint(String uri, String remaining, + Map parameters) throws Exception { + + return new CxfJaxrsEndpoint(remaining, this); + } + +} Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsComponent.java ------------------------------------------------------------------------------ svn:mergeinfo = Added: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumer.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumer.java?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumer.java (added) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumer.java Tue Feb 3 04:51:02 2009 @@ -0,0 +1,56 @@ +/** + * 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; + +import org.apache.camel.Processor; +import org.apache.camel.impl.DefaultConsumer; +import org.apache.cxf.endpoint.Server; +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; + +/** + * A consumer to consume RESTful web service requests from an endpoint. + * + * TODO: create Camel Exchange and pass it to processor. + * + * @version $Revision$ + */ +public class CxfJaxrsConsumer extends DefaultConsumer { + + private Server server; + + public CxfJaxrsConsumer(CxfJaxrsEndpoint endpoint, Processor processor) throws Exception { + super(endpoint, processor); + + // create server + JAXRSServerFactoryBean sf = endpoint.createServerFactoryBean(); + server = sf.create(); + + } + + @Override + protected void doStart() throws Exception { + super.doStart(); + server.start(); + } + + @Override + protected void doStop() throws Exception { + server.stop(); + super.doStop(); + } + +} Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumer.java ------------------------------------------------------------------------------ svn:mergeinfo = Added: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsEndpoint.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsEndpoint.java?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsEndpoint.java (added) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsEndpoint.java Tue Feb 3 04:51:02 2009 @@ -0,0 +1,92 @@ +/** + * 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; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.camel.Consumer; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.impl.DefaultEndpoint; +import org.apache.camel.util.ObjectHelper; +import org.apache.cxf.common.classloader.ClassLoaderUtils; +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; + +/** + * A Endpoint class that represents a CXF JAX-RS endpoint. + * + * @version $Revision$ + */ +public class CxfJaxrsEndpoint extends DefaultEndpoint { + + private List<String> resourceClassnames; + + public CxfJaxrsEndpoint(String remaining, CxfJaxrsComponent component) { + super(remaining, component); + } + + public boolean isSingleton() { + return true; + } + + public Consumer createConsumer(Processor processor) throws Exception { + return new CxfJaxrsConsumer(this, processor); + } + + /** + * Producer for Jaxrs endpoint is not supported. This method will throw + * {...@link UnsupportedOperationException}. + */ + public Producer createProducer() throws Exception { + throw new UnsupportedOperationException("Producer is not supported"); + } + + /** + * @param resourceClassnames the resourceClassnames to set + */ + public void setResourceClassnames(List<String> resourceClassnames) { + this.resourceClassnames = resourceClassnames; + } + + /** + * @return the resourceClassnames + */ + public List<String> getResourceClassnames() { + return resourceClassnames; + } + + /** + * @return + */ + public JAXRSServerFactoryBean createServerFactoryBean() throws Exception { + JAXRSServerFactoryBean answer = new JAXRSServerFactoryBean(); + ObjectHelper.notNull(resourceClassnames, "resourceClassnames is not set"); + answer.setResourceClasses(loadClasses(resourceClassnames)); + answer.setAddress(getEndpointUri()); + return answer; + } + + private List<Class> loadClasses(List<String> classNames) throws ClassNotFoundException { + List<Class> answer = new ArrayList<Class>(); + for (String className : classNames) { + answer.add(ClassLoaderUtils.loadClass(className, getClass())); + } + return answer; + } + +} Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsEndpoint.java ------------------------------------------------------------------------------ svn:mergeinfo = Added: camel/trunk/components/camel-cxf/src/main/resources/META-INF/services/org/apache/camel/component/cxf-jaxrs URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/resources/META-INF/services/org/apache/camel/component/cxf-jaxrs?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/main/resources/META-INF/services/org/apache/camel/component/cxf-jaxrs (added) +++ camel/trunk/components/camel-cxf/src/main/resources/META-INF/services/org/apache/camel/component/cxf-jaxrs Tue Feb 3 04:51:02 2009 @@ -0,0 +1,18 @@ +# +# 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. +# + +class=org.apache.camel.component.cxf.jaxrs.CxfJaxrsComponent Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest.java?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest.java (added) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest.java Tue Feb 3 04:51:02 2009 @@ -0,0 +1,113 @@ +/** + * 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; + +import java.io.InputStream; +import java.net.URL; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.PutMethod; +import org.apache.commons.httpclient.methods.RequestEntity; +import org.apache.commons.httpclient.methods.StringRequestEntity; +import org.apache.cxf.helpers.IOUtils; +import org.apache.cxf.io.CachedOutputStream; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests; + +/** + * + * @version $Revision$ + */ +...@contextconfiguration +public class CxfJaxrsConsumerTest extends AbstractJUnit38SpringContextTests { + + private static final String PUT_REQUEST = "<Customer><name>Mary</name><id>123</id></Customer>"; + private static final String POST_REQUEST = "<Customer><name>Jack</name></Customer>"; + + @Autowired + protected CamelContext context; + + public static class TestRouteBuilder extends RouteBuilder { + @Override + public void configure() throws Exception { + from("cxf-jaxrs://http://localhost:9000?resourceClassnames=#resourceClasses").process(new Processor() { + public void process(Exchange exchange) throws Exception { + // TODO have not implemented passing exchange to processor. + } + + }); + + } + } + + public void testGetConsumer() throws Exception { + URL url = new URL("http://localhost:9000/customerservice/customers/123"); + InputStream in = url.openStream(); + assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", getStringFromInputStream(in)); + + url = new URL("http://localhost:9000/customerservice/orders/223/products/323"); + in = url.openStream(); + assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}", getStringFromInputStream(in)); + + } + + public void testPutConsumer() throws Exception { + PutMethod put = new PutMethod("http://localhost:9000/customerservice/customers"); + RequestEntity entity = new StringRequestEntity(PUT_REQUEST, "text/xml", "ISO-8859-1"); + put.setRequestEntity(entity); + HttpClient httpclient = new HttpClient(); + + try { + assertEquals(200, httpclient.executeMethod(put)); + assertEquals("", put.getResponseBodyAsString()); + } finally { + put.releaseConnection(); + } + } + + public void testPostConsumer() throws Exception { + PostMethod post = new PostMethod("http://localhost:9000/customerservice/customers"); + post.addRequestHeader("Accept" , "text/xml"); + RequestEntity entity = new StringRequestEntity(POST_REQUEST, "text/xml", "ISO-8859-1"); + post.setRequestEntity(entity); + HttpClient httpclient = new HttpClient(); + + try { + assertEquals(200, httpclient.executeMethod(post)); + assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Customer><id>124</id><name>Jack</name></Customer>", + post.getResponseBodyAsString()); + } finally { + post.releaseConnection(); + } + + } + + private static String getStringFromInputStream(InputStream in) throws Exception { + CachedOutputStream bos = new CachedOutputStream(); + IOUtils.copy(in, bos); + in.close(); + bos.close(); + return bos.getOut().toString(); + } + +} Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Customer.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Customer.java?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Customer.java (added) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Customer.java Tue Feb 3 04:51:02 2009 @@ -0,0 +1,45 @@ +/** + * 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; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @version $Revision$ + */ +...@xmlrootelement(name = "Customer") +public class Customer { + private long id; + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Customer.java ------------------------------------------------------------------------------ svn:mergeinfo = Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java (added) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java Tue Feb 3 04:51:02 2009 @@ -0,0 +1,115 @@ +/** + * 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; + +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + + + +/** + * + * @version $Revision$ + */ +...@path("/customerservice/") +public class CustomerService { + long currentId = 123; + Map<Long, Customer> customers = new HashMap<Long, Customer>(); + Map<Long, Order> orders = new HashMap<Long, Order>(); + + public CustomerService() { + init(); + } + + @GET + @Path("/customers/{id}/") + public Customer getCustomer(@PathParam("id") String id) { + long idNumber = Long.parseLong(id); + Customer c = customers.get(idNumber); + return c; + } + + @PUT + @Path("/customers/") + public Response updateCustomer(Customer customer) { + Customer c = customers.get(customer.getId()); + Response r; + if (c != null) { + customers.put(customer.getId(), customer); + r = Response.ok().build(); + } else { + r = Response.notModified().build(); + } + + return r; + } + + @POST + @Path("/customers/") + public Response addCustomer(Customer customer) { + customer.setId(++currentId); + + customers.put(customer.getId(), customer); + + return Response.ok(customer).build(); + } + + @DELETE + @Path("/customers/{id}/") + public Response deleteCustomer(@PathParam("id") String id) { + long idNumber = Long.parseLong(id); + Customer c = customers.get(idNumber); + + Response r; + if (c != null) { + r = Response.ok().build(); + customers.remove(idNumber); + } else { + r = Response.notModified().build(); + } + + return r; + } + + @Path("/orders/{orderId}/") + public Order getOrder(@PathParam("orderId") String orderId) { + long idNumber = Long.parseLong(orderId); + Order c = orders.get(idNumber); + return c; + } + + final void init() { + Customer c = new Customer(); + c.setName("John"); + c.setId(123); + customers.put(c.getId(), c); + + Order o = new Order(); + o.setDescription("order 223"); + o.setId(223); + orders.put(o.getId(), o); + } + +} Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java ------------------------------------------------------------------------------ svn:mergeinfo = Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Order.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Order.java?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Order.java (added) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Order.java Tue Feb 3 04:51:02 2009 @@ -0,0 +1,72 @@ +/** + * 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; + +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @version $Revision$ + */ +...@xmlrootelement(name = "Order") +public class Order { + private long id; + private String description; + private Map<Long, Product> products = new HashMap<Long, Product>(); + + public Order() { + init(); + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String d) { + this.description = d; + } + + @GET + @Path("products/{productId}/") + public Product getProduct(@PathParam("productId")int productId) { + System.out.println("----invoking getProduct with id: " + productId); + Product p = products.get(new Long(productId)); + return p; + } + + final void init() { + Product p = new Product(); + p.setId(323); + p.setDescription("product 323"); + products.put(p.getId(), p); + } + +} Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Order.java ------------------------------------------------------------------------------ svn:mergeinfo = Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Product.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Product.java?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Product.java (added) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Product.java Tue Feb 3 04:51:02 2009 @@ -0,0 +1,45 @@ +/** + * 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; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @version $Revision$ + */ +...@xmlrootelement(name = "Product") +public class Product { + private long id; + private String description; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String d) { + this.description = d; + } +} Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/Product.java ------------------------------------------------------------------------------ svn:mergeinfo = Added: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest-context.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest-context.xml?rev=740209&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest-context.xml (added) +++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest-context.xml Tue Feb 3 04:51:02 2009 @@ -0,0 +1,42 @@ +<?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:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://activemq.apache.org/camel/schema/spring + http://activemq.apache.org/camel/schema/spring/camel-spring.xsd + http://activemq.apache.org/camel/schema/cxfEndpoint + http://activemq.apache.org/camel/schema/cxfEndpoint/camel-cxf.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util-2.0.xsd + "> + + <camelContext id="camel" + xmlns="http://activemq.apache.org/camel/schema/spring"> + </camelContext> + + <bean id="routeBuilder" + class="org.apache.camel.component.cxf.jaxrs.CxfJaxrsConsumerTest$TestRouteBuilder" /> + + <util:list id="resourceClasses"> + <value>org.apache.camel.component.cxf.jaxrs.testbean.CustomerService</value> + </util:list> + +</beans> \ No newline at end of file Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest-context.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest-context.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfJaxrsConsumerTest-context.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml