Author: ffang
Date: Fri Jun 21 08:16:43 2013
New Revision: 1495319
URL: http://svn.apache.org/r1495319
Log:
[SM-2190]A REST example with camel-cxf
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/README.txt
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/pom.xml
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/camel/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/camel/rest/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/camel/rest/client/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/camel/rest/client/Client.java
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/pom.xml
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/examples/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/examples/camel/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/examples/camel/rest/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/examples/camel/rest/PersonService.java
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/resources/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/resources/OSGI-INF/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/resources/OSGI-INF/blueprint/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/pom.xml
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/ServiceHandler.java
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/model/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/model/Person.java
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/resources/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/resources/OSGI-INF/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/resources/OSGI-INF/blueprint/
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/pom.xml
Modified:
servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
servicemix/smx5/trunk/examples/camel/pom.xml
Modified:
servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml?rev=1495319&r1=1495318&r2=1495319&view=diff
==============================================================================
---
servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
(original)
+++
servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
Fri Jun 21 08:16:43 2013
@@ -113,6 +113,10 @@
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools/${drools.bundle.version}</bundle>
<bundle>mvn:org.apache.servicemix.examples/camel-drools-blueprint/${version}</bundle>
</feature>
+ <feature name="examples-camel-cxf-rest" version="${version}"
resolver="(obr)">
+
<bundle>mvn:org.apache.servicemix.examples/camel-cxf-rest-service/${version}</bundle>
+
<bundle>mvn:org.apache.servicemix.examples/camel-cxf-rest-route/${version}</bundle>
+ </feature>
<feature name="examples-cxf-ws-addressing" version="${version}"
resolver="(obr)">
<feature version="${cxf.version}">cxf</feature>
<bundle
dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jbi-api-1.0/${servicemix.specs.version}</bundle>
Added: servicemix/smx5/trunk/examples/camel/camel-cxf-rest/README.txt
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/README.txt?rev=1495319&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-cxf-rest/README.txt (added)
+++ servicemix/smx5/trunk/examples/camel/camel-cxf-rest/README.txt Fri Jun 21
08:16:43 2013
@@ -0,0 +1,209 @@
+/*
+ * 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.
+ */
+
+CAMEL CXF REST EXAMPLE
+======================
+
+Purpose
+-------
+Create a RESTful JAX-RS web service using CXF and handle it using the
+Camel-cxfrs SimpleConsumer
+
+
+Explanation
+-----------
+The web service functions are defined in the PersonService.java file,
+which is located in the camel-cxf-rest-route/src/main/java/org/apache/
+servicemix/examples/camel/rest directory of this example. It contains
+annotations indicating what URIs and HTTP methods to use when accessing
+the resource. For information on how to write RESTful web services,
+please refer to the Apache CXF documentation.
+
+
+The blueprint.xml file located in the camel-cxf-rest-route/src/main/
+resources/OSGI-INF/blueprint folder:
+
+1. Configures the rsServer:
+
+ <cxf:rsServer id="rsServer" address="${CXFserver}${service}"
+ serviceClass="org.apache.servicemix.examples.camel.rest.PersonService"
+ loggingFeatureEnabled="true" loggingSizeLimit="20"/>
+
+2. Initializes the Camel route PersinServiceRoute wich routes each
+REST method call to a seperate endpoint:
+
+ <from uri="cxfrs:bean:rsServer?bindingStyle=SimpleConsumer" />
+ <recipientList>
+ <simple>direct-vm:${header.operationName}</simple>
+ </recipientList>
+
+
+The blueprint.xml file located in the camel-cxf-rest-service/src/main/
+resources/OSGI-INF/blueprint folder:
+
+1. Initializes the ServiceHandler bean implemented in the
+ServiceHandler.java file, located in the camel-cxf-rest-service/
+src/main/java/org/apache/servicemix/examples/camel/rest
+
+2. Defines severeal routes to consume the Rest method endpoints
+using the ServiceHandler bean.
+
+
+The Client.java file located in the camel-cxf-rest-client/src/main/
+java/org/apache/servicemix/examples/camel/rest/client folder provades
+a small test client that calls each provided REST method and displays
+the result.
+
+
+Prerequisites for Running the Example
+-------------------------------------
+1. You must have the following installed on your machine:
+
+ - JDK 1.6 or higher
+
+ - Maven 2.2.1 or higher
+
+ For more information, see the README in the top-level examples
+ directory.
+
+2. Start ServiceMix by running the following command:
+
+ <servicemix_home>/bin/servicemix (on UNIX)
+ <servicemix_home>\bin\servicemix (on Windows)
+
+
+Running the Example
+-------------------
+You can run the example in two ways:
+
+- A. Using a Prebuilt Deployment Bundle: Quick and Easy
+This option is useful if you want to see the example up and
+running as quickly as possible.
+
+- B. Building the Example Bundle Yourself
+This option is useful if you want to change the example in any
+way. It tells you how to build and deploy the example. This
+option might be slower than option A because, if you do not
+already have the required bundles in your local Maven
+repository, Maven will have to download the bundles it needs.
+
+
+A. Using a Prebuilt Deployment Bundle: Quick and Easy
+-----------------------------------------------------
+To install and run a prebuilt version of this example, enter
+the following command in the ServiceMix console:
+
+ features:install examples-camel-cxf-rest
+
+This command makes use of the ServiceMix features facility. For
+more information about the features facility, see the README.txt
+file in the examples parent directory.
+
+Running the Client
+------------------
+To run the java code client:
+
+1. Change to the
<servicemix_home>/examples/camel/camel-cxf-rest/camel-cxf-rest-client
+ directory.
+
+2. Run the following command:
+
+ mvn compile exec:java
+
+
+B. Building the Example Bundle Yourself
+---------------------------------------
+To install and run the example where you build the example bundle
+yourself, complete the following steps:
+
+1. If you have already run the example using the prebuilt version as
+ described above, you must first uninstall the examples-camel-cxf-rest
+ feature by entering the following command in the ServiceMix console:
+
+ features:uninstall examples-camel-cxf-rest
+
+2. Build the example by opening a command prompt, changing directory to
+ examples/camel/camel-cxf-rest (this example) and entering the following
Maven
+ command:
+
+ mvn install
+
+ If all of the required OSGi bundles are available in your local Maven
+ repository, the example will build very quickly. Otherwise it may
+ take some time for Maven to download everything it needs.
+
+ The mvn install command builds the example deployment bundle and
+ copies it to your local Maven repository and to the target directory
+ of this example.
+
+3. Install the example by entering the following command in
+ the ServiceMix console:
+
+ features:install examples-camel-cxf-rest
+
+ It makes use of the ServiceMix features facility. For more information
+ about the features facility, see the README.txt file in the examples
+ parent directory.
+
+See "Running the Client" above for information on how to make invocations
+on the web service.
+
+
+Stopping and Uninstalling the Example
+-------------------------------------
+To stop the example, you must first know the bundle IDs that ServiceMix
+has assigned to the example bundels. To get the bundle IDs, enter the
+following command in the ServiceMix console (Note, the text you are
+typing will intermingle with the output being logged. This is nothing
+to worry about.):
+
+ osgi:list
+
+At the end of the listing, you should see an entry similar to the
+following:
+
+ [ 173] [Active ] [Created ] [ ] [ 80] Apache ServiceMix ::
Examples :: Camel CXF REST :: Service (5.0.0.SNAPSHOT)
+ [ 175] [Active ] [Created ] [ ] [ 80] Apache ServiceMix ::
Examples :: Camel CXF REST :: Route (5.0.0.SNAPSHOT)
+
+In this case, the bundle IDs are 173 and 175.
+
+To stop a bundle, enter the following command in the ServiceMix
+console:
+
+ osgi:stop <bundle_id>
+
+For example:
+
+ osgi:stop 173
+
+To uninstall the example, enter one of the following commands at
+the ServiceMix console:
+
+ features:uninstall examples-camel-cxf-rest
+
+or
+
+ osgi:uninstall <bundle_id>
+
+
+Viewing the Log Entries
+-----------------------
+You can view the entries in the log file in the data/log
+directory of your ServiceMix installation, or by typing
+the following command in the ServiceMix console:
+
+ log:display
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/pom.xml?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/pom.xml
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/pom.xml
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!--
+ 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.
+ -->
+
+ <parent>
+ <artifactId>camel-cxf-rest</artifactId>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <version>5.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-cxf-rest-client</artifactId>
+ <name>Apache ServiceMix :: Examples :: Camel CXF REST :: Client</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <artifactId>camel-cxf-rest-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.2.5</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <configuration>
+
<mainClass>org.apache.servicemix.examples.camel.rest.client.Client</mainClass>
+
<includePluginDependencies>false</includePluginDependencies>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/camel/rest/client/Client.java
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/camel/rest/client/Client.java?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/camel/rest/client/Client.java
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-client/src/main/java/org/apache/servicemix/examples/camel/rest/client/Client.java
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,90 @@
+/**
+ * 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.servicemix.examples.camel.rest.client;
+
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.servicemix.examples.camel.rest.model.Person;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class Client {
+ private static final String PERSON_SERVICE_URL =
"http://localhost:8989/rest/personservice/";
+
+
+ public static void main(String[] args) {
+ Client client = new Client();
+ try {
+ client.postPerson(new Person(1,"John Smith",21));
+ client.getPerson(1);
+ client.deletePerson(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void postPerson(Person person) throws Exception{
+ System.out.println("\n### POST PERSON -> ");
+ URLConnection connection = connect(PERSON_SERVICE_URL+"person/post/");
+ connection.setDoOutput(true);
+ connection.setRequestProperty("Content-Type", "application/xml");
+
+ JAXBContext jaxbContext = JAXBContext.newInstance(Person.class);
+ Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
+
+ // pretty xml output
+ jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+
+ jaxbMarshaller.marshal(person, System.out);
+ jaxbMarshaller.marshal(person, connection.getOutputStream());
+
+ System.out.println("\n### POST PERSON RESPONSE ");
+ System.out.println(IOUtils.toString(connection.getInputStream()));
+ }
+
+ public void getPerson(int id) throws Exception{
+ String url = PERSON_SERVICE_URL+"person/get/"+id;
+ System.out.println("\n### GET PERSON WITH ID "+id+" FROM URL "+url);
+ URLConnection connection = connect(url);
+ connection.setDoInput(true);
+ System.out.println("\n### GET PERSON RESPONSE");
+ System.out.println(IOUtils.toString(connection.getInputStream()));
+
+ }
+
+ public void deletePerson(int id) throws Exception{
+ String url = PERSON_SERVICE_URL+"person/delete/"+id;
+ System.out.println("\n### DELETE PERSON WITH ID "+id+" FROM URL "+url);
+ HttpURLConnection httpConnection = (HttpURLConnection) connect(url);
+ httpConnection.setRequestMethod("DELETE");
+ httpConnection.setDoInput(true);
+ System.out.println("\n### DELETE PERSON RESPONSE");
+ System.out.println(IOUtils.toString(httpConnection.getInputStream()));
+
+ }
+
+ private URLConnection connect(String url) throws Exception{
+ URLConnection connection = new URL(url).openConnection();
+ return connection;
+ }
+
+
+}
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/pom.xml?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/pom.xml
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/pom.xml
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!--
+ 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.
+ -->
+ <parent>
+ <artifactId>camel-cxf-rest</artifactId>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <version>5.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-cxf-rest-route</artifactId>
+ <name>Apache ServiceMix :: Examples :: Camel CXF REST :: Route</name>
+ <packaging>bundle</packaging>
+
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <artifactId>camel-cxf-rest-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+
<Bundle-Description>${project.description}</Bundle-Description>
+ <Import-Package>*;resolution:=optional</Import-Package>
+
<Private-Package>org.apache.servicemix.examples.camel.rest</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/examples/camel/rest/PersonService.java
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/examples/camel/rest/PersonService.java?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/examples/camel/rest/PersonService.java
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/java/org/apache/servicemix/examples/camel/rest/PersonService.java
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,51 @@
+/**
+ * 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.servicemix.examples.camel.rest;
+
+import org.apache.servicemix.examples.camel.rest.model.Person;
+
+import javax.ws.rs.*;
+
+// This could be an interface if CAMEL-6014 is fixed.
+
+@Path("/personservice/")
+public class PersonService {
+ @PathParam("id")
+ private String id;
+
+ @GET
+ @Path("/person/get/{id}/")
+ @Produces("application/xml")
+ public Person getPerson(@PathParam("id") String id) {
+ return null;
+ }
+
+ @POST
+ @Path("/person/post")
+ @Produces("application/xml")
+ public Person putPerson(Person p) {
+ return null;
+ }
+
+ @DELETE
+ @Path("/person/delete/{id}")
+ @Produces("application/xml")
+ public Person deletePerson(@PathParam("id") String id) {
+ return null;
+ }
+}
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-route/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,49 @@
+<?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.
+
+-->
+
+<blueprint
+ xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <cm:property-placeholder
persistent-id="org.apache.servicemix.examples.cxf.receive"
update-strategy="reload">
+ <cm:default-properties>
+ <cm:property name="CXFserver" value="http://localhost:8989/"/>
+ <cm:property name="service" value="rest" />
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <cxf:rsServer id="rsServer" address="${CXFserver}${service}"
+
serviceClass="org.apache.servicemix.examples.camel.rest.PersonService"
+ loggingFeatureEnabled="true" loggingSizeLimit="20"/>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint" >
+ <route id="PersonServiceRoute">
+ <from uri="cxfrs:bean:rsServer?bindingStyle=SimpleConsumer" />
+ <recipientList>
+ <simple>direct-vm:${header.operationName}</simple>
+ </recipientList>
+ </route>
+ </camelContext>
+</blueprint>
+
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/pom.xml?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/pom.xml
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/pom.xml
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!--
+ 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.
+ -->
+
+ <parent>
+ <artifactId>camel-cxf-rest</artifactId>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <version>5.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-cxf-rest-service</artifactId>
+ <name>Apache ServiceMix :: Examples :: Camel CXF REST :: Service</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+
<Bundle-Description>${project.description}</Bundle-Description>
+ <Import-Package>*;resolution:=optional</Import-Package>
+
<Private-Package>org.apache.servicemix.examples.camel.rest</Private-Package>
+
<Export-Package>org.apache.servicemix.examples.camel.rest.model</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/ServiceHandler.java
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/ServiceHandler.java?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/ServiceHandler.java
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/ServiceHandler.java
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,63 @@
+/**
+ * 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.servicemix.examples.camel.rest;
+
+import org.apache.servicemix.examples.camel.rest.model.Person;
+
+import java.util.ArrayList;
+
+public class ServiceHandler {
+
+ ArrayList<Person> persons = new ArrayList<Person>();
+
+ public void init(){
+ add(new Person(0,"test",100));
+ }
+
+ private void add(Person person){
+ persons.add(person.getId(),person);
+ }
+
+ private Person get(int id){
+ return persons.get(id);
+ }
+
+ private void delete(int id){
+ persons.remove(id);
+ }
+
+ public Person getPerson(String id){
+ return get(Integer.parseInt(id));
+ }
+
+ public Person putPerson(Person person){
+ add(person);
+ return person;
+ }
+
+ public String deletePerson(int id){
+ delete(id);
+ return new String();
+ }
+
+
+
+
+
+
+}
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/model/Person.java
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/model/Person.java?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/model/Person.java
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/java/org/apache/servicemix/examples/camel/rest/model/Person.java
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,73 @@
+/**
+ * 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.servicemix.examples.camel.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement
+public class Person {
+ private String name;
+ private int age;
+ private int id;
+
+ public Person(int id, String name, int age) {
+ this.name = name;
+ this.age = age;
+ this.id = id;
+ }
+
+ public Person() {
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Person person = (Person) o;
+
+ if (id != person.id) return false;
+
+ return true;
+ }
+}
Added:
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1495319&view=auto
==============================================================================
---
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(added)
+++
servicemix/smx5/trunk/examples/camel/camel-cxf-rest/camel-cxf-rest-service/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Fri Jun 21 08:16:43 2013
@@ -0,0 +1,54 @@
+<?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.
+
+-->
+<blueprint
+ xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
+ http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <bean id="serviceHandler"
class="org.apache.servicemix.examples.camel.rest.ServiceHandler"
init-method="init" />
+
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint" >
+ <route id="getPerson">
+ <from uri="direct-vm:getPerson" />
+ <transform>
+ <simple>${header.id}</simple>
+ </transform>
+ <log message="getPerson invocation with id: ${body}"/>
+ <bean method="getPerson" ref="serviceHandler"/>
+ </route>
+ <route id="putPerson">
+ <from uri="direct-vm:putPerson" />
+ <log message="putPerson invocation with body: ${body}"/>
+ <bean method="putPerson" ref="serviceHandler"/>
+ </route>
+ <route id="deletePerson">
+ <from uri="direct-vm:deletePerson" />
+ <transform>
+ <simple>${header.id}</simple>
+ </transform>
+ <log message="deletePerson invocation with id: ${body}"/>
+ <bean method="deletePerson" ref="serviceHandler"/>
+ </route>
+ </camelContext>
+
+</blueprint>
Added: servicemix/smx5/trunk/examples/camel/camel-cxf-rest/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-cxf-rest/pom.xml?rev=1495319&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-cxf-rest/pom.xml (added)
+++ servicemix/smx5/trunk/examples/camel/camel-cxf-rest/pom.xml Fri Jun 21
08:16:43 2013
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <parent>
+ <artifactId>camel-examples</artifactId>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <version>5.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>camel-cxf-rest</artifactId>
+ <name>Apache ServiceMix :: Examples :: Camel CXF REST</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>camel-cxf-rest-route</module>
+ <module>camel-cxf-rest-service</module>
+ <module>camel-cxf-rest-client</module>
+ </modules>
+
+</project>
\ No newline at end of file
Modified: servicemix/smx5/trunk/examples/camel/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/pom.xml?rev=1495319&r1=1495318&r2=1495319&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/camel/pom.xml (original)
+++ servicemix/smx5/trunk/examples/camel/pom.xml Fri Jun 21 08:16:43 2013
@@ -38,6 +38,7 @@
<module>camel-drools</module>
<module>camel-drools-blueprint</module>
<module>camel-sql</module>
+ <module>camel-cxf-rest</module>
</modules>
</project>