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 2008/08/25 15:31:23 UTC

svn commit: r688722 [1/2] - in /servicemix/utils/trunk: ./ src/main/java/org/apache/servicemix/executors/ src/main/java/org/apache/servicemix/executors/impl/ src/main/java/org/apache/servicemix/finder/ src/main/java/org/apache/servicemix/id/ src/main/j...

Author: gertv
Date: Mon Aug 25 06:31:20 2008
New Revision: 688722

URL: http://svn.apache.org/viewvc?rev=688722&view=rev
Log:
SM-1455: Merge servicemix-services into servicemix-utils

Added:
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/Executor.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/WorkManagerWrapper.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/package.html
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/package.html
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/finder/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/finder/FactoryFinder.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/id/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/id/IdGenerator.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/Statements.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/AxionJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BlobJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DB2JDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/ImageBasedJDBCAdaptor.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/InformixJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/MaxDBJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/OracleJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/PostgresqlJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/LockManager.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/Store.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/StoreFactory.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/TimeoutMemoryStore.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/Timer.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerListener.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerManager.java
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/impl/
    servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java
    servicemix/utils/trunk/src/main/resources/META-INF/
    servicemix/utils/trunk/src/main/resources/META-INF/services/
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/apache_derby_embedded_jdbc_driver
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/axion_jdbc_driver
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/hsql_database_engine_driver
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/i-net_sprinta_2000
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_db2_jdbc_universal_driver_architecture
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_informix_jdbc_driver_for_ibm_informix_dynamic_server
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jconnect__tm__for_jdbc__tm_
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jtds_type_4_jdbc_driver_for_ms_sql_server_and_sybase
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/mysql-ab_jdbc_driver
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/oracle_jdbc_driver
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/postgresql_native_driver
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sap_db
    servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sqlserver
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/locks/
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/locks/impl/
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/locks/impl/SimpleLockTest.java
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTest.java
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTransactionalTest.java
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/MemoryStoreFactoryTest.java
    servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/TimeoutMemoryStoreTest.java
    servicemix/utils/trunk/src/test/resources/log4j-tests.properties
    servicemix/utils/trunk/src/test/resources/log4j.properties
Modified:
    servicemix/utils/trunk/   (props changed)
    servicemix/utils/trunk/pom.xml

Propchange: servicemix/utils/trunk/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Aug 25 06:31:20 2008
@@ -0,0 +1,5 @@
+derby.log
+target
+.project
+.classpath
+.settings

Modified: servicemix/utils/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/pom.xml?rev=688722&r1=688721&r2=688722&view=diff
==============================================================================
--- servicemix/utils/trunk/pom.xml (original)
+++ servicemix/utils/trunk/pom.xml Mon Aug 25 06:31:20 2008
@@ -30,14 +30,20 @@
   <artifactId>servicemix-utils</artifactId>
   <packaging>bundle</packaging>
   <version>1.0-SNAPSHOT</version>
-  <name>ServiceMix :: Utils</name>
-  <description>Various utility and helper classes for the ServiceMix containers and components</description>
+  <name>Apache ServiceMix :: Utils</name>
+  <description>Various utility/helper classes and services for the ServiceMix containers and components</description>
 
   <properties>
   </properties>
 
   <dependencies>
     <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+      <version>1.1</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
       <version>1.1</version>
@@ -96,6 +102,30 @@
       <version>3.4.3</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>hsqldb</groupId>
