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 [2/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...
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,70 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * This JDBCAdapter inserts and extracts BLOB data using the
+ * setBinaryStream()/getBinaryStream() operations.
+ *
+ * The databases/JDBC drivers that use this adapter are:
+ * <ul>
+ * <li>Axion</li>
+ * </ul>
+ *
+ * @org.apache.xbean.XBean element="streamJDBCAdapter"
+ *
+ * @version $Revision: 1.2 $
+ */
+public class StreamJDBCAdapter extends DefaultJDBCAdapter {
+
+ /**
+ * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#getBinaryData(java.sql.ResultSet, int)
+ */
+ protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException {
+
+ try {
+ InputStream is = rs.getBinaryStream(index);
+ ByteArrayOutputStream os = new ByteArrayOutputStream(1024 * 4);
+ int ch = is.read();
+ while (ch >= 0) {
+ os.write(ch);
+ ch = is.read();
+ }
+ is.close();
+ os.close();
+ return os.toByteArray();
+ } catch (IOException e) {
+ throw (SQLException) new SQLException("Error reading binary parameter: " + index).initCause(e);
+ }
+ }
+
+ /**
+ * @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.setBinaryStream(index, new ByteArrayInputStream(data), data.length);
+ }
+
+}
\ No newline at end of file
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/LockManager.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/LockManager.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/LockManager.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/LockManager.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,26 @@
+/*
+ * 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.locks;
+
+import java.util.concurrent.locks.Lock;
+
+@Deprecated
+public interface LockManager {
+
+ Lock getLock(String id);
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLock.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,103 @@
+/*
+ * 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.locks.impl;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.AbstractQueuedSynchronizer;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * @author lhein
+ */
+@Deprecated
+public class SimpleLock implements Lock, Serializable {
+
+ // Our internal helper class
+ private static class Sync extends AbstractQueuedSynchronizer {
+ // Report whether in locked state
+ protected boolean isHeldExclusively() {
+ return getState() == 1;
+ }
+
+ // Acquire the lock if state is zero
+ public boolean tryAcquire(int acquires) {
+ assert acquires == 1; // Otherwise unused
+ return compareAndSetState(0, 1);
+ }
+
+ // Release the lock by setting state to zero
+ protected boolean tryRelease(int releases) {
+ assert releases == 1; // Otherwise unused
+ if (getState() == 0) {
+ throw new IllegalMonitorStateException();
+ }
+ setState(0);
+ return true;
+ }
+
+ // Provide a Condition
+ Condition newCondition() {
+ return new ConditionObject();
+ }
+
+ // Deserialize properly
+ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
+ s.defaultReadObject();
+ setState(0); // reset to unlocked state
+ }
+ }
+
+ // The sync object does all the hard work. We just forward to it.
+ private final Sync sync = new Sync();
+
+ public void lock() {
+ sync.acquire(1);
+ }
+
+ public boolean tryLock() {
+ return sync.tryAcquire(1);
+ }
+
+ public void unlock() {
+ sync.release(1);
+ }
+
+ public Condition newCondition() {
+ return sync.newCondition();
+ }
+
+ public boolean isLocked() {
+ return sync.isHeldExclusively();
+ }
+
+ public boolean hasQueuedThreads() {
+ return sync.hasQueuedThreads();
+ }
+
+ public void lockInterruptibly() throws InterruptedException {
+ sync.acquireInterruptibly(1);
+ }
+
+ public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
+ return sync.tryAcquireNanos(1, unit.toNanos(timeout));
+ }
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,42 @@
+/*
+ * 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.locks.impl;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.locks.Lock;
+
+import org.apache.servicemix.locks.LockManager;
+
+@Deprecated
+public class SimpleLockManager implements LockManager {
+
+ private ConcurrentMap<String, Lock> locks = new ConcurrentHashMap<String, Lock>();
+
+ public Lock getLock(String id) {
+ Lock lock = locks.get(id);
+ if (lock == null) {
+ lock = new SimpleLock();
+ Lock oldLock = locks.putIfAbsent(id, lock);
+ if (oldLock != null) {
+ lock = oldLock;
+ }
+ }
+ return lock;
+ }
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/Store.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/Store.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/Store.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/Store.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,77 @@
+/*
+ * 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.store;
+
+import java.io.IOException;
+
+/**
+ * A Store is an interface representing a storage where objects can be
+ * put and retrieved. A store can support different features, mainly
+ * persistence, clustered or transactional.
+ *
+ * A store is not designed to be a thread-safe map. If a user tries to
+ * store an object with an existing id, the behavior is undefined.
+ *
+ * @author gnodet
+ */
+public interface Store {
+
+ String PERSISTENT = "Persistent";
+
+ String CLUSTERED = "Clustered";
+
+ String TRANSACTIONAL = "Transactional";
+
+ /**
+ * Returns true if the store implementation supports the given feature.
+ * @param name the feature to check
+ * @return <code>true</code> if the feature is supported
+ */
+ boolean hasFeature(String name);
+
+ /**
+ * Put an object in the store under the given id.
+ * This method must be used with caution and the behavior is
+ * unspecified if an object already exist for the same id.
+ *
+ * @param id the id of the object to store
+ * @param data the object to store
+ * @throws IOException if an error occurs
+ */
+ void store(String id, Object data) throws IOException;
+
+ /**
+ * Put an object into the store and return the unique id that
+ * may be used at a later time to retrieve the object.
+ *
+ * @param data the object to store
+ * @return the id of the object stored
+ * @throws IOException if an error occurs
+ */
+ String store(Object data) throws IOException;
+
+ /**
+ * Loads an object that has been previously stored under the specified key.
+ * The object is removed from the store.
+ *
+ * @param id the id of the object
+ * @return the object, or <code>null></code> if the object could not be found
+ * @throws IOException if an error occurs
+ */
+ Object load(String id) throws IOException;
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/StoreFactory.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/StoreFactory.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/StoreFactory.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/StoreFactory.java 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.
+ */
+package org.apache.servicemix.store;
+
+import java.io.IOException;
+
+public interface StoreFactory {
+
+ Store open(String name) throws IOException;
+
+ void close(Store store) throws IOException;
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/TimeoutMemoryStore.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/TimeoutMemoryStore.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/TimeoutMemoryStore.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/TimeoutMemoryStore.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.store.memory;
+
+import java.io.IOException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.id.IdGenerator;
+
+/**
+ * {@link MemoryStore} which removes entries from the store after the specified timeout
+ * to free memory.
+ */
+public class TimeoutMemoryStore extends MemoryStore {
+
+ private static final Log LOG = LogFactory.getLog(TimeoutMemoryStore.class);
+ private ConcurrentMap<String, Entry> datas = new ConcurrentHashMap<String, Entry>();
+ private final long timeout;
+
+ protected TimeoutMemoryStore(IdGenerator idGenerator, long timeout) {
+ super(idGenerator);
+ this.timeout = timeout;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void store(String id, Object data) throws IOException {
+ LOG.debug("Storing object with id: " + id);
+ datas.put(id, new Entry(data));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Before attempting to load the object, all data older than the specified timeout will first be
+ * removed from the store.
+ */
+ public Object load(String id) throws IOException {
+ evict();
+ LOG.debug("Loading object with id:" + id);
+ Entry entry = datas.remove(id);
+ return entry == null ? null : entry.data;
+ }
+
+ private void evict() {
+ long now = System.currentTimeMillis();
+ for (String key : datas.keySet()) {
+ long age = now - datas.get(key).time;
+ if (age > timeout) {
+ LOG.debug("Removing object with id " + key + " from store after " + age + " ms");
+ datas.remove(key);
+ }
+ }
+ }
+
+ /*
+ * A single store entry
+ */
+ private final class Entry {
+ private final long time = System.currentTimeMillis();
+ private final Object data;
+
+ private Entry(Object data) {
+ this.data = data;
+ }
+ }
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,101 @@
+/*
+ * 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.store.jdbc;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.sql.Connection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.store.Store;
+
+public class JdbcStore implements Store {
+
+ private static final Log LOG = LogFactory.getLog(JdbcStore.class);
+
+ private JdbcStoreFactory factory;
+ private String name;
+
+ public JdbcStore(JdbcStoreFactory factory, String name) {
+ this.factory = factory;
+ this.name = name;
+ }
+
+ public boolean hasFeature(String feature) {
+ return PERSISTENT.equals(feature)
+ || (CLUSTERED.equals(feature) && factory.isClustered())
+ || (TRANSACTIONAL.equals(feature) && factory.isTransactional());
+ }
+
+ public void store(String id, Object data) throws IOException {
+ LOG.debug("Storing object with id: " + id);
+ Connection connection = null;
+ try {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(buffer);
+ out.writeObject(data);
+ out.close();
+ connection = factory.getDataSource().getConnection();
+ factory.getAdapter().doStoreData(connection, name + ":" + id, buffer.toByteArray());
+ } catch (Exception e) {
+ throw (IOException) new IOException("Error storing object").initCause(e);
+ } finally {
+ close(connection);
+ }
+ }
+
+ public String store(Object data) throws IOException {
+ String id = factory.getIdGenerator().generateId();
+ store(id, data);
+ return id;
+ }
+
+ public Object load(String id) throws IOException {
+ LOG.debug("Loading object with id: " + id);
+ Connection connection = null;
+ try {
+ connection = factory.getDataSource().getConnection();
+ byte[] data = factory.getAdapter().doLoadData(connection, name + ":" + id);
+ Object result = null;
+ if (data != null) {
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
+ result = ois.readObject();
+ factory.getAdapter().doRemoveData(connection, name + ":" + id);
+ }
+ return result;
+ } catch (Exception e) {
+ throw (IOException) new IOException("Error storing object").initCause(e);
+ } finally {
+ close(connection);
+ }
+ }
+
+ protected void close(Connection connection) throws IOException {
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ throw (IOException) new IOException("Error closing connection").initCause(e);
+ }
+ }
+ }
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,182 @@
+/*
+ * 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.store.jdbc;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.apache.servicemix.id.IdGenerator;
+import org.apache.servicemix.jdbc.JDBCAdapter;
+import org.apache.servicemix.jdbc.JDBCAdapterFactory;
+import org.apache.servicemix.jdbc.Statements;
+import org.apache.servicemix.store.Store;
+import org.apache.servicemix.store.StoreFactory;
+
+public class JdbcStoreFactory implements StoreFactory {
+
+ private boolean transactional;
+ private boolean clustered;
+ private DataSource dataSource;
+ private IdGenerator idGenerator = new IdGenerator();
+ private Map<String, JdbcStore> stores = new HashMap<String, JdbcStore>();
+ private String tableName = "SM_STORE";
+ private boolean createDataBase = true;
+ private JDBCAdapter adapter;
+ private Statements statements;
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.store.ExchangeStoreFactory#get(java.lang.String)
+ */
+ public synchronized Store open(String name) throws IOException {
+ if (adapter == null) {
+ Connection connection = null;
+ try {
+ connection = getDataSource().getConnection();
+ adapter = JDBCAdapterFactory.getAdapter(connection);
+ if (statements == null) {
+ statements = new Statements();
+ statements.setStoreTableName(tableName);
+ }
+ adapter.setStatements(statements);
+ if (createDataBase) {
+ adapter.doCreateTables(connection);
+ }
+ connection.commit();
+ } catch (SQLException e) {
+ throw (IOException) new IOException("Exception while creating database").initCause(e);
+ } finally {
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ // Do nothing
+ }
+ }
+ }
+ }
+ JdbcStore store = stores.get(name);
+ if (store == null) {
+ store = new JdbcStore(this, name);
+ stores.put(name, store);
+ }
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.store.ExchangeStoreFactory#release(org.apache.servicemix.store.ExchangeStore)
+ */
+ public synchronized void close(Store store) throws IOException {
+ stores.remove(store);
+ }
+
+ /**
+ * @return Returns the adapter.
+ */
+ public JDBCAdapter getAdapter() {
+ return adapter;
+ }
+
+ /**
+ * @return Returns the dataSource.
+ */
+ public DataSource getDataSource() {
+ return dataSource;
+ }
+
+ /**
+ * @param dataSource The dataSource to set.
+ */
+ public void setDataSource(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ /**
+ * @return Returns the clustered.
+ */
+ public boolean isClustered() {
+ return clustered;
+ }
+
+ /**
+ * @param clustered The clustered to set.
+ */
+ public void setClustered(boolean clustered) {
+ this.clustered = clustered;
+ }
+
+ /**
+ * @return Returns the transactional.
+ */
+ public boolean isTransactional() {
+ return transactional;
+ }
+
+ /**
+ * @param transactional The transactional to set.
+ */
+ public void setTransactional(boolean transactional) {
+ this.transactional = transactional;
+ }
+
+ /**
+ * @return Returns the idGenerator.
+ */
+ public IdGenerator getIdGenerator() {
+ return idGenerator;
+ }
+
+ /**
+ * @param idGenerator The idGenerator to set.
+ */
+ public void setIdGenerator(IdGenerator idGenerator) {
+ this.idGenerator = idGenerator;
+ }
+
+ /**
+ * @return Returns the tableName.
+ */
+ public String getTableName() {
+ return tableName;
+ }
+
+ /**
+ * @param tableName The tableName to set.
+ */
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ /**
+ * @return Returns the createDataBase.
+ */
+ public boolean isCreateDataBase() {
+ return createDataBase;
+ }
+
+ /**
+ * @param createDataBase The createDataBase to set.
+ */
+ public void setCreateDataBase(boolean createDataBase) {
+ this.createDataBase = createDataBase;
+ }
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java Mon Aug 25 06:31:20 2008
@@ -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.store.memory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.id.IdGenerator;
+import org.apache.servicemix.store.Store;
+
+/**
+ * A simple memory store implementation based on a simple map.
+ * This store is neither clusterable, nor persistent, nor transactional.
+ *
+ * @author gnodet
+ */
+public class MemoryStore implements Store {
+
+ private static final Log LOG = LogFactory.getLog(MemoryStore.class);
+
+ private Map<String, Object> datas = new ConcurrentHashMap<String, Object>();
+
+ private IdGenerator idGenerator;
+
+ public MemoryStore(IdGenerator idGenerator) {
+ this.idGenerator = idGenerator;
+ }
+
+ public boolean hasFeature(String name) {
+ return false;
+ }
+
+ public void store(String id, Object data) throws IOException {
+ LOG.debug("Storing object with id: " + id);
+ datas.put(id, data);
+ }
+
+ public String store(Object data) throws IOException {
+ String id = idGenerator.generateId();
+ store(id, data);
+ return id;
+ }
+
+ public Object load(String id) throws IOException {
+ LOG.debug("Loading object with id: " + id);
+ return datas.remove(id);
+ }
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,65 @@
+/*
+ * 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.store.memory;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.servicemix.id.IdGenerator;
+import org.apache.servicemix.store.Store;
+import org.apache.servicemix.store.StoreFactory;
+
+/**
+ * {@link StoreFactory} for creating memory-based {@link Store} implementations
+ *
+ * If a timeout has been specified, a {@link TimeoutMemoryStore} will be created,
+ * otherwise the factory will build a plain {@link MemoryStore}
+ */
+public class MemoryStoreFactory implements StoreFactory {
+
+ private IdGenerator idGenerator = new IdGenerator();
+ private Map<String, MemoryStore> stores = new HashMap<String, MemoryStore>();
+ private long timeout = -1;
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.store.ExchangeStoreFactory#get(java.lang.String)
+ */
+ public synchronized Store open(String name) throws IOException {
+ MemoryStore store = stores.get(name);
+ if (store == null) {
+ if (timeout <= 0) {
+ store = new MemoryStore(idGenerator);
+ } else {
+ store = new TimeoutMemoryStore(idGenerator, timeout);
+ }
+ stores.put(name, store);
+ }
+ return store;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.servicemix.store.ExchangeStoreFactory#release(org.apache.servicemix.store.ExchangeStore)
+ */
+ public synchronized void close(Store store) throws IOException {
+ stores.remove(store);
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/Timer.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/Timer.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/Timer.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/Timer.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,25 @@
+/*
+ * 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.timers;
+
+public interface Timer {
+
+ boolean cancel();
+
+ TimerListener getTimerListener();
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerListener.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerListener.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerListener.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerListener.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,23 @@
+/*
+ * 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.timers;
+
+public interface TimerListener {
+
+ void timerExpired(Timer timer);
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerManager.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerManager.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerManager.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/TimerManager.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,31 @@
+/*
+ * 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.timers;
+
+import java.util.Date;
+
+public interface TimerManager {
+
+ Timer schedule(TimerListener listener, long delay);
+
+ Timer schedule(TimerListener listener, Date date);
+
+ void start();
+
+ void stop();
+
+}
Added: servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java (added)
+++ servicemix/utils/trunk/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,88 @@
+/*
+ * 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.timers.impl;
+
+import java.util.Date;
+import java.util.TimerTask;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.timers.Timer;
+import org.apache.servicemix.timers.TimerListener;
+import org.apache.servicemix.timers.TimerManager;
+
+public class TimerManagerImpl implements TimerManager {
+
+ private static final Log LOG = LogFactory.getLog(TimerManagerImpl.class);
+
+ private java.util.Timer timer;
+
+ public Timer schedule(TimerListener listener, long delay) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Schedule timer " + listener + " for " + delay);
+ }
+ TimerImpl tt = new TimerImpl(listener);
+ timer.schedule(tt, delay);
+ return tt;
+ }
+
+ public Timer schedule(TimerListener listener, Date date) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Schedule timer " + listener + " at " + date);
+ }
+ TimerImpl tt = new TimerImpl(listener);
+ timer.schedule(tt, date);
+ return tt;
+ }
+
+ public void start() {
+ timer = new java.util.Timer();
+ }
+
+ public void stop() {
+ timer.cancel();
+ }
+
+ protected static class TimerImpl extends TimerTask implements Timer {
+
+ private TimerListener timerListener;
+
+ public TimerImpl(TimerListener timerListener) {
+ this.timerListener = timerListener;
+ }
+
+ public boolean cancel() {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Timer " + timerListener + " cancelled");
+ }
+ return super.cancel();
+ }
+
+ public TimerListener getTimerListener() {
+ return this.timerListener;
+ }
+
+ public void run() {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Timer " + timerListener + " expired");
+ }
+ this.timerListener.timerExpired(this);
+ }
+
+ }
+
+}
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/apache_derby_embedded_jdbc_driver
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/apache_derby_embedded_jdbc_driver?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/apache_derby_embedded_jdbc_driver (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/apache_derby_embedded_jdbc_driver Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.DefaultJDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/axion_jdbc_driver
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/axion_jdbc_driver?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/axion_jdbc_driver (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/axion_jdbc_driver Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.AxionJDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/hsql_database_engine_driver
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/hsql_database_engine_driver?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/hsql_database_engine_driver (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/hsql_database_engine_driver Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.HsqldbJDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/i-net_sprinta_2000
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/i-net_sprinta_2000?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/i-net_sprinta_2000 (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/i-net_sprinta_2000 Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.ImageBasedJDBCAdaptor
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_db2_jdbc_universal_driver_architecture
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_db2_jdbc_universal_driver_architecture?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_db2_jdbc_universal_driver_architecture (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_db2_jdbc_universal_driver_architecture Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.DB2JDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_informix_jdbc_driver_for_ibm_informix_dynamic_server
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_informix_jdbc_driver_for_ibm_informix_dynamic_server?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_informix_jdbc_driver_for_ibm_informix_dynamic_server (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_informix_jdbc_driver_for_ibm_informix_dynamic_server Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.InformixJDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jconnect__tm__for_jdbc__tm_
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jconnect__tm__for_jdbc__tm_?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jconnect__tm__for_jdbc__tm_ (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jconnect__tm__for_jdbc__tm_ Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.ImageBasedJDBCAdaptor
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jtds_type_4_jdbc_driver_for_ms_sql_server_and_sybase
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jtds_type_4_jdbc_driver_for_ms_sql_server_and_sybase?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jtds_type_4_jdbc_driver_for_ms_sql_server_and_sybase (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jtds_type_4_jdbc_driver_for_ms_sql_server_and_sybase Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.ImageBasedJDBCAdaptor
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/mysql-ab_jdbc_driver
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/mysql-ab_jdbc_driver?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/mysql-ab_jdbc_driver (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/mysql-ab_jdbc_driver Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.DefaultJDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/oracle_jdbc_driver
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/oracle_jdbc_driver?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/oracle_jdbc_driver (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/oracle_jdbc_driver Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.OracleJDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/postgresql_native_driver
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/postgresql_native_driver?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/postgresql_native_driver (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/postgresql_native_driver Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.PostgresqlJDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sap_db
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sap_db?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sap_db (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sap_db Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.MaxDBJDBCAdapter
Added: servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sqlserver
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sqlserver?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sqlserver (added)
+++ servicemix/utils/trunk/src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sqlserver Mon Aug 25 06:31:20 2008
@@ -0,0 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+#
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+class=org.apache.servicemix.jdbc.adapter.ImageBasedJDBCAdaptor
Added: servicemix/utils/trunk/src/test/java/org/apache/servicemix/locks/impl/SimpleLockTest.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/test/java/org/apache/servicemix/locks/impl/SimpleLockTest.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/test/java/org/apache/servicemix/locks/impl/SimpleLockTest.java (added)
+++ servicemix/utils/trunk/src/test/java/org/apache/servicemix/locks/impl/SimpleLockTest.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,35 @@
+/*
+ * 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.locks.impl;
+
+import java.util.concurrent.locks.Lock;
+
+import junit.framework.TestCase;
+
+public class SimpleLockTest extends TestCase {
+
+ public void testSimple() {
+ Lock l = new SimpleLock();
+
+ assertTrue(l.tryLock());
+ assertFalse(l.tryLock());
+ l.unlock();
+ l.lock();
+ l.unlock();
+ }
+
+}
Added: servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTest.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTest.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTest.java (added)
+++ servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTest.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,59 @@
+/*
+ * 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.store.jdbc;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.store.Store;
+import org.apache.servicemix.store.StoreFactory;
+import org.hsqldb.jdbc.jdbcDataSource;
+
+public class JdbcStoreTest extends TestCase {
+
+ private DataSource dataSource;
+ private Connection connection;
+ private StoreFactory factory;
+
+ protected void setUp() throws Exception {
+ jdbcDataSource ds = new jdbcDataSource();
+ ds.setDatabase("jdbc:hsqldb:mem:aname");
+ ds.setUser("sa");
+ dataSource = ds;
+ connection = dataSource.getConnection();
+ JdbcStoreFactory f = new JdbcStoreFactory();
+ f.setDataSource(dataSource);
+ factory = f;
+ }
+
+ protected void tearDown() throws Exception {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+
+ public void testStoreLoad() throws Exception {
+ Store store = factory.open("store");
+ String id = store.store(new Integer(10));
+ Integer i = (Integer) store.load(id);
+ assertEquals(10, i.intValue());
+ assertNull(store.load("a"));
+ }
+}
Added: servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTransactionalTest.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTransactionalTest.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTransactionalTest.java (added)
+++ servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTransactionalTest.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,136 @@
+/*
+ * 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.store.jdbc;
+
+import java.sql.Connection;
+
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.sql.DataSource;
+import javax.sql.XADataSource;
+
+import junit.framework.TestCase;
+
+import org.apache.derby.jdbc.EmbeddedXADataSource;
+import org.apache.servicemix.store.Store;
+import org.apache.servicemix.store.StoreFactory;
+import org.jencks.GeronimoPlatformTransactionManager;
+import org.jencks.factory.ConnectionManagerFactoryBean;
+import org.tranql.connector.AllExceptionsAreFatalSorter;
+import org.tranql.connector.jdbc.AbstractXADataSourceMCF;
+
+public class JdbcStoreTransactionalTest extends TestCase {
+
+ private DataSource dataSource;
+ private Connection connection;
+ private StoreFactory factory;
+ private GeronimoPlatformTransactionManager tm;
+
+ protected void setUp() throws Exception {
+ tm = new GeronimoPlatformTransactionManager();
+
+ // Create an embedded database for testing tx results when commit / rollback
+ ConnectionManagerFactoryBean cmFactory = new ConnectionManagerFactoryBean();
+ cmFactory.setTransactionManager(tm);
+ cmFactory.setTransaction("xa");
+ cmFactory.afterPropertiesSet();
+ ConnectionManager cm = (ConnectionManager) cmFactory.getObject();
+ ManagedConnectionFactory mcf = new DerbyDataSourceMCF("target/testdb");
+ dataSource = (DataSource) mcf.createConnectionFactory(cm);
+ JdbcStoreFactory f = new JdbcStoreFactory();
+ f.setTransactional(true);
+ f.setDataSource(dataSource);
+ factory = f;
+ }
+
+ protected void tearDown() throws Exception {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+
+ public void testStoreAndLoad() throws Exception {
+ Store store = factory.open("store");
+ String id = store.store(new Integer(10));
+ Integer i = (Integer) store.load(id);
+ assertEquals(10, i.intValue());
+ assertNull(store.load(id));
+ assertNull(store.load("a"));
+ }
+
+ public void testStoreAndLoadInOneTx() throws Exception {
+ Store store = factory.open("store");
+ tm.begin();
+ String id = store.store(new Integer(10));
+ Integer i = (Integer) store.load(id);
+ assertEquals(10, i.intValue());
+ assertNull(store.load(id));
+ assertNull(store.load("a"));
+ tm.commit();
+ }
+
+ public void testStoreAndLoadInTwoTx() throws Exception {
+ Store store = factory.open("store");
+ tm.begin();
+ String id = store.store(new Integer(10));
+ tm.commit();
+ tm.begin();
+ Integer i = (Integer) store.load(id);
+ assertEquals(10, i.intValue());
+ assertNull(store.load(id));
+ tm.commit();
+ assertNull(store.load("a"));
+ }
+
+ public void testStoreRollbackAndLoad() throws Exception {
+ Store store = factory.open("store");
+ tm.begin();
+ String id = store.store(new Integer(10));
+ tm.rollback();
+ tm.begin();
+ assertNull(store.load(id));
+ tm.commit();
+ }
+
+ public void testStoreRollbackAndLoadNonTx() throws Exception {
+ Store store = factory.open("store");
+ tm.begin();
+ String id = store.store(new Integer(10));
+ tm.rollback();
+ assertNull(store.load(id));
+ }
+
+ public static class DerbyDataSourceMCF extends AbstractXADataSourceMCF {
+ private static final long serialVersionUID = 7971682207810098396L;
+ protected DerbyDataSourceMCF(String dbName) {
+ super(createXADS(dbName), new AllExceptionsAreFatalSorter());
+ }
+ public String getPassword() {
+ return null;
+ }
+ public String getUserName() {
+ return null;
+ }
+ protected static XADataSource createXADS(String dbName) {
+ EmbeddedXADataSource xads = new EmbeddedXADataSource();
+ xads.setDatabaseName(dbName);
+ xads.setCreateDatabase("create");
+ return xads;
+ }
+ }
+
+}
Added: servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/MemoryStoreFactoryTest.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/MemoryStoreFactoryTest.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/MemoryStoreFactoryTest.java (added)
+++ servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/MemoryStoreFactoryTest.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.store.memory;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for {@link MemoryStoreFactory}
+ */
+public class MemoryStoreFactoryTest extends TestCase {
+
+ private MemoryStoreFactory factory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ factory = new MemoryStoreFactory();
+ }
+
+ public void testOpen() throws Exception {
+ assertTrue(factory.open("store1") instanceof MemoryStore);
+ factory.setTimeout(500);
+ assertTrue(factory.open("store1") instanceof MemoryStore);
+ assertTrue(factory.open("store2") instanceof TimeoutMemoryStore);
+ }
+
+}
Added: servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/TimeoutMemoryStoreTest.java
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/TimeoutMemoryStoreTest.java?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/TimeoutMemoryStoreTest.java (added)
+++ servicemix/utils/trunk/src/test/java/org/apache/servicemix/store/memory/TimeoutMemoryStoreTest.java Mon Aug 25 06:31:20 2008
@@ -0,0 +1,62 @@
+/*
+ * 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.store.memory;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.store.Store;
+
+/**
+ * Test case for {@link TimeoutMemoryStore}
+ */
+public class TimeoutMemoryStoreTest extends TestCase {
+
+ private static final long TIMEOUT = 250L;
+
+ private Store store;
+ private final MemoryStoreFactory factory = new MemoryStoreFactory();
+
+ public TimeoutMemoryStoreTest() {
+ super();
+ factory.setTimeout(TIMEOUT);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ store = factory.open("test");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ factory.close(store);
+ }
+
+ public void testTimeout() throws Exception {
+ String id = store.store("Any kind of data...");
+ Object data = store.load(id);
+ assertNotNull(data);
+ //now store it again and load it after the timeout
+ store.store(id, data);
+ synchronized (this) {
+ wait(TIMEOUT * 2);
+ }
+ assertNull("Data should have been removed from store after timeout", store.load(id));
+ }
+
+}
Added: servicemix/utils/trunk/src/test/resources/log4j-tests.properties
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/test/resources/log4j-tests.properties?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/test/resources/log4j-tests.properties (added)
+++ servicemix/utils/trunk/src/test/resources/log4j-tests.properties Mon Aug 25 06:31:20 2008
@@ -0,0 +1,42 @@
+#
+# 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.
+#
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, out
+
+log4j.logger.org.springframework=INFO
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
Added: servicemix/utils/trunk/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/servicemix/utils/trunk/src/test/resources/log4j.properties?rev=688722&view=auto
==============================================================================
--- servicemix/utils/trunk/src/test/resources/log4j.properties (added)
+++ servicemix/utils/trunk/src/test/resources/log4j.properties Mon Aug 25 06:31:20 2008
@@ -0,0 +1,42 @@
+#
+# 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.
+#
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, stdout
+
+log4j.logger.org.springframework=INFO
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true