http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala ---------------------------------------------------------------------- diff --git a/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala b/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala deleted file mode 100644 index 36fc9a7..0000000 --- a/examples/akka/akka-camel/src/test/scala/org/apache/servicemix/examples/akka/StatsTest.scala +++ /dev/null @@ -1,73 +0,0 @@ -/** - * 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.akka - -import org.junit.Test -import org.junit.Assert.fail -import akka.actor.ActorSystem -import akka.pattern._ -import akka.util.Timeout -import akka.util.duration._ -import akka.dispatch.Await -import org.apache.servicemix.examples.akka.Stats.{Input, Report} -import java.util.concurrent.TimeoutException - -/** - * Test case for the stats actor - */ -class StatsTest { - - val ITEM1 = "ITEM1" - val MAX_ATTEMPTS = 10 - - val system = ActorSystem("TestSystem") - val stats = Stats(system) - - implicit val timeout = Timeout(100 millis) // needed for `?` below - - @Test - def testCountAverageAndStddev() { - stats ! Input(ITEM1, 10) - stats ! Input(ITEM1, 20) - - // we expect ITEM1's count, average and standard deviation to be in the report - expectReport("ITEM1,2,15.0000,4.8990") - } - - /* - * Wait for report to contain expected output - */ - def expectReport(expectation: String) : Unit = expectReport(expectation, MAX_ATTEMPTS) - - def expectReport(expectation: String, remaining: Int) : Unit = getReport.contains(expectation) match { - case true => // do nothing here, w received our report - case false if (remaining <= 0) => fail("Did not receive reporting containing " + expectation) - case false => expectReport(expectation, remaining - 1) - } - - /* - * Get the stats engine report - if no report is available yet, this method will return a blank sheet - */ - def getReport : String = { - try { - Await.result(stats ? Report(), 100 millis).toString - } catch { - //Report() only sends back a response if it actually has something to tell - case e: TimeoutException => "" - } - } -}
http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/akka/pom.xml ---------------------------------------------------------------------- diff --git a/examples/akka/pom.xml b/examples/akka/pom.xml deleted file mode 100644 index b7106b4..0000000 --- a/examples/akka/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?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. - --> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.servicemix.examples</groupId> - <artifactId>examples</artifactId> - <version>4.5.0-SNAPSHOT</version> - </parent> - - <groupId>org.apache.servicemix.examples</groupId> - <artifactId>akka-examples</artifactId> - <packaging>pom</packaging> - <name>Apache ServiceMix :: Examples :: Akka</name> - - <modules> - <module>akka-camel</module> - </modules> - -</project> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-blueprint/README.txt ---------------------------------------------------------------------- diff --git a/examples/camel/camel-blueprint/README.txt b/examples/camel/camel-blueprint/README.txt deleted file mode 100644 index ac51cde..0000000 --- a/examples/camel/camel-blueprint/README.txt +++ /dev/null @@ -1,235 +0,0 @@ -/* - * 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 OSGI EXAMPLE -================== - -Purpose -------- -Deploys a Camel EIP route as an OSGi bundle using Blueprint. -Configuration makes use of the OSGi Configuration Admin service and -Blueprint property placeholders, and the example demonstrates how to -deploy the properties file from the ServiceMix console. - - -Explanation ------------ -The Camel route is defined in a Blueprint XML file, blueprint.xml, which can be -found in the src/main/resources/OSGI-INF/blueprint directory of this example. -The route is defined in the <route> element and can be explained as follows: - -1. A timer endpoint generates a heartbeat event every 2000ms. - -2. A callout is made to a transformer bean that transforms each - heartbeat message to the current date and time. - -3. A log endpoint sends the transformed message to the - Jakarta commons logger. - -The blueprint.xml file also contains the following elements: - -- A <bean> element that instantiates the transformer bean using standard - Blueprint configuration syntax and specifies a prefix value using a - property placeholder. - -- An <cm:property-placeholder> element which allows you to specify placeholder - values using the OSGi Configuration Admin service. In this case, the - property is also given the default value of "MyTransform". - -The route and configuration are deployed in an OSGi bundle. - - -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 building) - - 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 quickly. - -- 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-blueprint - -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. - -Once the example is running, periodic events are routed to the transform -method of the MyTransform class and you should see output similar to the -following being logged to your console screen: - ->>>> Blueprint-Example set body: Tue Jan 04 10:23:39 CET 2011 ->>>> Blueprint-Example set body: Tue Jan 04 10:23:41 CET 2011 ->>>> Blueprint-Example set body: Tue Jan 04 10:23:43 CET 2011 - -Updating and Redeploying the Properties File from the Console -------------------------------------------------------------- -You can update and redeploy the properties file that is used by the -properties placeholder in the blueprint.xml from console as follows: - -1. Edit the org.apache.servicemix.examples.cfg file, located in the - same folder as this README, by changing the value of the "prefix" - key to whatever you want (for example, YourTransform). - -2. Copy the updated configuration file to your <servicemix_home>/etc - directory. You can do this from the ServiceMix console by typing: - - copy $YOUR_SERVICEMIX_HOME/examples/camel/camel-blueprint/org.apache.servicemix.examples.cfg - $YOUR_SERVICEMIX_HOME/etc - - On Windows you need to replace / in the path with \\. - - Note, the text you are typing might intermingle with the output - being logged. This is nothing to worry about. - -3. Restart the example bundle: - - (i) First you must know the bundle ID that ServiceMix has assigned - to it. To get the bundle ID, enter the following command in the - ServiceMix console: - - osgi:list - - At the end of the listing, you should see an entry similar to - the following: - - [158] [Active ] [Started ] [ 60] Apache ServiceMix Example :: Camel OSGi (4.1.0) - - In this case, the bundle ID is 158. - - (ii) Enter the following command in the ServiceMix console to - restart the bundle: - - osgi:restart <bundle_id> - - The prefix of the output should change, and the output should look - similar to the following: - - >>>> YourTransform set body: Tue Aug 11 17:14:12 BST 2009 - >>>> YourTransform set body: Tue Aug 11 17:14:14 BST 2009 - >>>> YourTransform set body: Tue Aug 11 17:14:16 BST 2009 - -For information on how to stop and/or uninstall the example, see -"Stopping and Uninstalling the Example" below. - - -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-blueprint - feature by entering the following command in the ServiceMix console: - - features:uninstall examples-camel-blueprint - -2. Build the example by opening a command prompt, changing directory to - examples/camel/camel-blueprint (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-blueprint - - 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. - -Once the example is running, periodic events are routed to the -transform method of the MyTransform class and you should see output -similar to the following being logged to your console screen: - ->>>> Blueprint-Example set body: Tue Jan 04 10:23:39 CET 2011 ->>>> Blueprint-Example set body: Tue Jan 04 10:23:41 CET 2011 ->>>> Blueprint-Example set body: Tue Jan 04 10:23:43 CET 2011 - -Now, if you have not already done so, try updating and redeploying, -from the console, the properties file that is used by the properties -placeholder in the blueprint.xml file. For details on how to do this, see -the "Updating and Redeploying the Properties File from the Console" -section above. - - -Stopping and Uninstalling the Example -------------------------------------- -To stop the example, enter the following command in the ServiceMix -console: - - osgi:stop <bundle_id> - -For information on how to find the bundle_id assigned to the example, -see step 3 in the "Updating and Redeploying the Properties File -from the Console" section above. - -To uninstall the example, enter one of the following commands in -the ServiceMix console: - - features:uninstall examples-camel-blueprint - -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 http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-blueprint/org.apache.servicemix.examples.cfg ---------------------------------------------------------------------- diff --git a/examples/camel/camel-blueprint/org.apache.servicemix.examples.cfg b/examples/camel/camel-blueprint/org.apache.servicemix.examples.cfg deleted file mode 100644 index 16efba6..0000000 --- a/examples/camel/camel-blueprint/org.apache.servicemix.examples.cfg +++ /dev/null @@ -1,22 +0,0 @@ -# -# 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. -# -# - - -prefix=YourTransform http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-blueprint/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-blueprint/pom.xml b/examples/camel/camel-blueprint/pom.xml deleted file mode 100644 index 38ccead..0000000 --- a/examples/camel/camel-blueprint/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?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. - --> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.servicemix.examples</groupId> - <artifactId>camel-examples</artifactId> - <version>4.6.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-blueprint</artifactId> - <packaging>bundle</packaging> - <name>Apache ServiceMix :: Features :: Examples :: Camel Blueprint</name> - <description>Camel Example using blueprint for configuration</description> - - <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>*,org.apache.camel.osgi</Import-Package> - <Private-Package>org.apache.servicemix.examples.camel</Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-blueprint/src/main/java/org/apache/servicemix/examples/camel/MyTransform.java ---------------------------------------------------------------------- diff --git a/examples/camel/camel-blueprint/src/main/java/org/apache/servicemix/examples/camel/MyTransform.java b/examples/camel/camel-blueprint/src/main/java/org/apache/servicemix/examples/camel/MyTransform.java deleted file mode 100644 index d26596c..0000000 --- a/examples/camel/camel-blueprint/src/main/java/org/apache/servicemix/examples/camel/MyTransform.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * 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; - -import java.util.Date; -import java.util.logging.Logger; - -public class MyTransform { - - private static final transient Logger logger = Logger.getLogger(MyTransform.class.getName()); - private boolean verbose = true; - private String prefix = "MyTransform"; - - public Object transform(Object body) { - String answer = prefix + " set body: " + new Date(); - if (verbose) { - System.out.println(">>>> " + answer); - } - logger.info(">>>> " + answer); - return answer; - } - - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public String getPrefix() { - return prefix; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } -} http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/examples/camel/camel-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml deleted file mode 100644 index 05ed21e..0000000 --- a/examples/camel/camel-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?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:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/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"> - - <cm:property-placeholder persistent-id="org.apache.servicemix.examples"> - <cm:default-properties> - <cm:property name="prefix" value="Blueprint-Example"/> - </cm:default-properties> - </cm:property-placeholder> - - <camelContext xmlns="http://camel.apache.org/schema/blueprint"> - <route> - <from uri="timer://myTimer?fixedRate=true&period=2000" /> - <bean ref="myTransform" method="transform"/> - <to uri="log:ExampleRouterBlueprint" /> - </route> - </camelContext> - - <bean id="myTransform" class="org.apache.servicemix.examples.camel.MyTransform"> - <property name="prefix" value="${prefix}" /> - </bean> - -</blueprint> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-osgi/README.txt ---------------------------------------------------------------------- diff --git a/examples/camel/camel-osgi/README.txt b/examples/camel/camel-osgi/README.txt deleted file mode 100644 index 5907aeb..0000000 --- a/examples/camel/camel-osgi/README.txt +++ /dev/null @@ -1,237 +0,0 @@ -/* - * 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 OSGI EXAMPLE -================== - -Purpose -------- -Deploys a Camel EIP route as an OSGi bundle. Configuration makes use -of the OSGi Configuration Admin service and Spring property placeholders, -and the example demonstrates how to deploy the properties file from the -ServiceMix console. - - -Explanation ------------ - -This example provides two Camel routes: -- A XML route -- A Java route - - -XML Route ---------- -The Camel route is defined in a Spring XML file, beans.xml, which can be -found in the src/main/resources/META-INF/spring directory of this example. -The route is defined in the <route> element and can be explained as follows: - -1. A timer endpoint generates a heartbeat event every 2000ms. - -2. A callout is made to a transformer bean that transforms each - heartbeat message to the current date and time. - -3. A log endpoint sends the transformed message to the - Jakarta commons logger. - -The beans.xml file also contains the following elements: - -- A <bean> element that instantiates the transformer bean using standard - Spring configuration syntax and specifies a prefix value using a - property placeholder. - -- An <osgix:cm-properties> element which allows you to specify placeholder - values using the OSGi Configuration Admin service. In this case, the - property is also given the default value of "MyTransform". - -The route and configuration are deployed in an OSGi bundle. - -Java Route ---------- -The Java Camel route is defined in a Java soure file, MyRouteBuilder, which can be -found in the src/main/java/org/apache/servicemix/examples/camel directory -of this example. The route is similar to the XML route which is explained above. - - -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 building) - - 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 quickly. - -- 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-osgi - -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. - -Once the example is running, periodic events are routed to the transform -method of the MyTransform class and you should see output on your console screen. -The output should be from both the XML and Java Camel routes. - -Updating and Redeploying the Properties File from the Console -------------------------------------------------------------- -You can update and redeploy the properties file that is used by the -properties placeholder in the beans.xml from console as follows: - -1. Edit the org.apache.servicemix.examples.cfg file, located in the - same folder as this README, by changing the value of the "prefix" - key to whatever you want (for example, YourTransform). - -2. Copy the updated configuration file to your <servicemix_home>/etc - directory. You can do this from the ServiceMix console by typing: - - copy $YOUR_SERVICEMIX_HOME/examples/camel/camel-osgi/org.apache.servicemix.examples.cfg - $YOUR_SERVICEMIX_HOME/etc - - On Windows you need to replace / in the path with \\. - - Note, the text you are typing might intermingle with the output - being logged. This is nothing to worry about. - -3. Restart the example bundle: - - (i) First you must know the bundle ID that ServiceMix has assigned - to it. To get the bundle ID, enter the following command in the - ServiceMix console: - - osgi:list - - At the end of the listing, you should see an entry similar to - the following: - - [158] [Active ] [Started ] [ 60] Apache ServiceMix Example :: Camel OSGi (4.1.0) - - In this case, the bundle ID is 158. - - (ii) Enter the following command in the ServiceMix console to - restart the bundle: - - osgi:restart <bundle_id> - - The prefix of the output should change, and the output on the console should - be updated accordingly. - -For information on how to stop and/or uninstall the example, see -"Stopping and Uninstalling the Example" below. - - -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-osgi - feature by entering the following command in the ServiceMix console: - - features:uninstall examples-camel-osgi - -2. Build the example by opening a command prompt, changing directory to - examples/camel/camel-osgi (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-osgi - - 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. - -Once the example is running, periodic events are routed to the -transform method of the MyTransform class and you should see output -on your console screen. - -Now, if you have not already done so, try updating and redeploying, -from the console, the properties file that is used by the properties -placeholder in the beans.xml file. For details on how to do this, see -the "Updating and Redeploying the Properties File from the Console" -section above. - - -Stopping and Uninstalling the Example -------------------------------------- -To stop the example, enter the following command in the ServiceMix -console: - - osgi:stop <bundle_id> - -For information on how to find the bundle_id assigned to the example, -see step 3 in the "Updating and Redeploying the Properties File -from the Console" section above. - -To uninstall the example, enter one of the following commands in -the ServiceMix console: - - features:uninstall examples-camel-osgi - -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 http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-osgi/org.apache.servicemix.examples.cfg ---------------------------------------------------------------------- diff --git a/examples/camel/camel-osgi/org.apache.servicemix.examples.cfg b/examples/camel/camel-osgi/org.apache.servicemix.examples.cfg deleted file mode 100644 index 16efba6..0000000 --- a/examples/camel/camel-osgi/org.apache.servicemix.examples.cfg +++ /dev/null @@ -1,22 +0,0 @@ -# -# 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. -# -# - - -prefix=YourTransform http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-osgi/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-osgi/pom.xml b/examples/camel/camel-osgi/pom.xml deleted file mode 100644 index 50d10c8..0000000 --- a/examples/camel/camel-osgi/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?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. - --> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.servicemix.examples</groupId> - <artifactId>camel-examples</artifactId> - <version>4.6.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-osgi</artifactId> - <packaging>bundle</packaging> - <name>Apache ServiceMix :: Features :: Examples :: Camel OSGi</name> - <description>Camel example using OSGi instead of JBI</description> - - <dependencies> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-spring</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>*</Import-Package> - <Private-Package>org.apache.servicemix.examples.camel</Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-osgi/src/main/java/org/apache/servicemix/examples/camel/MyRouteBuilder.java ---------------------------------------------------------------------- diff --git a/examples/camel/camel-osgi/src/main/java/org/apache/servicemix/examples/camel/MyRouteBuilder.java b/examples/camel/camel-osgi/src/main/java/org/apache/servicemix/examples/camel/MyRouteBuilder.java deleted file mode 100644 index 7b27f7b..0000000 --- a/examples/camel/camel-osgi/src/main/java/org/apache/servicemix/examples/camel/MyRouteBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.spring.Main; - -/** - * A simple example router to show how to define the route with Java DSL - * - * @version $Revision$ - */ -public class MyRouteBuilder extends RouteBuilder { - /** - * Allow this route to be run as an application - * - * @param args - */ - public static void main(String[] args) throws Exception{ - new Main().run(args); - } - - public void configure() { - // set up the transform bean - MyTransform transform = new MyTransform(); - transform.setPrefix("JavaDSL"); - - from("timer://javaTimer?fixedRate=true&period=2000") - .bean(transform, "transform") - .to("log:ExampleRouter"); - } - - -} http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-osgi/src/main/java/org/apache/servicemix/examples/camel/MyTransform.java ---------------------------------------------------------------------- diff --git a/examples/camel/camel-osgi/src/main/java/org/apache/servicemix/examples/camel/MyTransform.java b/examples/camel/camel-osgi/src/main/java/org/apache/servicemix/examples/camel/MyTransform.java deleted file mode 100644 index 0895bf2..0000000 --- a/examples/camel/camel-osgi/src/main/java/org/apache/servicemix/examples/camel/MyTransform.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * 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; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Date; - -/** - * @version $Revision: 640450 $ - */ -public class MyTransform { - - private static final transient Logger LOG = LoggerFactory.getLogger(MyTransform.class); - - private boolean verbose = true; - private String prefix = "MyTransform"; - - public Object transform(Object body) { - String answer = prefix + " set body: " + new Date(); - if (verbose) { - System.out.println(">>>> " + answer); - } - LOG.info(">>>> " + answer); - return answer; - } - - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public String getPrefix() { - return prefix; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } -} http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/camel-osgi/src/main/resources/META-INF/spring/beans.xml ---------------------------------------------------------------------- diff --git a/examples/camel/camel-osgi/src/main/resources/META-INF/spring/beans.xml b/examples/camel/camel-osgi/src/main/resources/META-INF/spring/beans.xml deleted file mode 100644 index 58b4b38..0000000 --- a/examples/camel/camel-osgi/src/main/resources/META-INF/spring/beans.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?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:ctx="http://www.springframework.org/schema/context" - xmlns:camel="http://camel.apache.org/schema/spring" - xmlns:osgix="http://www.springframework.org/schema/osgi-compendium" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd - http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd"> - - <camel:camelContext xmlns="http://camel.apache.org/schema/spring"> - <!-- install the Java DSL route builder --> - <package>org.apache.servicemix.examples.camel</package> - <!-- install the route which is defined with xml tags --> - <route> - <from uri="timer://springTimer?fixedRate=true&period=2000"/> - <bean ref="myTransform" method="transform"/> - <to uri="log:ExampleRouter"/> - </route> - </camel:camelContext> - - <bean id="myTransform" class="org.apache.servicemix.examples.camel.MyTransform"> - <property name="prefix" value="${prefix}"/> - </bean> - - <osgix:cm-properties id="preProps" persistent-id="org.apache.servicemix.examples"> - <prop key="prefix">MyTransform</prop> - </osgix:cm-properties> - - <ctx:property-placeholder properties-ref="preProps" /> - -</beans> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/camel/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel/pom.xml b/examples/camel/pom.xml deleted file mode 100644 index a751c7b..0000000 --- a/examples/camel/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?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. - --> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.servicemix.examples</groupId> - <artifactId>examples</artifactId> - <version>4.6.0-SNAPSHOT</version> - </parent> - - <groupId>org.apache.servicemix.examples</groupId> - <artifactId>camel-examples</artifactId> - <packaging>pom</packaging> - <name>Apache ServiceMix :: Features :: Examples :: Camel </name> - - <modules> - <module>camel-blueprint</module> - <module>camel-osgi</module> - </modules> - -</project> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/README.txt ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/README.txt b/examples/cxf/cxf-jaxrs-blueprint/README.txt deleted file mode 100755 index c5fd1cf..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/README.txt +++ /dev/null @@ -1,263 +0,0 @@ -/* - * 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. - */ - -CXF JAX-RS Blueprint EXAMPLE -============================ - -Purpose -------- -Create a RESTful JAX-RS web service using CXF and expose it with the -OSGi HTTP Service. - - -Explanation ------------ -The web service is implemented in the CustomerService.java file, which is -located in the src/main/java/org/apache/servicemix/examples/cxf/jaxrs -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 beans.xml file, located in the src/main/resources/META-INF/ -spring directory: - -1. Imports the configuration files needed to enable CXF to support - JAX-RS and to use the OSGi HTTP service. - -2. Configures the web service, as follows: - - <jaxrs:server id="customerService" address="/crm"> - <jaxrs:serviceBeans> - <ref bean="customerSvc"/> - </jaxrs:serviceBeans> - </jaxrs:server> - - <bean id="customerSvc" class=" org.apache.servicemix.examples.cxf.jaxrs.CustomerService"/> - - -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-cxf-jaxrs - -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 a Client ----------------- - -You can browse WADL at: - -http://localhost:8181/cxf/crm/customerservice?_wadl&_type=xml - -or - -http://localhost:8181/cxf/crm?_wadl&_type=xml - -The latter URI can be used to see the desription of multiple root -resource classes. - -You can see the services listing at http://localhost:8181/cxf. - -You can make invocations on the web service in several ways, including -using a web client, using a Java client and using a command-line -utility such a curl or Wget. See below for more details. - -(a) To run a web client: - ------------------- -Open a browser and go to the following URL: - - http://localhost:8181/cxf/crm/customerservice/customers/123 - -It should display an XML representation for customer 123. - -Note, if you use Safari, right click the window and select 'Show Source'. - -(b) To run a Java client: - -------------------- -- Change to the <servicemix_home>/examples/cxf/cxf-jaxrs - directory. - -- Run the following command: - - mvn compile exec:java - - It makes a sequence of RESTful invocations and displays the - results. - -(c) To run a command-line utility: - ----------------------------- -You can use a command-line utility, such as curl or Wget, to make -the invocations. For example, try using curl as follows: - -- Open a command prompt and change directory to - <servicemix_home>/examples/cxf/cxf-jaxrs. - -- Run the following curl commands: - - # Create a customer - # - # - curl -X POST -T src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/add_customer.xml -H "Content-Type: text/xml" http://localhost:8181/cxf/crm/customerservice/customers - - # Retrieve the customer instance with id 123 - # - curl http://localhost:8181/cxf/crm/customerservice/customers/123 - - # Update the customer instance with id 123 - # - curl -X PUT -T src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/update_customer.xml -H "Content-Type: text/xml" http://localhost:8181/cxf/crm/customerservice/customers - - # Delete the customer instance with id 123 - # - curl -X DELETE http://localhost:8181/cxf/crm/customerservice/customers/123 - - -Changing /cxf servlet alias ---------------------------- -By default CXF Servlet is assigned a '/cxf' alias. You can -change it in a couple of ways - -a. Add org.apache.cxf.osgi.cfg to the /etc directory and set the - 'org.apache.cxf.servlet.context' property, for example: - - org.apache.cxf.servlet.context=/custom - -b. Use shell config commands, for example: - - config:edit org.apache.cxf.osgi - config:propset org.apache.cxf.servlet.context /super - config:update - - -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-cxf-jaxrs - feature by entering the following command in the ServiceMix console: - - features:uninstall examples-cxf-jaxrs - -2. Build the example by opening a command prompt, changing directory to - examples/cxf-jaxrs (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-cxf-jaxrs - - 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 a 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 ID that ServiceMix -has assigned to it. To get the bundle ID, 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: - - [159] [Active ] [Started] [ 60] Apache ServiceMix Example :: CXF JAX-RS OSGI (4.1.0) - -In this case, the bundle ID is 159. - -To stop the example, enter the following command in the ServiceMix -console: - - osgi:stop <bundle_id> - -For example: - - osgi:stop 159 - -To uninstall the example, enter one of the following commands at -the ServiceMix console: - - features:uninstall examples-cxf-jaxrs - -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 http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/pom.xml ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/pom.xml b/examples/cxf/cxf-jaxrs-blueprint/pom.xml deleted file mode 100644 index f1ace29..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?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. - --> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.servicemix.examples</groupId> - <artifactId>cxf</artifactId> - <version>4.6.0-SNAPSHOT</version> - </parent> - - <artifactId>cxf-jaxrs-blueprint</artifactId> - <packaging>bundle</packaging> - <name>Apache ServiceMix :: Features :: Examples :: CXF JAX-RS OSGI Blueprint</name> - <description>CXF Example using JAX-RS and Blueprint</description> - - <dependencies> - <dependency> - <groupId>org.apache.servicemix.specs</groupId> - <artifactId>org.apache.servicemix.specs.jsr311-api-1.1.1</artifactId> - </dependency> - <dependency> - <groupId>org.apache.servicemix.bundles</groupId> - <artifactId>org.apache.servicemix.bundles.commons-httpclient</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> - javax.wsdl, - javax.xml.bind, - javax.xml.bind.annotation, - javax.ws.rs, - javax.ws.rs.core, - org.apache.commons.httpclient, - org.apache.commons.httpclient.methods, - org.osgi.service.blueprint - </Import-Package> - <Export-Package> - org.apache.servicemix.examples.cxf.jaxrs - </Export-Package> - </instructions> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <configuration> - <mainClass>org.apache.servicemix.examples.cxf.jaxrs.client.Client</mainClass> - <includePluginDependencies>false</includePluginDependencies> - </configuration> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Customer.java ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Customer.java b/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Customer.java deleted file mode 100755 index d96d7ff..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Customer.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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.cxf.jaxrs; - -import javax.xml.bind.annotation.XmlRootElement; - -@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; - } -} http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/CustomerService.java ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/CustomerService.java b/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/CustomerService.java deleted file mode 100755 index c8fab24..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/CustomerService.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * 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.cxf.jaxrs; - -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.Produces; -import javax.ws.rs.core.Response; - -@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}/") - @Produces("application/xml") - public Customer getCustomer(@PathParam("id") String id) { - System.out.println("----invoking getCustomer, Customer id is: " + id); - long idNumber = Long.parseLong(id); - Customer c = customers.get(idNumber); - return c; - } - - @PUT - @Path("/customers/") - public Response updateCustomer(Customer customer) { - System.out.println("----invoking updateCustomer, Customer name is: " + customer.getName()); - 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) { - System.out.println("----invoking addCustomer, Customer name is: " + customer.getName()); - customer.setId(++currentId); - - customers.put(customer.getId(), customer); - - return Response.ok().type("application/xml").entity(customer).build(); - } - - @DELETE - @Path("/customers/{id}/") - public Response deleteCustomer(@PathParam("id") String id) { - System.out.println("----invoking deleteCustomer, Customer id is: " + 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) { - System.out.println("----invoking getOrder, Order id is: " + 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); - } - -} http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Order.java ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Order.java b/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Order.java deleted file mode 100755 index ea19c73..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Order.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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.cxf.jaxrs; - -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.ws.rs.Produces; - -import javax.xml.bind.annotation.XmlRootElement; - -@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}/") - @Produces("application/xml") - 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); - } -} http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Product.java ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Product.java b/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Product.java deleted file mode 100755 index cfd8b8c..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/Product.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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.cxf.jaxrs; - -import javax.xml.bind.annotation.XmlRootElement; - -@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; - } -} http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/client/Client.java ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/client/Client.java b/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/client/Client.java deleted file mode 100755 index b3962f5..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/src/main/java/org/apache/servicemix/examples/cxf/jaxrs/client/Client.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * 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.cxf.jaxrs.client; - -import java.io.File; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.net.URL; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.FileRequestEntity; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.PutMethod; -import org.apache.commons.httpclient.methods.RequestEntity; - -public final class Client { - - private Client() { - } - - public static void main(String args[]) throws Exception { - // Sent HTTP GET request to query all customer info - - // Sent HTTP GET request to query customer info - System.out.println("Sent HTTP GET request to query customer info"); - URL url = new URL("http://localhost:8181/cxf/crm/customerservice/customers/123"); - InputStream in = url.openStream(); - System.out.println(getStringFromInputStream(in)); - - // Sent HTTP GET request to query sub resource product info - System.out.println("\n"); - System.out.println("Sent HTTP GET request to query sub resource product info"); - url = new URL("http://localhost:8181/cxf/crm/customerservice/orders/223/products/323"); - in = url.openStream(); - System.out.println(getStringFromInputStream(in)); - - // Sent HTTP PUT request to update customer info - System.out.println("\n"); - System.out.println("Sent HTTP PUT request to update customer info"); - Client client = new Client(); - String inputFile = client.getClass().getResource("update_customer.xml").getFile(); - File input = new File(inputFile); - PutMethod put = new PutMethod("http://localhost:8181/cxf/crm/customerservice/customers"); - RequestEntity entity = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1"); - put.setRequestEntity(entity); - HttpClient httpclient = new HttpClient(); - - try { - int result = httpclient.executeMethod(put); - System.out.println("Response status code: " + result); - System.out.println("Response body: "); - System.out.println(put.getResponseBodyAsString()); - } finally { - // Release current connection to the connection pool once you are - // done - put.releaseConnection(); - } - - // Sent HTTP POST request to add customer - System.out.println("\n"); - System.out.println("Sent HTTP POST request to add customer"); - inputFile = client.getClass().getResource("add_customer.xml").getFile(); - input = new File(inputFile); - PostMethod post = new PostMethod("http://localhost:8181/cxf/crm/customerservice/customers"); - post.addRequestHeader("Accept" , "text/xml"); - entity = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1"); - post.setRequestEntity(entity); - httpclient = new HttpClient(); - - try { - int result = httpclient.executeMethod(post); - System.out.println("Response status code: " + result); - System.out.println("Response body: "); - System.out.println(post.getResponseBodyAsString()); - } finally { - // Release current connection to the connection pool once you are - // done - post.releaseConnection(); - } - - System.out.println("\n"); - System.exit(0); - } - - private static String getStringFromInputStream(InputStream in) throws Exception { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - int c = 0; - while ((c = in.read()) != -1) { - bos.write(c); - } - in.close(); - bos.close(); - return bos.toString(); - } - -} http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml deleted file mode 100755 index e56abe2..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?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:jaxrs="http://cxf.apache.org/blueprint/jaxrs" - xsi:schemaLocation=" -http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd -http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd"> - - <jaxrs:server id="customerService" address="/crm"> - <jaxrs:serviceBeans> - <ref component-id="customerSvc"/> - </jaxrs:serviceBeans> - </jaxrs:server> - - <bean id="customerSvc" class=" org.apache.servicemix.examples.cxf.jaxrs.CustomerService"/> - -</blueprint> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/add_customer.xml ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/add_customer.xml b/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/add_customer.xml deleted file mode 100755 index 0b2af7f..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/add_customer.xml +++ /dev/null @@ -1,3 +0,0 @@ -<Customer> - <name>Jack</name> -</Customer> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/update_customer.xml ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/update_customer.xml b/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/update_customer.xml deleted file mode 100755 index 9bdb64b..0000000 --- a/examples/cxf/cxf-jaxrs-blueprint/src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/update_customer.xml +++ /dev/null @@ -1,4 +0,0 @@ -<Customer> - <name>Mary</name> - <id>123</id> -</Customer> http://git-wip-us.apache.org/repos/asf/servicemix-features/blob/d358d2ea/examples/cxf/cxf-jaxrs/README.txt ---------------------------------------------------------------------- diff --git a/examples/cxf/cxf-jaxrs/README.txt b/examples/cxf/cxf-jaxrs/README.txt deleted file mode 100644 index f5bc763..0000000 --- a/examples/cxf/cxf-jaxrs/README.txt +++ /dev/null @@ -1,263 +0,0 @@ -/* - * 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. - */ - -CXF JAX-RS EXAMPLE -================== - -Purpose -------- -Create a RESTful JAX-RS web service using CXF and expose it with the -OSGi HTTP Service. - - -Explanation ------------ -The web service is implemented in the CustomerService.java file, which is -located in the src/main/java/org/apache/servicemix/examples/cxf/jaxrs -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 beans.xml file, located in the src/main/resources/META-INF/ -spring directory: - -1. Imports the configuration files needed to enable CXF to support - JAX-RS and to use the OSGi HTTP service. - -2. Configures the web service, as follows: - - <jaxrs:server id="customerService" address="/crm"> - <jaxrs:serviceBeans> - <ref bean="customerSvc"/> - </jaxrs:serviceBeans> - </jaxrs:server> - - <bean id="customerSvc" class=" org.apache.servicemix.examples.cxf.jaxrs.CustomerService"/> - - -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-cxf-jaxrs - -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 a Client ----------------- - -You can browse WADL at: - -http://localhost:8181/cxf/crm/customerservice?_wadl&_type=xml - -or - -http://localhost:8181/cxf/crm?_wadl&_type=xml - -The latter URI can be used to see the desription of multiple root -resource classes. - -You can see the services listing at http://localhost:8181/cxf. - -You can make invocations on the web service in several ways, including -using a web client, using a Java client and using a command-line -utility such a curl or Wget. See below for more details. - -(a) To run a web client: - ------------------- -Open a browser and go to the following URL: - - http://localhost:8181/cxf/crm/customerservice/customers/123 - -It should display an XML representation for customer 123. - -Note, if you use Safari, right click the window and select 'Show Source'. - -(b) To run a Java client: - -------------------- -- Change to the <servicemix_home>/examples/cxf/cxf-jaxrs - directory. - -- Run the following command: - - mvn compile exec:java - - It makes a sequence of RESTful invocations and displays the - results. - -(c) To run a command-line utility: - ----------------------------- -You can use a command-line utility, such as curl or Wget, to make -the invocations. For example, try using curl as follows: - -- Open a command prompt and change directory to - <servicemix_home>/examples/cxf/cxf-jaxrs. - -- Run the following curl commands: - - # Create a customer - # - # - curl -X POST -T src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/add_customer.xml -H "Content-Type: text/xml" http://localhost:8181/cxf/crm/customerservice/customers - - # Retrieve the customer instance with id 123 - # - curl http://localhost:8181/cxf/crm/customerservice/customers/123 - - # Update the customer instance with id 123 - # - curl -X PUT -T src/main/resources/org/apache/servicemix/examples/cxf/jaxrs/client/update_customer.xml -H "Content-Type: text/xml" http://localhost:8181/cxf/crm/customerservice/customers - - # Delete the customer instance with id 123 - # - curl -X DELETE http://localhost:8181/cxf/crm/customerservice/customers/123 - - -Changing /cxf servlet alias ---------------------------- -By default CXF Servlet is assigned a '/cxf' alias. You can -change it in a couple of ways - -a. Add org.apache.cxf.osgi.cfg to the /etc directory and set the - 'org.apache.cxf.servlet.context' property, for example: - - org.apache.cxf.servlet.context=/custom - -b. Use shell config commands, for example: - - config:edit org.apache.cxf.osgi - config:propset org.apache.cxf.servlet.context /super - config:update - - -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-cxf-jaxrs - feature by entering the following command in the ServiceMix console: - - features:uninstall examples-cxf-jaxrs - -2. Build the example by opening a command prompt, changing directory to - examples/cxf-jaxrs (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-cxf-jaxrs - - 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 a 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 ID that ServiceMix -has assigned to it. To get the bundle ID, 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: - - [159] [Active ] [Started] [ 60] Apache ServiceMix Example :: CXF JAX-RS OSGI (4.1.0) - -In this case, the bundle ID is 159. - -To stop the example, enter the following command in the ServiceMix -console: - - osgi:stop <bundle_id> - -For example: - - osgi:stop 159 - -To uninstall the example, enter one of the following commands at -the ServiceMix console: - - features:uninstall examples-cxf-jaxrs - -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