+      <artifactId>hsqldb</artifactId>
+      <version>1.7.3.3</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.derby</groupId>
+      <artifactId>derby</artifactId>
+      <version>10.2.2.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jencks</groupId>
+      <artifactId>jencks</artifactId>
+      <version>2.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>tranql</groupId>
+      <artifactId>tranql-connector</artifactId>
+      <version>1.1</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/Executor.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/Executor.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/Executor.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/Executor.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.executors;
+
+/**
+ * The Executor interface is a simple interface
+ * on top of a thread pool.
+ * 
+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
+ */
+public interface Executor {
+
+    /**
+     * Execute a command.
+     * 
+     * @param command the command to execute
+     */
+    void execute(Runnable command);
+    
+    /**
+     * Shutdown this executor.
+     * This must be called to kill all threads.
+     */
+    void shutdown();
+
+    /**
+     * The capacity of the underlying queue (if any)
+     * @return
+     */
+    int capacity();
+    
+    /**
+     * The current size of the underlying queue (if any)
+     * @return
+     */
+    int size();
+    
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,36 @@
+/*
+ * 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.executors;
+
+/**
+ * Factory to create <code>Executor</code>s.
+ * 
+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
+ */
+public interface ExecutorFactory {
+
+    /**
+     * Create a new executor for the given Id.
+     * The id may be used to provide per executor
+     * configuration.
+     * 
+     * @param id the id of the executor to create
+     * @return a configured Executor
+     */
+    Executor createExecutor(String id);
+    
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/WorkManagerWrapper.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/WorkManagerWrapper.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/WorkManagerWrapper.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/WorkManagerWrapper.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,69 @@
+/*
+ * 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.executors;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+
+/**
+ * This helper class is a simple wrapper around the Executor
+ * interface to provide a WorkManager.
+ * 
+ * Note that the implementation is really simplistic
+ * and all calls will delegate to the <code>execute</code>
+ * method of the internal <code>Executor</code>.
+ * 
+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
+ */
+public class WorkManagerWrapper implements WorkManager {
+
+    private final Executor executor;
+    
+    public WorkManagerWrapper(Executor executor) {
+        this.executor = executor;
+    }
+
+    public void doWork(Work work) throws WorkException {
+        executor.execute(work);
+    }
+
+    public void doWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException {
+        executor.execute(work);
+    }
+
+    public void scheduleWork(Work work) throws WorkException {
+        executor.execute(work);
+    }
+
+    public void scheduleWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException {
+        executor.execute(work);
+    }
+
+    public long startWork(Work work) throws WorkException {
+        executor.execute(work);
+        return 0;
+    }
+
+    public long startWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException {
+        executor.execute(work);
+        return 0;
+    }
+    
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,162 @@
+/*
+ * 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.executors.impl;
+
+/**
+ * This bean holds configuration attributes for a given Executor.
+ * 
+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
+ */
+public class ExecutorConfig {
+
+    private int corePoolSize = 4;
+
+    private int maximumPoolSize = -1;
+
+    private long keepAliveTime = 60000;
+
+    private boolean threadDaemon;
+
+    private int threadPriority = Thread.NORM_PRIORITY;
+
+    private int queueSize = 1024;
+
+    private long shutdownDelay = 1000;
+
+    private boolean allowCoreThreadsTimeout = true;
+
+    /**
+     * @return the corePoolSize
+     */
+    public int getCorePoolSize() {
+        return corePoolSize;
+    }
+
+    /**
+     * @param corePoolSize
+     *            the corePoolSize to set
+     */
+    public void setCorePoolSize(int corePoolSize) {
+        this.corePoolSize = corePoolSize;
+    }
+
+    /**
+     * @return the keepAlive
+     */
+    public long getKeepAliveTime() {
+        return keepAliveTime;
+    }
+
+    /**
+     * @param keepAlive
+     *            the keepAlive to set
+     */
+    public void setKeepAliveTime(long keepAlive) {
+        this.keepAliveTime = keepAlive;
+    }
+
+    /**
+     * @return the maximumPoolSize
+     */
+    public int getMaximumPoolSize() {
+        return maximumPoolSize;
+    }
+
+    /**
+     * @param maximumPoolSize
+     *            the maximumPoolSize to set
+     */
+    public void setMaximumPoolSize(int maximumPoolSize) {
+        this.maximumPoolSize = maximumPoolSize;
+    }
+
+    /**
+     * @return the queueSize
+     */
+    public int getQueueSize() {
+        return queueSize;
+    }
+
+    /**
+     * @param queueSize
+     *            the queueSize to set
+     */
+    public void setQueueSize(int queueSize) {
+        this.queueSize = queueSize;
+    }
+
+    /**
+     * @return the threadDaemon
+     */
+    public boolean isThreadDaemon() {
+        return threadDaemon;
+    }
+
+    /**
+     * @param threadDaemon
+     *            the threadDaemon to set
+     */
+    public void setThreadDaemon(boolean threadDaemon) {
+        this.threadDaemon = threadDaemon;
+    }
+
+    /**
+     * @return the threadPriority
+     */
+    public int getThreadPriority() {
+        return threadPriority;
+    }
+
+    /**
+     * @param threadPriority
+     *            the threadPriority to set
+     */
+    public void setThreadPriority(int threadPriority) {
+        this.threadPriority = threadPriority;
+    }
+
+    /**
+     * @return the shutdownDelay
+     */
+    public long getShutdownDelay() {
+        return shutdownDelay;
+    }
+
+    /**
+     * @param shutdownDelay
+     *            the shutdownDelay to set
+     */
+    public void setShutdownDelay(long shutdownDelay) {
+        this.shutdownDelay = shutdownDelay;
+    }
+
+    /**
+     * @return the allowCoreThreadsTimeout
+     */
+    public boolean isAllowCoreThreadsTimeout() {
+        return allowCoreThreadsTimeout;
+    }
+
+    /**
+     * @param allowCoreThreadsTimeout
+     *            the allowCoreThreadsTimeout to set
+     */
+    public void setAllowCoreThreadsTimeout(boolean allowCoreThreadsTimeout) {
+        this.allowCoreThreadsTimeout = allowCoreThreadsTimeout;
+    }
+
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,166 @@
+/*
+ * 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.executors.impl;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.servicemix.executors.Executor;
+import org.apache.servicemix.executors.ExecutorFactory;
+
+/**
+ * Default implementation of the ExecutorFactory.
+ * 
+ * Configuration can be done hierachically.
+ * When an executor is created with an id of <code>foo.bar</code>,
+ * the factory will look for a configuration in the following
+ * way:
+ * <ul>
+ *    <li>configs.get("foo.bar")</li>
+ *    <li>configs.get("foo")</li>
+ *    <li>defaultConfig</li>
+ * </ul>
+ * 
+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
+ */
+public class ExecutorFactoryImpl implements ExecutorFactory {
+
+    private ExecutorConfig defaultConfig = new ExecutorConfig();
+
+    private Map<String, ExecutorConfig> configs = new HashMap<String, ExecutorConfig>();
+
+    public Executor createExecutor(String id) {
+        ExecutorConfig config = getConfig(id);
+        return new ExecutorImpl(createService(id, config), config.getShutdownDelay());
+    }
+
+    protected ExecutorConfig getConfig(String id) {
+        ExecutorConfig config = null;
+        if (configs != null) {
+            config = configs.get(id);
+            while (config == null && id.indexOf('.') > 0) {
+                id = id.substring(0, id.lastIndexOf('.'));
+                config = configs.get(id);
+            }
+        }
+        if (config == null) {
+            config = defaultConfig;
+        }
+        return config;
+    }
+
+    protected ThreadPoolExecutor createService(String id, ExecutorConfig config) {
+        if (config.getQueueSize() != 0 && config.getCorePoolSize() == 0) {
+            throw new IllegalArgumentException("CorePoolSize must be > 0 when using a capacity queue");
+        }
+        BlockingQueue<Runnable> queue;
+        if (config.getQueueSize() == 0) {
+            queue = new SynchronousQueue<Runnable>();
+        } else if (config.getQueueSize() < 0 || config.getQueueSize() == Integer.MAX_VALUE) {
+            queue = new LinkedBlockingQueue<Runnable>();
+        } else {
+            queue = new ArrayBlockingQueue<Runnable>(config.getQueueSize());
+        }
+        ThreadFactory factory = new DefaultThreadFactory(id, config.isThreadDaemon(), config.getThreadPriority());
+        RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();
+        ThreadPoolExecutor service = new ThreadPoolExecutor(config.getCorePoolSize(),
+                config.getMaximumPoolSize() < 0 ? Integer.MAX_VALUE : config.getMaximumPoolSize(), config
+                        .getKeepAliveTime(), TimeUnit.MILLISECONDS, queue, factory, handler);
+        if (config.isAllowCoreThreadsTimeout()) {
+            try {
+                Method mth = service.getClass().getMethod("allowCoreThreadTimeOut", new Class[] {boolean.class });
+                mth.invoke(service, new Object[] {Boolean.TRUE });
+            } catch (Throwable t) {
+                // Do nothing
+            }
+        }
+        return service;
+    }
+
+    /**
+     * The default thread factory
+     */
+    static class DefaultThreadFactory implements ThreadFactory {
+        final ThreadGroup group;
+
+        final AtomicInteger threadNumber = new AtomicInteger(1);
+
+        final String namePrefix;
+
+        final boolean daemon;
+
+        final int priority;
+
+        DefaultThreadFactory(String id, boolean daemon, int priority) {
+            SecurityManager s = System.getSecurityManager();
+            group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
+            namePrefix = "pool-" + id + "-thread-";
+            this.daemon = daemon;
+            this.priority = priority;
+        }
+
+        public Thread newThread(Runnable r) {
+            Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
+            if (t.isDaemon() != daemon) {
+                t.setDaemon(daemon);
+            }
+            if (t.getPriority() != priority) {
+                t.setPriority(priority);
+            }
+            return t;
+        }
+    }
+
+    /**
+     * @return the configs
+     */
+    public Map<String, ExecutorConfig> getConfigs() {
+        return configs;
+    }
+
+    /**
+     * @param configs the configs to set
+     */
+    public void setConfigs(Map<String, ExecutorConfig> configs) {
+        this.configs = configs;
+    }
+
+    /**
+     * @return the defaultConfig
+     */
+    public ExecutorConfig getDefaultConfig() {
+        return defaultConfig;
+    }
+
+    /**
+     * @param defaultConfig the defaultConfig to set
+     */
+    public void setDefaultConfig(ExecutorConfig defaultConfig) {
+        this.defaultConfig = defaultConfig;
+    }
+
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.executors.impl;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.servicemix.executors.Executor;
+
+/**
+ * The default Executor implementation which uses a 
+ * ThreadPoolExecutor underneath.
+ * 
+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
+ */
+public class ExecutorImpl implements Executor {
+
+    private final ThreadPoolExecutor threadPool;
+
+    private final long shutdownDelay;
+
+    public ExecutorImpl(ThreadPoolExecutor threadPool, long shutdownDelay) {
+        this.threadPool = threadPool;
+        this.shutdownDelay = shutdownDelay;
+    }
+
+    public void execute(Runnable command) {
+        threadPool.execute(command);
+    }
+
+    public void shutdown() {
+        threadPool.shutdown();
+        if (!threadPool.isTerminated() && shutdownDelay > 0) {
+            new Thread(new Runnable() {
+                public void run() {
+                    try {
+                        if (!threadPool.awaitTermination(shutdownDelay, TimeUnit.MILLISECONDS)) {
+                            threadPool.shutdownNow();
+                        }
+                    } catch (InterruptedException e) {
+                        // Do nothing
+                    }
+                }
+            }).start();
+        }
+    }
+
+    public int capacity() {
+        BlockingQueue queue = threadPool.getQueue();
+        return queue.remainingCapacity() + queue.size();
+    }
+
+    public int size() {
+        BlockingQueue queue = threadPool.getQueue();
+        return queue.size();
+    }
+
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/package.html
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/package.html?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/package.html (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/impl/package.html Mon Aug 25 06:31:20 2008
@@ -0,0 +1,27 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<html>
+<head>
+</head>
+<body>
+
+Implementations of configurable thread pools.
+
+</body>
+</html>

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/package.html
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/package.html?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/package.html (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/executors/package.html Mon Aug 25 06:31:20 2008
@@ -0,0 +1,27 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<html>
+<head>
+</head>
+<body>
+
+API for configurable thread pools.
+
+</body>
+</html>

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/finder/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/finder/FactoryFinder.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/finder/FactoryFinder.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/finder/FactoryFinder.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,105 @@
+/*
+ * 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.finder;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+public class FactoryFinder {
+
+    private final String path;
+
+    private final Map<String, Class<?>> classMap = new ConcurrentHashMap<String, Class<?>>();
+
+    public FactoryFinder(String path) {
+        this.path = path;
+    }
+
+    /**
+     * Creates a new instance of the given key
+     *
+     * @param key is the key to add to the path to find a text file
+     *            containing the factory name
+     * @return a newly created instance
+     */
+    public Object newInstance(String key) throws IllegalAccessException, InstantiationException, IOException,
+            ClassNotFoundException {
+        return newInstance(key, null);
+    }
+
+    public Object newInstance(String key, String propertyPrefix) throws IllegalAccessException, InstantiationException,
+            IOException, ClassNotFoundException {
+        if (propertyPrefix == null) {
+            propertyPrefix = "";
+        }
+        Class clazz = classMap.get(propertyPrefix + key);
+        if (clazz == null) {
+            clazz = newInstance(doFindFactoryProperies(key), propertyPrefix);
+            classMap.put(propertyPrefix + key, clazz);
+        }
+        return clazz.newInstance();
+    }
+
+    private Class newInstance(Properties properties, String propertyPrefix) throws ClassNotFoundException, IOException {
+
+        String className = properties.getProperty(propertyPrefix + "class");
+        if (className == null) {
+            throw new IOException("Expected property is missing: " + propertyPrefix + "class");
+        }
+        Class clazz;
+        try {
+            clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+        } catch (ClassNotFoundException e) {
+            clazz = FactoryFinder.class.getClassLoader().loadClass(className);
+        }
+
+        return clazz;
+    }
+
+    private Properties doFindFactoryProperies(String key) throws IOException {
+        String uri = path + key;
+
+        // lets try the thread context class loader first
+        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uri);
+        if (in == null) {
+            in = FactoryFinder.class.getClassLoader().getResourceAsStream(uri);
+            if (in == null) {
+                throw new IOException("Could not find factory class for resource: " + uri);
+            }
+        }
+
+        // lets load the file
+        BufferedInputStream reader = null;
+        try {
+            reader = new BufferedInputStream(in);
+            Properties properties = new Properties();
+            properties.load(reader);
+            return properties;
+        } finally {
+            try {
+                reader.close();
+            } catch (Exception e) {
+                // Do nothing
+            }
+        }
+    }
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/id/IdGenerator.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/id/IdGenerator.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/id/IdGenerator.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/id/IdGenerator.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,125 @@
+/*
+ * 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.id;
+
+/*
+ * Copied from
+ * http://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IdGenerator.java
+ */
+
+import java.net.InetAddress;
+import java.net.ServerSocket;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Generator for Globally unique Strings.
+ */
+
+public class IdGenerator {
+
+    private static final Log LOG = LogFactory.getLog(IdGenerator.class);
+
+    private static final String UNIQUE_STUB;
+
+    private static int instanceCount;
+
+    private static String hostName;
+
+    private String seed;
+
+    private long sequence;
+
+    public IdGenerator() {
+        this("ID:");
+    }
+
+    /**
+     * Construct an IdGenerator
+     * 
+     */
+    public IdGenerator(String prefix) {
+        synchronized (UNIQUE_STUB) {
+            this.seed = prefix + UNIQUE_STUB + (instanceCount++) + ":";
+        }
+    }
+    
+    static {
+        String stub = "";
+        boolean canAccessSystemProps = true;
+        try {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                sm.checkPropertiesAccess();
+            }
+        } catch (SecurityException se) {
+            canAccessSystemProps = false;
+        }
+
+        if (canAccessSystemProps) {
+            try {
+                hostName = InetAddress.getLocalHost().getHostAddress();
+                ServerSocket ss = new ServerSocket(0);
+                stub = hostName + "-" + Long.toHexString(ss.getLocalPort() ^ System.currentTimeMillis()) + "-";
+                Thread.sleep(100);
+                ss.close();
+            } catch (Exception ioe) {
+                LOG.warn("Could not generate unique stub", ioe);
+            }
+        } else {
+            hostName = "localhost";
+            stub = hostName + Long.toHexString(System.currentTimeMillis()) + "-";
+        }
+        UNIQUE_STUB = stub;
+    }
+
+    /**
+     * As we have to find the hostname as a side-affect of generating a unique
+     * stub, we allow it's easy retrevial here
+     * 
+     * @return the local host name
+     */
+
+    public static String getHostName() {
+        return hostName;
+    }
+
+    /**
+     * Generate a unqiue id
+     * 
+     * @return a unique id
+     */
+
+    public synchronized String generateId() {
+        return this.seed + (this.sequence++);
+    }
+
+    /**
+     * Generate a unique ID - that is friendly for a URL or file system
+     * 
+     * @return a unique id
+     */
+    public String generateSanitizedId() {
+        String result = generateId();
+        result = result.replace(':', '-');
+        result = result.replace('_', '-');
+        result = result.replace('.', '-');
+        return result;
+    }
+
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -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.jdbc;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public interface JDBCAdapter {
+
+    void doCreateTables(Connection connection) throws SQLException, IOException;
+    
+    void doDropTables(Connection connection) throws SQLException, IOException;
+    
+    byte[] doLoadData(Connection connection, String id) throws SQLException, IOException;
+    
+    byte[][] doLoadData(Connection connection, String[] ids) throws SQLException, IOException;
+    
+    void doStoreData(Connection connection, String id, byte[] data) throws SQLException, IOException;
+    
+    void doUpdateData(Connection connection, String id, byte[] data) throws SQLException, IOException;
+    
+    void doRemoveData(Connection connection, String id) throws SQLException, IOException;
+    
+    void doRemoveData(Connection connection, String[] ids) throws SQLException, IOException;
+    
+    int doGetCount(Connection connection) throws SQLException, IOException;
+    
+    String[] doGetIds(Connection connection) throws SQLException, IOException;
+    
+    String[] doGetIds(Connection connection, int fromIndex, int toIndex) throws SQLException, IOException;
+    
+    Statements getStatements();
+    
+    void setStatements(Statements statements);
+    
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,76 @@
+/*
+ * 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.jdbc;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.finder.FactoryFinder;
+import org.apache.servicemix.jdbc.adapter.DefaultJDBCAdapter;
+
+public final class JDBCAdapterFactory {
+
+    private static final Log LOG = LogFactory.getLog(JDBCAdapterFactory.class);
+    private static FactoryFinder factoryFinder = new FactoryFinder("META-INF/services/org/apache/servicemix/jdbc/");
+
+    private JDBCAdapterFactory() {
+    }
+    
+    public static JDBCAdapter getAdapter(Connection connection) {
+        JDBCAdapter adapter = null;
+        try {
+
+            // Make the filename file system safe.
+            String driverName = connection.getMetaData().getDriverName();
+            driverName = driverName.replaceAll("[^a-zA-Z0-9\\-]", "_").toLowerCase();
+
+            try {
+                adapter = (JDBCAdapter) factoryFinder.newInstance(driverName);
+                LOG.info("Database driver recognized: [" + driverName + "]");
+            } catch (Throwable e) {
+                LOG.warn("Database driver NOT recognized: [" + driverName
+                        + "].  Will use default JDBC implementation.");
+            }
+
+        } catch (SQLException e) {
+            LOG.warn("JDBC error occurred while trying to detect database type.  Will use default JDBC implementation: "
+                            + e.getMessage());
+            log("Failure details: ", e);
+        }
+
+        // Use the default JDBC adapter if the
+        // Database type is not recognized.
+        if (adapter == null) {
+            adapter = new DefaultJDBCAdapter();
+        }
+        
+        return adapter;
+    }
+    
+    public static void log(String msg, SQLException e) {
+        if (LOG.isDebugEnabled()) {
+            String s = msg + e.getMessage();
+            while (e.getNextException() != null) {
+                e = e.getNextException();
+                s += ", due to: " + e.getMessage();
+            }
+            LOG.debug(s, e);
+        }
+    }
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/Statements.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/Statements.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/Statements.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/Statements.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,213 @@
+/*
+ * 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.jdbc;
+
+/**
+ * @version $Revision: 1.4 $
+ * 
+ * @org.apache.xbean.XBean element="statements"
+ * 
+ */
+public class Statements {
+
+    protected String storeTableName = "SM_STORE";
+    protected String binaryDataType = "BLOB";
+    protected String idDataType = "VARCHAR(255)";
+    private String tablePrefix = "";
+    private String storeDataStatement;
+    private String updateDataStatement;
+    private String removeDataStatement;
+    private String findDataStatement;
+    private String findAllIdsStatement;
+    private String findAllDataStatement;
+    private String countStatement;
+    private String[] createSchemaStatements;
+    private String[] dropSchemaStatements;
+
+    public String[] getCreateSchemaStatements() {
+        if (createSchemaStatements == null) {
+            createSchemaStatements = new String[] {
+                "CREATE TABLE " + getFullStoreTableName() + "(" + "ID " + idDataType + " NOT NULL"
+                            + ", DATA " + binaryDataType
+                            + ", PRIMARY KEY ( ID ) )",
+            };
+        }
+        return createSchemaStatements;
+    }
+
+    public String[] getDropSchemaStatements() {
+        if (dropSchemaStatements == null) {
+            dropSchemaStatements = new String[] { 
+                "DROP TABLE " + getFullStoreTableName() + "", 
+            };
+        }
+        return dropSchemaStatements;
+    }
+
+    public String getStoreDataStatement() {
+        if (storeDataStatement == null) {
+            storeDataStatement = "INSERT INTO " + getFullStoreTableName()
+                    + "(ID, DATA) VALUES (?, ?)";
+        }
+        return storeDataStatement;
+    }
+
+    public String getUpdateDataStatement() {
+        if (updateDataStatement == null) {
+            updateDataStatement = "UPDATE " + getFullStoreTableName() + " SET DATA=? WHERE ID=?";
+        }
+        return updateDataStatement;
+    }
+
+    public String getRemoveDataStatement() {
+        if (removeDataStatement == null) {
+            removeDataStatement = "DELETE FROM " + getFullStoreTableName() + " WHERE ID=?";
+        }
+        return removeDataStatement;
+    }
+
+    public String getFindDataStatement() {
+        if (findDataStatement == null) {
+            findDataStatement = "SELECT DATA FROM " + getFullStoreTableName() + " WHERE ID=?";
+        }
+        return findDataStatement;
+    }
+
+    public String getFindAllIdsStatement() {
+        if (findAllIdsStatement == null) {
+            findAllIdsStatement = "SELECT ID FROM " + getFullStoreTableName() 
+                    + " ORDER BY ID"; 
+        }
+        return findAllIdsStatement;
+    }
+
+    public String getFindAllDataStatement() {
+        if (findAllDataStatement == null) {
+            findAllDataStatement = "SELECT ID, DATA FROM " + getFullStoreTableName()
+                    + " WHERE ORDER BY ID";
+        }
+        return findAllDataStatement;
+    }
+
+    public String getCountStatement() {
+        if (countStatement == null) {
+            countStatement = "SELECT COUNT(ID) FROM " + getFullStoreTableName();
+        }
+        return countStatement;
+    }
+
+    public String getFullStoreTableName() {
+        return getTablePrefix() + getStoreTableName();
+    }
+
+    /**
+     * @return Returns the messageDataType.
+     */
+    public String getBinaryDataType() {
+        return binaryDataType;
+    }
+
+    /**
+     * @param messageDataType
+     *            The messageDataType to set.
+     */
+    public void setBinaryDataType(String messageDataType) {
+        this.binaryDataType = messageDataType;
+    }
+
+    /**
+     * @return Returns the storeTableName.
+     */
+    public String getStoreTableName() {
+        return storeTableName;
+    }
+
+    /**
+     * @param storeTableName
+     *            The storeTableName to set.
+     */
+    public void setStoreTableName(String storeTableName) {
+        this.storeTableName = storeTableName;
+    }
+
+    /**
+     * @return Returns the idDataType.
+     */
+    public String getIdDataType() {
+        return idDataType;
+    }
+
+    /**
+     * @param idDataType
+     *            The idDataType to set.
+     */
+    public void setIdDataType(String msgIdDataType) {
+        this.idDataType = msgIdDataType;
+    }
+
+    /**
+     * @return Returns the tablePrefix.
+     */
+    public String getTablePrefix() {
+        return tablePrefix;
+    }
+
+    /**
+     * @param tablePrefix
+     *            The tablePrefix to set.
+     */
+    public void setTablePrefix(String tablePrefix) {
+        this.tablePrefix = tablePrefix;
+    }
+
+    public void setStoreDataStatement(String addMessageStatment) {
+        this.storeDataStatement = addMessageStatment;
+    }
+
+    public void setCreateSchemaStatements(String[] createSchemaStatments) {
+        this.createSchemaStatements = createSchemaStatments;
+    }
+
+    public void setDropSchemaStatements(String[] dropSchemaStatments) {
+        this.dropSchemaStatements = dropSchemaStatments;
+    }
+
+    public void setFindAllDataStatement(String findAllMessagesStatment) {
+        this.findAllDataStatement = findAllMessagesStatment;
+    }
+
+    public void setFindDataStatement(String findMessageStatment) {
+        this.findDataStatement = findMessageStatment;
+    }
+
+    public void setRemoveDataStatement(String removeMessageStatment) {
+        this.removeDataStatement = removeMessageStatment;
+    }
+
+    public void setUpdateDataStatement(String updateMessageStatment) {
+        this.updateDataStatement = updateMessageStatment;
+    }
+
+    public void setFindAllIdsStatement(String findAllIdsStatement) {
+        this.findAllIdsStatement = findAllIdsStatement;
+    }
+
+    public void setCountStatement(String getCountStatement) {
+        this.countStatement = getCountStatement;
+    }
+
+}
\ No newline at end of file

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/AxionJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/AxionJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/AxionJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/AxionJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -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.
+ */
+package org.apache.servicemix.jdbc.adapter;
+
+
+
+/**
+ * Axion specific Adapter.
+ * 
+ * @org.apache.xbean.XBean element="axionJDBCAdapter"
+ * @version $Revision: 1.4 $
+ */
+public class AxionJDBCAdapter extends StreamJDBCAdapter {
+
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BlobJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BlobJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BlobJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BlobJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.jdbc.adapter;
+
+
+
+/**
+ * This JDBCAdapter inserts and extracts BLOB data using the 
+ * getBlob()/setBlob() operations.  This is a little more involved
+ * since to insert a blob you have to:
+ * 
+ *  1: insert empty blob.
+ *  2: select the blob 
+ *  3: finally update the blob with data value. 
+ * 
+ * The databases/JDBC drivers that use this adapter are:
+ * <ul>
+ * <li></li> 
+ * </ul>
+ * 
+ * @org.apache.xbean.XBean element="blobJDBCAdapter"
+ * 
+ * @version $Revision: 1.2 $
+ */
+public class BlobJDBCAdapter extends DefaultJDBCAdapter {
+    
+}
\ No newline at end of file

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -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.jdbc.adapter;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * This JDBCAdapter inserts and extracts BLOB data using the 
+ * setBytes()/getBytes() operations.
+ * 
+ * The databases/JDBC drivers that use this adapter are:
+ * 
+ * @org.apache.xbean.XBean element="bytesJDBCAdapter"
+ * 
+ * @version $Revision: 1.2 $
+ */
+public class BytesJDBCAdapter extends DefaultJDBCAdapter {
+
+    /**
+     * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#getBinaryData(java.sql.ResultSet, int)
+     */
+    protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException {
+        return rs.getBytes(index);
+    }
+
+    /**
+     * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#setBinaryData(java.sql.PreparedStatement, int, byte[])
+     */
+    protected void setBinaryData(PreparedStatement s, int index, byte[] data) throws SQLException {
+        s.setBytes(index, data);
+    }
+
+}
\ No newline at end of file

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DB2JDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DB2JDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DB2JDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DB2JDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,36 @@
+/*
+ * 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.jdbc.adapter;
+
+import java.sql.Blob;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ *
+ * @org.apache.xbean.XBean element="db2JDBCAdapter"
+ *
+ * @version $Revision: 1.2 $
+ */
+public class DB2JDBCAdapter extends DefaultJDBCAdapter {
+
+    protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException {
+        // Get as a BLOB
+        Blob aBlob = rs.getBlob(index);
+        return aBlob.getBytes(1, (int) aBlob.length());
+    }
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,313 @@
+/*
+ * 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.jdbc.adapter;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jdbc.JDBCAdapter;
+import org.apache.servicemix.jdbc.JDBCAdapterFactory;
+import org.apache.servicemix.jdbc.Statements;
+
+/**
+ * Implements all the default JDBC operations that are used by the
+ * JDBCPersistenceAdapter. <p/> sub-classing is encouraged to override the
+ * default implementation of methods to account for differences in JDBC Driver
+ * implementations. <p/> The JDBCAdapter inserts and extracts BLOB data using
+ * the getBytes()/setBytes() operations. <p/> The databases/JDBC drivers that
+ * use this adapter are:
+ * <ul>
+ * <li></li>
+ * </ul>
+ * 
+ * @org.apache.xbean.XBean element="defaultJDBCAdapter"
+ * 
+ * @version $Revision: 1.10 $
+ */
+public class DefaultJDBCAdapter implements JDBCAdapter {
+
+    private static final Log LOG = LogFactory.getLog(DefaultJDBCAdapter.class);
+
+    protected Statements statements;
+
+    protected void setBinaryData(PreparedStatement s, int index, byte data[]) throws SQLException {
+        s.setBytes(index, data);
+    }
+
+    protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException {
+        return rs.getBytes(index);
+    }
+
+    public void doCreateTables(Connection connection) throws SQLException, IOException {
+        Statement s = null;
+        try {
+            // Check to see if the table already exists. If it does, then don't
+            // log warnings during startup.
+            // Need to run the scripts anyways since they may contain ALTER
+            // statements that upgrade a previous version of the table
+            boolean alreadyExists = false;
+            ResultSet rs = null;
+            try {
+                rs = connection.getMetaData().getTables(null, null, statements.getFullStoreTableName(),
+                        new String[] {"TABLE" });
+                alreadyExists = rs.next();
+            } catch (Throwable ignore) {
+                // Do nothing
+            } finally {
+                close(rs);
+            }
+
+            // If the dataSource is a managed DataSource, executing a statement
+            // that throws
+            // an exception will make the connection unusable.
+            // So if the table already exists, do not try to re-create them
+            if (alreadyExists) {
+                return;
+            }
+
+            s = connection.createStatement();
+            String[] createStatments = statements.getCreateSchemaStatements();
+            for (int i = 0; i < createStatments.length; i++) {
+                // This will fail usually since the tables will be
+                // created already.
+                try {
+                    LOG.debug("Executing SQL: " + createStatments[i]);
+                    s.execute(createStatments[i]);
+                } catch (SQLException e) {
+                    if (alreadyExists) {
+                        LOG.debug("Could not create JDBC tables; The message table already existed." + " Failure was: "
+                                + createStatments[i] + " Message: " + e.getMessage() + " SQLState: " + e.getSQLState()
+                                + " Vendor code: " + e.getErrorCode());
+                    } else {
+                        LOG.warn("Could not create JDBC tables; they could already exist." + " Failure was: "
+                                + createStatments[i] + " Message: " + e.getMessage() + " SQLState: " + e.getSQLState()
+                                + " Vendor code: " + e.getErrorCode());
+                        JDBCAdapterFactory.log("Failure details: ", e);
+                    }
+                }
+            }
+        } finally {
+            close(s);
+        }
+    }
+
+    public void doDropTables(Connection connection) throws SQLException, IOException {
+        Statement s = null;
+        try {
+            s = connection.createStatement();
+            String[] dropStatments = statements.getDropSchemaStatements();
+            for (int i = 0; i < dropStatments.length; i++) {
+                // This will fail usually since the tables will be
+                // created already.
+                try {
+                    s.execute(dropStatments[i]);
+                } catch (SQLException e) {
+                    LOG.warn("Could not drop JDBC tables; they may not exist." + " Failure was: " + dropStatments[i]
+                            + " Message: " + e.getMessage() + " SQLState: " + e.getSQLState() + " Vendor code: "
+                            + e.getErrorCode());
+                    JDBCAdapterFactory.log("Failure details: ", e);
+                }
+            }
+        } finally {
+            close(s);
+        }
+    }
+
+    public void doStoreData(Connection connection, String id, byte[] data) throws SQLException, IOException {
+        PreparedStatement s = null;
+        try {
+            if (s == null) {
+                s = connection.prepareStatement(statements.getStoreDataStatement());
+            }
+            s.setString(1, id);
+            setBinaryData(s, 2, data);
+            if (s.executeUpdate() != 1) {
+                throw new SQLException("Failed to insert data");
+            }
+        } finally {
+            close(s);
+        }
+    }
+
+    public byte[] doLoadData(Connection connection, String id) throws SQLException, IOException {
+        PreparedStatement s = null;
+        ResultSet rs = null;
+        try {
+            s = connection.prepareStatement(statements.getFindDataStatement());
+            s.setString(1, id);
+            rs = s.executeQuery();
+            if (!rs.next()) {
+                return null;
+            }
+            return getBinaryData(rs, 1);
+        } finally {
+            close(rs);
+            close(s);
+        }
+    }
+
+    public void doUpdateData(Connection connection, String id, byte[] data) throws SQLException, IOException {
+        PreparedStatement s = null;
+        try {
+            if (s == null) {
+                s = connection.prepareStatement(statements.getUpdateDataStatement());
+            }
+            s.setString(2, id);
+            setBinaryData(s, 1, data);
+            if (s.executeUpdate() != 1) {
+                throw new SQLException("Failed to update data");
+            }
+        } finally {
+            close(s);
+        }
+    }
+
+    public void doRemoveData(Connection connection, String id) throws SQLException, IOException {
+        PreparedStatement s = null;
+        try {
+            s = connection.prepareStatement(statements.getRemoveDataStatement());
+            s.setString(1, id);
+            if (s.executeUpdate() != 1) {
+                throw new SQLException("Failed to remove data");
+            }
+        } finally {
+            close(s);
+        }
+    }
+
+    private static void close(Statement s) {
+        try {
+            if (s != null) {
+                s.close();
+            }
+        } catch (Throwable e) {
+            // Do nothing
+        }
+    }
+
+    private static void close(ResultSet rs) {
+        try {
+            if (rs != null) {
+                rs.close();
+            }
+        } catch (Throwable e) {
+            // Do nothing
+        }
+    }
+
+    public Statements getStatements() {
+        return statements;
+    }
+
+    public void setStatements(Statements statements) {
+        this.statements = statements;
+    }
+
+    public byte[][] doLoadData(Connection connection, String[] ids) throws SQLException, IOException {
+        PreparedStatement s = null;
+        byte[][] datas = new byte[ids.length][];
+        try {
+            s = connection.prepareStatement(statements.getFindDataStatement());
+            for (int i = 0; i < ids.length; i++) {
+                s.setString(1, ids[i]);
+                ResultSet rs = s.executeQuery();
+                if (rs.next()) {
+                    datas[i] = getBinaryData(rs, 1);
+                }
+                close(rs);
+            }
+            return datas;
+        } finally {
+            close(s);
+        }
+    }
+
+    public void doRemoveData(Connection connection, String[] ids) throws SQLException, IOException {
+        PreparedStatement s = null;
+        try {
+            s = connection.prepareStatement(statements.getRemoveDataStatement());
+            for (int i = 0; i < ids.length; i++) {
+                s.setString(1, ids[i]);
+                s.executeUpdate();
+            }
+        } finally {
+            close(s);
+        }
+    }
+
+    public int doGetCount(Connection connection) throws SQLException, IOException {
+        PreparedStatement s = null;
+        ResultSet rs = null;
+        try {
+            s = connection.prepareStatement(statements.getCountStatement());
+            rs = s.executeQuery();
+            rs.next();
+            return rs.getInt(1);
+        } finally {
+            close(rs);
+            close(s);
+        }
+    }
+
+    public String[] doGetIds(Connection connection) throws SQLException, IOException {
+        PreparedStatement s = null;
+        ResultSet rs = null;
+        try {
+            List<String> ids = new ArrayList<String>();
+            s = connection.prepareStatement(statements.getFindAllIdsStatement());
+            rs = s.executeQuery();
+            while (rs.next()) {
+                ids.add(rs.getString(1));
+            }
+            return ids.toArray(new String[ids.size()]);
+        } finally {
+            close(rs);
+            close(s);
+        }
+    }
+
+    public String[] doGetIds(Connection connection, int fromIndex, int toIndex) throws SQLException, IOException {
+        Statement s = null;
+        ResultSet rs = null;
+        try {
+            s = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+            s.setFetchSize(toIndex - fromIndex);
+            rs = s.executeQuery(statements.getFindAllIdsStatement());
+            rs.absolute(fromIndex + 1);
+            String[] ids = new String[toIndex - fromIndex];
+            for (int row = 0; row < toIndex - fromIndex; row++) {
+                ids[row] = rs.getString(1);
+                if (!rs.next()) {
+                    break;
+                }
+            }
+            return ids;
+        } finally {
+            close(rs);
+            close(s);
+        }
+    }
+
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.jdbc.adapter;
+
+import org.apache.servicemix.jdbc.Statements;
+
+/**
+ * 
+ * @version $Revision: 1.2 $
+ */
+public class HsqldbJDBCAdapter extends BytesJDBCAdapter {
+
+    public void setStatements(Statements statements) {
+        statements.setBinaryDataType("OTHER");
+        super.setStatements(statements);
+    }
+
+}
\ No newline at end of file

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/ImageBasedJDBCAdaptor.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/ImageBasedJDBCAdaptor.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/ImageBasedJDBCAdaptor.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/ImageBasedJDBCAdaptor.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,40 @@
+/*
+ * 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.jdbc.adapter;
+
+import org.apache.servicemix.jdbc.Statements;
+
+/**
+ * Provides JDBCAdapter since that uses
+ * IMAGE datatype to hold binary data.
+ * 
+ * The databases/JDBC drivers that use this adapter are:
+ * <ul>
+ * <li>Sybase</li>
+ * <li>MS SQL</li>
+ * </ul>
+ * 
+ * @org.apache.xbean.XBean element="imageBasedJDBCAdaptor"
+ */
+public class ImageBasedJDBCAdaptor extends DefaultJDBCAdapter {
+
+    public void setStatements(Statements statements) {
+        statements.setBinaryDataType("IMAGE");
+        super.setStatements(statements);
+    }
+    
+}
\ No newline at end of file

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/InformixJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/InformixJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/InformixJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/InformixJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,28 @@
+/*
+ * 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.jdbc.adapter;
+
+
+/**
+ * JDBC Adapter for Informix database.
+ * Informix database restricts length of composite keys.
+ *  
+ * @org.apache.xbean.XBean element="informixJDBCAdapter"
+ */
+public class InformixJDBCAdapter extends BlobJDBCAdapter {
+
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/MaxDBJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/MaxDBJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/MaxDBJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/MaxDBJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.jdbc.adapter;
+
+import org.apache.servicemix.jdbc.Statements;
+
+/**
+ * JDBC Adapter for the MaxDB database.
+ */
+public class MaxDBJDBCAdapter extends DefaultJDBCAdapter {
+
+    public void setStatements(Statements statements) {
+        statements.setBinaryDataType("LONG BYTE");
+        statements.setIdDataType("VARCHAR(250) ASCII");
+        super.setStatements(statements);
+    }
+
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/OracleJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/OracleJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/OracleJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/OracleJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.jdbc.adapter;
+
+import java.sql.Blob;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Implements all the default JDBC operations that are used
+ * by the JDBCPersistenceAdapter.
+ * <p/>
+ * Subclassing is encouraged to override the default
+ * implementation of methods to account for differences
+ * in JDBC Driver implementations.
+ * <p/>
+ * The JDBCAdapter inserts and extracts BLOB data using the
+ * getBytes()/setBytes() operations.
+ * <p/>
+ * The databases/JDBC drivers that use this adapter are:
+ * <ul>
+ * <li></li>
+ * </ul>
+ *
+ * @org.apache.xbean.XBean element="oracleJDBCAdapter"
+ *
+ * @version $Revision: 1.2 $
+ */
+public class OracleJDBCAdapter extends DefaultJDBCAdapter {
+
+    protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException {
+        // Get as a BLOB
+        Blob aBlob = rs.getBlob(index);
+        if (aBlob == null) {
+            return null;
+        }
+        return aBlob.getBytes(1, (int) aBlob.length());
+    }
+}

Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/PostgresqlJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/PostgresqlJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/PostgresqlJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/PostgresqlJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,47 @@
+/*
+ * 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.jdbc.adapter;
+
+import org.apache.servicemix.jdbc.Statements;
+
+
+/**
+ * Implements all the default JDBC operations that are used
+ * by the JDBCPersistenceAdapter.
+ * <p/>
+ * Subclassing is encouraged to override the default
+ * implementation of methods to account for differences
+ * in JDBC Driver implementations.
+ * <p/>
+ * The JDBCAdapter inserts and extracts BLOB data using the
+ * getBytes()/setBytes() operations.
+ * <p/>
+ * The databases/JDBC drivers that use this adapter are:
+ * <ul>
+ * <li></li>
+ * </ul>
+ *
+ * @version $Revision: 1.1 $
+ */
+public class PostgresqlJDBCAdapter extends BytesJDBCAdapter {
+
+    public void setStatements(Statements statements) {
+        statements.setBinaryDataType("BYTEA");
+        super.setStatements(statements);
+    }
+
+}