You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2013/05/17 01:32:33 UTC
svn commit: r1483606 - in /servicemix/smx5/trunk: ./
assemblies/apache-servicemix/src/main/filtered-resources/ examples/camel/
examples/camel/camel-sql/
examples/camel/camel-sql/camel-sql-datasource-derby/
examples/camel/camel-sql/camel-sql-datasource-...
Author: gertv
Date: Thu May 16 23:32:32 2013
New Revision: 1483606
URL: http://svn.apache.org/r1483606
Log:
SM-2189: Add camel-sql example and update maven bundle plugin version
Added:
servicemix/smx5/trunk/examples/camel/camel-sql/
servicemix/smx5/trunk/examples/camel/camel-sql/README.txt
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/pom.xml
- copied, changed from r1483243, servicemix/smx5/trunk/examples/camel/pom.xml
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/examples/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/examples/camel/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/examples/camel/sql/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanDerby.java
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/resources/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/resources/OSGI-INF/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/resources/OSGI-INF/blueprint/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/resources/OSGI-INF/blueprint/blueprint.xml
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/pom.xml
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/examples/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/examples/camel/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/examples/camel/sql/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanH2.java
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/resources/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/resources/OSGI-INF/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/resources/OSGI-INF/blueprint/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/resources/OSGI-INF/blueprint/blueprint.xml
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/pom.xml
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/examples/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/examples/camel/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/examples/camel/sql/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanPgSQL.java
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/resources/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/resources/OSGI-INF/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/resources/OSGI-INF/blueprint/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/resources/OSGI-INF/blueprint/blueprint.xml
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/pom.xml
- copied, changed from r1483243, servicemix/smx5/trunk/examples/camel/pom.xml
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/ListenerBean.java
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/OrderBean.java
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/OSGI-INF/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/OSGI-INF/blueprint/
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/OSGI-INF/blueprint/blueprint.xml
servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/sql.properties
servicemix/smx5/trunk/examples/camel/camel-sql/pom.xml
- copied, changed from r1483243, servicemix/smx5/trunk/examples/camel/pom.xml
Modified:
servicemix/smx5/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
servicemix/smx5/trunk/examples/camel/pom.xml
servicemix/smx5/trunk/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=1483606&r1=1483605&r2=1483606&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 Thu May 16 23:32:32 2013
@@ -72,6 +72,28 @@
<bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient/${commons-httpclient.bundle.version}</bundle>
<bundle>mvn:org.apache.servicemix.examples/cxf-jaxws-blueprint/${version}</bundle>
</feature>
+ <feature name="examples-camel-sql-derby" version="${version}" resolver="(obr)">
+ <feature version="${camel.version}">camel-sql</feature>
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/${commons-dbcp.bundle.version}</bundle>
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.derby/${derby.bundle.version}</bundle>
+ <bundle>mvn:org.apache.servicemix.examples/camel-sql-datasource-derby/${version}</bundle>
+ <bundle>mvn:org.apache.servicemix.examples/camel-sql-orders/${version}</bundle>
+ </feature>
+ <feature name="examples-camel-sql-pgsql" version="${version}" resolver="(obr)">
+ <feature version="${camel.version}">camel-sql</feature>
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/${commons-dbcp.bundle.version}</bundle>
+ <bundle dependency="true">wrap:mvn:postgresql/postgresql/${postgresql.version}.jdbc4</bundle>
+ <bundle>mvn:org.apache.servicemix.examples/camel-sql-datasource-pgsql/${version}</bundle>
+ <bundle>mvn:org.apache.servicemix.examples/camel-sql-orders/${version}</bundle>
+ </feature>
+ <feature name="examples-camel-sql-h2" version="${version}" resolver="(obr)">
+ <feature version="${camel.version}">camel-sql</feature>
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/${commons-dbcp.bundle.version}</bundle>
+ <bundle dependency="true">mvn:org.osgi/org.osgi.compendium/${osgi.version}</bundle>
+ <bundle dependency="true">mvn:com.h2database/h2/${h2.version}</bundle>
+ <bundle>mvn:org.apache.servicemix.examples/camel-sql-datasource-h2/${version}</bundle>
+ <bundle>mvn:org.apache.servicemix.examples/camel-sql-orders/${version}</bundle>
+ </feature>
<feature name="examples-camel-osgi" version="${version}" resolver="(obr)">
<feature version="${camel.version}">camel</feature>
<bundle>mvn:org.apache.servicemix.examples/camel-osgi/${version}</bundle>
Added: servicemix/smx5/trunk/examples/camel/camel-sql/README.txt
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/README.txt?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/README.txt (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/README.txt Thu May 16 23:32:32 2013
@@ -0,0 +1,274 @@
+/*
+ * 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 SQL EXAMPLE
+=================
+
+Purpose
+-------
+Deploys a Camel EIP route that uses a database to store messages after
+receiving. A second route illustrates how to read messages from the database
+in order to process them.
+
+
+Explanation
+-----------
+The example exists of several modules:
+
+- camel-sql-Orders
+
+ The Orders module has two Camel routes defined in a Blueprint XML
+ file. Both routes use the camel-sql feature and some predefined queries
+ which are located in the sql.properties file. The datasource is referenced
+ from the service we exposed in the first module.
+
+ The first route periodically creates a random order using the OrderBean
+ and submits it to the database. The route also logs every oder to the
+ Servicemix log. It displays the item-name from the order, for example:
+
+ | Inserted new order of Gummi bears
+
+ The second route consumes the unconsumed orders from the database
+ and processes them using the OrderBean. The result is logged to the
+ Servicemix log. For example:
+
+ | {ID=10, ITEM=Gummi bears, AMOUNT=46, CONSUMED=false,
+ description=The red ones are the cutest [PROCESSED], processed=true}
+
+- camel-sql-datasource-derby
+
+ This module creates an in-memory Derby database utilizing a
+ DatabaseBeanDerby bean. The Database bean takes care of the table
+ creation and the graceful shutdown of the database connection.
+
+ The datasource is exposed as a OSGI service so it can be referenced
+ in other OSGI bundles.
+
+ - camel-sql-datasource-pgsql
+
+ This module creates an Postgre SQL table utilizing a
+ DatabaseBeanPgSQL bean. The Database bean takes care of the table
+ creation and the graceful shutdown of the database connection.
+
+ The datasource is exposed as a OSGI service so it can be referenced
+ in other OSGI bundles.
+
+ - camel-sql-datasource-h2
+
+ This module creates an in-memory h2 database utilizing a
+ DatabaseBeanH2 bean. The Database bean takes care of the table
+ creation and the graceful shutdown of the database connection.
+
+ The datasource is exposed as a OSGI service so it can be referenced
+ in other OSGI bundles.
+
+
+All modules 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. This example requires some additional configuration to allow
+ the JVM to use more PermGen memory:
+
+ export JAVA_MAX_PERM_MEM=128m (on UNIX)
+ set JAVA_MAX_PERM_MEM=128m (on Windows)
+
+3. Start ServiceMix by running the following command:
+
+ <servicemix_home>/bin/servicemix (on UNIX)
+ <servicemix_home>\bin\servicemix (on Windows)
+
+
+Preparing the databases
+-----------------------
+
+According to the example you would like to run, you have to
+prepare the Derby, H2 or PgSQL database.
+
+- Derby
+ You can find a downloadable bin-distribution of Derby for
+ your OS on http://db.apache.org/derby/derby_downloads.html
+
+ Extract the downloaded package and run the network server
+
+ <derby_home>/bin/startNetworkServer (on UNIX)
+ <derby_home>\bin\startNetworkServer.bat (on Windows)
+
+- H2
+ You can find a downloadable distribution of H2 for
+ your OS on http://www.h2database.com/html/download.html
+
+ To install the H2 database server, run the installer or
+ extract the package. Now start the database server:
+
+ <h2_home>/bin/h2.sh (on UNIX)
+ <h2_home>\bin\h2.bat (on Windows)
+
+- PgSQL
+ You can find a downloadable distribution of pgSQL for
+ your OS on http://www.postgresql.org/download/
+
+ Follow the installation and execution instructions for
+ your OS on the download website.
+
+ To prepare the database server you can use the command line tool
+ psql or the GUI tool PgAdmin (http://pgadmin.org/).
+
+ - Create a new database orderdb
+
+ - Execute the following SQL code:
+
+ CREATE ROLE camelsql LOGIN
+ ENCRYPTED PASSWORD 'md5fcac28063087cf28e72241706e98c001'
+ NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
+
+ ALTER DATABASE orderdb OWNER TO camelsql;
+
+
+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-sql-derby
+or
+ features:install examples-camel-sql-h2
+or
+ features:install examples-camel-sql-pgsql
+
+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
+generateOrder-route which crates routes en sends them to the database.
+The processOrder-route picks those orders from the database and
+processes them. You should see a similar log output:
+
+ | Inserted a new order of Cookies
+ | {ID=8, ITEM=Cookies, AMOUNT=35, CONSUMED=false,
+ description=Grandma's recipe and fresh from the bakery! [PROCESSED], processed=true}
+
+
+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 feature
+ by entering the following command in the ServiceMix console:
+
+ features:uninstall examples-camel-sql-derby
+ or
+ features:uninstall examples-camel-sql-h2
+ or
+ features:uninstall examples-camel-sql-pgsql
+
+2. Build the example by opening a command prompt, changing directory to
+ examples/camel/camel-sql (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-sql-derby
+ or
+ features:install examples-camel-sql-h2
+ or
+ features:install examples-camel-sql-pgsql
+
+ 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
+generateOrder-route which crates routes en sends them to the database.
+The processOrder-route picks those orders from the database and
+processes them. You should see a similar log output:
+
+ | Inserted a new order of Cookies
+ | {ID=8, ITEM=Cookies, AMOUNT=35, CONSUMED=false,
+ description=Grandma's recipe and fresh from the bakery! [PROCESSED], processed=true}
+
+
+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-sql-derby
+or
+ features:uninstall examples-camel-sql-h2
+or
+ features:uninstall examples-camel-sql-pgsql
+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
Copied: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/pom.xml (from r1483243, servicemix/smx5/trunk/examples/camel/pom.xml)
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/pom.xml?p2=servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/pom.xml&p1=servicemix/smx5/trunk/examples/camel/pom.xml&r1=1483243&r2=1483606&rev=1483606&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/camel/pom.xml (original)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/pom.xml Thu May 16 23:32:32 2013
@@ -2,7 +2,7 @@
<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.
@@ -19,24 +19,41 @@
limitations under the License.
-->
- <modelVersion>4.0.0</modelVersion>
-
<parent>
+ <artifactId>camel-sql</artifactId>
<groupId>org.apache.servicemix.examples</groupId>
- <artifactId>examples</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-sql-datasource-derby</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache ServiceMix :: Examples :: Camel SQL :: Datasource Derby</name>
+ <description>Camel Example using sql</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>*</Import-Package>
+ <Private-Package>org.apache.servicemix.examples.camel.sql</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ </dependencies>
- <groupId>org.apache.servicemix.examples</groupId>
- <artifactId>camel-examples</artifactId>
- <packaging>pom</packaging>
- <name>Apache ServiceMix :: Examples :: Camel </name>
-
- <modules>
- <module>camel-blueprint</module>
- <module>camel-osgi</module>
- <module>camel-drools</module>
- <module>camel-drools-blueprint</module>
- </modules>
-</project>
+</project>
\ No newline at end of file
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanDerby.java
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanDerby.java?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanDerby.java (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanDerby.java Thu May 16 23:32:32 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.sql;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class DatabaseBeanDerby {
+
+ private DataSource dataSource;
+ private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseBeanDerby.class);
+
+ public DatabaseBeanDerby(){}
+
+ public void setDataSource(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public void create() throws SQLException{
+ Statement sta = dataSource.getConnection().createStatement();
+ try {
+ sta.executeUpdate(
+ "CREATE TABLE orders (id INT generated by default as identity, item VARCHAR(50), amount INT, description VARCHAR(300), processed BOOLEAN, consumed BOOLEAN)");
+ } catch (SQLException e) {
+ LOGGER.info("Table orders already exists");
+ }
+ }
+
+ public void destroy() throws SQLException {
+ dataSource.getConnection().close();
+ }
+
+
+}
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-derby/src/main/resources/OSGI-INF/blueprint/blueprint.xml Thu May 16 23:32:32 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"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.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 id="myblueprint.placeholder" persistent-id="org.apache.servicemix.examples.camel.sql">
+ <cm:default-properties>
+ <cm:property name="derby_username" value=""/>
+ <cm:property name="derby_password" value=""/>
+ <cm:property name="derby_database" value="orderdb"/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+
+ <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ <property name="url" value="jdbc:derby:memory:${derby_database};create=true"/>
+ <property name="username" value="${derby_username}"/>
+ <property name="password" value="${derby_password}"/>
+ </bean>
+
+ <bean id="initDatabase" class="org.apache.servicemix.examples.camel.sql.DatabaseBeanDerby"
+ init-method="create" destroy-method="destroy">
+ <property name="dataSource" ref="dataSource"/>
+ </bean>
+
+ <service ref="dataSource" interface="javax.sql.DataSource">
+ <service-properties>
+ <entry key="datasource.name" value="orders"/>
+ <entry key="datasource.type" value="Apache Derby"/>
+ </service-properties>
+ </service>
+
+</blueprint>
\ No newline at end of file
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/pom.xml?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/pom.xml (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/pom.xml Thu May 16 23:32:32 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/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-sql</artifactId>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <version>5.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-sql-datasource-h2</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache ServiceMix :: Examples :: Camel SQL :: Datasource H2</name>
+ <description>Camel Example using sql</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>*</Import-Package>
+ <Private-Package>org.apache.servicemix.examples.camel.sql</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanH2.java
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanH2.java?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanH2.java (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanH2.java Thu May 16 23:32:32 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.sql;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class DatabaseBeanH2 {
+
+ private DataSource dataSource;
+ private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseBeanH2.class);
+
+ public DatabaseBeanH2(){}
+
+ public void setDataSource(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public void create() throws SQLException{
+ Statement sta = dataSource.getConnection().createStatement();
+ try {
+ sta.executeUpdate("CREATE TABLE orders ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, item VARCHAR(50), amount INT, description VARCHAR(300), processed BOOLEAN, consumed BOOLEAN);");
+ } catch (SQLException e) {
+ LOGGER.info("Table orders already exists");
+ }
+ }
+
+ public void destroy() throws SQLException {
+ dataSource.getConnection().close();
+ }
+
+
+}
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-h2/src/main/resources/OSGI-INF/blueprint/blueprint.xml Thu May 16 23:32:32 2013
@@ -0,0 +1,56 @@
+<?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:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- OSGI blueprint property placeholder -->
+ <cm:property-placeholder id="myblueprint.placeholder" persistent-id="org.apache.servicemix.examples.camel.sql">
+ <cm:default-properties>
+ <cm:property name="h2_username" value=""/>
+ <cm:property name="h2_password" value=""/>
+ <cm:property name="h2_database" value="orderdb"/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+
+
+ <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="org.h2.Driver"/>
+ <property name="url" value="jdbc:h2:~/${h2_database}"/>
+ <property name="username" value="${h2_username}"/>
+ <property name="password" value="${h2_password}"/>
+ </bean>
+
+ <bean id="initDatabase" class="org.apache.servicemix.examples.camel.sql.DatabaseBeanH2"
+ init-method="create" destroy-method="destroy">
+ <property name="dataSource" ref="dataSource"/>
+ </bean>
+
+ <service ref="dataSource" interface="javax.sql.DataSource">
+ <service-properties>
+ <entry key="datasource.name" value="orders"/>
+ <entry key="datasource.type" value="H2"/>
+ </service-properties>
+ </service>
+
+</blueprint>
\ No newline at end of file
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/pom.xml?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/pom.xml (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/pom.xml Thu May 16 23:32:32 2013
@@ -0,0 +1,66 @@
+<?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-sql</artifactId>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <version>5.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-sql-datasource-pgsql</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache ServiceMix :: Examples :: Camel SQL :: Datasource PgSql</name>
+ <description>Camel Example using sql</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.postgresql.jdbc4,*</Import-Package>
+ <Private-Package>org.apache.servicemix.examples.camel.sql</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.24</version>
+ </dependency>
+ -->
+ </dependencies>
+
+
+</project>
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanPgSQL.java
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanPgSQL.java?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanPgSQL.java (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/java/org/apache/servicemix/examples/camel/sql/DatabaseBeanPgSQL.java Thu May 16 23:32:32 2013
@@ -0,0 +1,49 @@
+/**
+ * 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.sql;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class DatabaseBeanPgSQL {
+ private DataSource dataSource;
+ private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseBeanPgSQL.class);
+
+ public DatabaseBeanPgSQL(){}
+
+ public void setDataSource(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public void create() throws SQLException {
+ Statement sta = dataSource.getConnection().createStatement();
+ try {
+ sta.executeUpdate("CREATE SEQUENCE order_id_seq;");
+ sta.executeUpdate("CREATE TABLE orders ( id INT NOT NULL PRIMARY KEY DEFAULT nextval('order_id_seq'), item VARCHAR(50), amount INT, description VARCHAR(300), processed BOOLEAN, consumed BOOLEAN);");
+ } catch (SQLException e) {
+ LOGGER.info("Table orders already exists");
+ }
+ }
+
+ public void destroy() throws SQLException {
+ dataSource.getConnection().close();
+ }
+}
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-datasource-pgsql/src/main/resources/OSGI-INF/blueprint/blueprint.xml Thu May 16 23:32:32 2013
@@ -0,0 +1,55 @@
+<?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:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.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 id="myblueprint.placeholder" persistent-id="org.apache.servicemix.examples.camel.sql">
+ <cm:default-properties>
+ <cm:property name="pgsql_username" value="camelsql"/>
+ <cm:property name="pgsql_password" value="camel"/>
+ <cm:property name="pgsql_database" value="orderdb"/>
+ <cm:property name="pgsql_host" value="localhost"/>
+ <cm:property name="pgsql_port" value="5432"/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="org.postgresql.Driver"/>
+ <property name="url" value="jdbc:postgresql://${pgsql_host}:${pgsql_port}/${pgsql_database}"/>
+ <property name="username" value="${pgsql_username}"/>
+ <property name="password" value="${pgsql_password}"/>
+ </bean>
+
+ <bean id="initDatabase" class="org.apache.servicemix.examples.camel.sql.DatabaseBeanPgSQL"
+ init-method="create" destroy-method="destroy">
+ <property name="dataSource" ref="dataSource"/>
+ </bean>
+
+ <service ref="dataSource" interface="javax.sql.DataSource">
+ <service-properties>
+ <entry key="datasource.name" value="orders"/>
+ <entry key="datasource.type" value="PgSQL"/>
+ </service-properties>
+ </service>
+
+</blueprint>
\ No newline at end of file
Copied: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/pom.xml (from r1483243, servicemix/smx5/trunk/examples/camel/pom.xml)
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/pom.xml?p2=servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/pom.xml&p1=servicemix/smx5/trunk/examples/camel/pom.xml&r1=1483243&r2=1483606&rev=1483606&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/camel/pom.xml (original)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/pom.xml Thu May 16 23:32:32 2013
@@ -2,7 +2,7 @@
<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.
@@ -19,24 +19,41 @@
limitations under the License.
-->
- <modelVersion>4.0.0</modelVersion>
-
<parent>
+ <artifactId>camel-sql</artifactId>
<groupId>org.apache.servicemix.examples</groupId>
- <artifactId>examples</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
+ <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.servicemix.examples</groupId>
- <artifactId>camel-examples</artifactId>
- <packaging>pom</packaging>
- <name>Apache ServiceMix :: Examples :: Camel </name>
-
- <modules>
- <module>camel-blueprint</module>
- <module>camel-osgi</module>
- <module>camel-drools</module>
- <module>camel-drools-blueprint</module>
- </modules>
+ <artifactId>camel-sql-orders</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache ServiceMix :: Examples :: Camel SQL :: Orders</name>
+ <description>Camel Example using sql</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.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>*</Import-Package>
+ <Private-Package>org.apache.servicemix.examples.camel.sql</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
-</project>
+</project>
\ No newline at end of file
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/ListenerBean.java
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/ListenerBean.java?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/ListenerBean.java (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/ListenerBean.java Thu May 16 23:32:32 2013
@@ -0,0 +1,34 @@
+/**
+ * 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.sql;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Map;
+
+public class ListenerBean {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ListenerBean.class);
+
+ public void onBind(Object service, Map properties){
+ LOGGER.info("Binding to "+ properties.get("datasource.type"));
+
+
+ }
+ public void onUnbind(Object service, Map properties){
+ LOGGER.info("Unbinding from "+ properties.get("datasource.type"));
+ }
+}
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/OrderBean.java
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/OrderBean.java?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/OrderBean.java (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/java/org/apache/servicemix/examples/camel/sql/OrderBean.java Thu May 16 23:32:32 2013
@@ -0,0 +1,66 @@
+/**
+ * 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.sql;
+
+import java.util.*;
+
+public class OrderBean {
+
+ private Random random;
+ private static int itemnumber = 0;
+ private List<Map<String,Object>> orders;
+
+
+ public OrderBean() {
+ random = new Random();
+ }
+
+
+ public Map<String,Object> generateRandomOrder(){
+ return orders.get(random.nextInt(orders.size()-1));
+ }
+
+ private static int getNextItemNumber(){
+ return OrderBean.itemnumber++;
+ }
+
+ public void processOrder(Map<String,Object> order){
+ order.put("description",order.get("description")+" [PROCESSED]");
+ order.put("processed",true);
+
+ }
+
+
+ public void init(){
+ orders = new ArrayList<Map<String, Object>>();
+ orders.add(createOrder("Cookies","Grandma's recipe and fresh from the bakery!",random.nextInt(50)));
+ orders.add(createOrder("Lollipops","Mix of different colors and flavours",random.nextInt(10)));
+ orders.add(createOrder("Gummi bears","The red ones are the cutest",random.nextInt(100)));
+ orders.add(createOrder("Skittles","Everybody loves rainbows",random.nextInt(800)));
+ }
+
+ private Map<String,Object> createOrder(String item, String description, int amount){
+ Map<String,Object> order = new HashMap<String,Object>();
+ order.put("item",item);
+ order.put("description",description);
+ order.put("amount",amount);
+ return order;
+ }
+
+
+
+}
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/OSGI-INF/blueprint/blueprint.xml Thu May 16 23:32:32 2013
@@ -0,0 +1,60 @@
+<?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">
+
+ <bean id="orderBean" class="org.apache.servicemix.examples.camel.sql.OrderBean" init-method="init"/>
+
+ <reference id="dataSource" interface="javax.sql.DataSource" filter="(datasource.name=orders)">
+ <reference-listener bind-method="onBind" unbind-method="onUnbind">
+ <bean class="org.apache.servicemix.examples.camel.sql.ListenerBean"/>
+ </reference-listener>
+ </reference>
+
+ <bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
+ <property name="dataSource" ref="dataSource"/>
+ </bean>
+
+ <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+ <propertyPlaceholder id="placeholder" location="classpath:sql.properties"/>
+ <route id="generateOrder-route">
+ <from uri="timer:foo?period=5s"/>
+ <transform>
+ <method ref="orderBean" method="generateRandomOrder"/>
+ </transform>
+ <to uri="sql:{{sql.insertOrder}}"/>
+ <log message="Inserted a new order of ${body[item]}"/>
+ </route>
+
+ <!-- route that process the orders by picking up new rows from the database
+ and when done processing then update the row to mark it as processed -->
+ <route id="processOrder-route">
+ <from uri="sql:{{sql.selectOrder}}?consumer.onConsume={{sql.markOrder}}"/>
+ <to uri="bean:orderBean?method=processOrder"/>
+ <log message="${body}"/>
+ </route>
+ </camelContext>
+
+
+
+
+</blueprint>
\ No newline at end of file
Added: servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/sql.properties
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/sql.properties?rev=1483606&view=auto
==============================================================================
--- servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/sql.properties (added)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/camel-sql-orders/src/main/resources/sql.properties Thu May 16 23:32:32 2013
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+#
+
+## notice we use named parameters in the queries, eg :#name. A named query parameter must start with :#
+## sql that insert new orders
+sql.insertOrder=insert into orders (item, amount, description, processed, consumed) values (:#item, :#amount, :#description, false, false)
+
+## sql that select all unprocessed orders
+sql.selectOrder=select * from orders where consumed = false
+
+## sql that update the order as being processed
+sql.markOrder=update orders set consumed = true where id = :#id
\ No newline at end of file
Copied: servicemix/smx5/trunk/examples/camel/camel-sql/pom.xml (from r1483243, servicemix/smx5/trunk/examples/camel/pom.xml)
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/examples/camel/camel-sql/pom.xml?p2=servicemix/smx5/trunk/examples/camel/camel-sql/pom.xml&p1=servicemix/smx5/trunk/examples/camel/pom.xml&r1=1483243&r2=1483606&rev=1483606&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/camel/pom.xml (original)
+++ servicemix/smx5/trunk/examples/camel/camel-sql/pom.xml Thu May 16 23:32:32 2013
@@ -2,7 +2,7 @@
<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.
@@ -19,24 +19,23 @@
limitations under the License.
-->
- <modelVersion>4.0.0</modelVersion>
-
<parent>
+ <artifactId>camel-examples</artifactId>
<groupId>org.apache.servicemix.examples</groupId>
- <artifactId>examples</artifactId>
<version>5.0.0-SNAPSHOT</version>
</parent>
+ <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.servicemix.examples</groupId>
- <artifactId>camel-examples</artifactId>
+ <artifactId>camel-sql</artifactId>
+ <name>Apache ServiceMix :: Examples :: Camel SQL</name>
<packaging>pom</packaging>
- <name>Apache ServiceMix :: Examples :: Camel </name>
<modules>
- <module>camel-blueprint</module>
- <module>camel-osgi</module>
- <module>camel-drools</module>
- <module>camel-drools-blueprint</module>
+ <module>camel-sql-datasource-derby</module>
+ <module>camel-sql-orders</module>
+ <module>camel-sql-datasource-pgsql</module>
+ <module>camel-sql-datasource-h2</module>
</modules>
-</project>
+
+</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=1483606&r1=1483605&r2=1483606&view=diff
==============================================================================
--- servicemix/smx5/trunk/examples/camel/pom.xml (original)
+++ servicemix/smx5/trunk/examples/camel/pom.xml Thu May 16 23:32:32 2013
@@ -37,6 +37,7 @@
<module>camel-osgi</module>
<module>camel-drools</module>
<module>camel-drools-blueprint</module>
+ <module>camel-sql</module>
</modules>
</project>
Modified: servicemix/smx5/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx5/trunk/pom.xml?rev=1483606&r1=1483605&r2=1483606&view=diff
==============================================================================
--- servicemix/smx5/trunk/pom.xml (original)
+++ servicemix/smx5/trunk/pom.xml Thu May 16 23:32:32 2013
@@ -158,12 +158,14 @@
<bcel.bundle.version>5.2_3</bcel.bundle.version>
<commons-beanutils.bundle.version>1.8.2_1</commons-beanutils.bundle.version>
<commons-codec.bundle.version>1.4</commons-codec.bundle.version>
+ <commons-dbcp.bundle.version>1.4_3</commons-dbcp.bundle.version>
<commons-httpclient.bundle.version>3.1_6</commons-httpclient.bundle.version>
<commons-lang.bundle.version>2.4_4</commons-lang.bundle.version>
<commons-net.bundle.version>2.2</commons-net.bundle.version>
<commons-pool.version>1.6</commons-pool.version>
<commons-io.version>2.4</commons-io.version>
<commons-vfs.bundle.version>1.0_5</commons-vfs.bundle.version>
+ <derby.bundle.version>10.9.1.0_1</derby.bundle.version>
<dom4j.bundle.version>1.6.1_5</dom4j.bundle.version>
<drools.bundle.version>${drools.version}_1</drools.bundle.version>
<fastinfoset.bundle.version>1.2.7_3</fastinfoset.bundle.version>
@@ -177,6 +179,7 @@
<opensaml.bundle.version>2.4.1_1</opensaml.bundle.version>
<jodatime.bundle.version>1.5.2_2</jodatime.bundle.version>
<oscore.bundle.version>2.2.4_4</oscore.bundle.version>
+ <osgi.version>4.3.1</osgi.version>
<osworkflow.bundle.version>2.7.0_4</osworkflow.bundle.version>
<oro.bundle.version>2.0.8_4</oro.bundle.version>
<propertyset.bundle.version>1.3_4</propertyset.bundle.version>
@@ -203,7 +206,7 @@
<depends-maven-plugin.version>1.2</depends-maven-plugin.version>
<maven-antrun-plugin.version>1.6</maven-antrun-plugin.version>
<maven-assembly-plugin.version>2.2.1</maven-assembly-plugin.version>
- <maven-bundle-plugin.version>2.1.0</maven-bundle-plugin.version>
+ <maven-bundle-plugin.version>2.3.7</maven-bundle-plugin.version>
<!-- Other Dependencies -->
<axiom.version>1.2.12</axiom.version>
@@ -230,6 +233,7 @@
<mybatis.version>3.1.1</mybatis.version>
<pax.tinybundle.version>1.0.0</pax.tinybundle.version>
<pojosr.version>0.2.1</pojosr.version>
+ <postgresql.version>9.1-901</postgresql.version>
<scalatest.version>1.9.1</scalatest.version>
<scriptengines.version>1.1</scriptengines.version>
<slf4j.version>1.6.6</slf4j.version>