You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/06/25 21:45:53 UTC
svn commit: r550587 - in
/incubator/servicemix/trunk/core/servicemix-services: ./
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/se...
Author: gnodet
Date: Mon Jun 25 12:45:51 2007
New Revision: 550587
URL: http://svn.apache.org/viewvc?view=rev&rev=550587
Log:
Fix checkstyle / pmd checks
Modified:
incubator/servicemix/trunk/core/servicemix-services/pom.xml
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/Executor.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/finder/FactoryFinder.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/id/IdGenerator.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/Statements.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/LockManager.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/Store.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/StoreFactory.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java
incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java
Modified: incubator/servicemix/trunk/core/servicemix-services/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/pom.xml?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/pom.xml (original)
+++ incubator/servicemix/trunk/core/servicemix-services/pom.xml Mon Jun 25 12:45:51 2007
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.servicemix</groupId>
- <artifactId>core</artifactId>
+ <artifactId>parent</artifactId>
<version>3.2-incubating-SNAPSHOT</version>
</parent>
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/Executor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/Executor.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/Executor.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/Executor.java Mon Jun 25 12:45:51 2007
@@ -29,24 +29,24 @@
*
* @param command the command to execute
*/
- public void execute(Runnable command);
+ void execute(Runnable command);
/**
* Shutdown this executor.
* This must be called to kill all threads.
*/
- public void shutdown();
+ void shutdown();
/**
* The capacity of the underlying queue (if any)
* @return
*/
- public int capacity();
+ int capacity();
/**
* The current size of the underlying queue (if any)
* @return
*/
- public int size();
+ int size();
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/ExecutorFactory.java Mon Jun 25 12:45:51 2007
@@ -31,6 +31,6 @@
* @param id the id of the executor to create
* @return a configured Executor
*/
- public Executor createExecutor(String id);
+ Executor createExecutor(String id);
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorConfig.java Mon Jun 25 12:45:51 2007
@@ -17,117 +17,146 @@
package org.apache.servicemix.executors.impl;
/**
- * This bean holds configuration attributes for a given
- * Executor.
+ * 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 = false;
+
+ 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
+ * @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
+ * @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
+ * @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
+ * @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
+ * @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
+ * @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
+ * @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
+ * @param allowCoreThreadsTimeout
+ * the allowCoreThreadsTimeout to set
*/
public void setAllowCoreThreadsTimeout(boolean allowCoreThreadsTimeout) {
this.allowCoreThreadsTimeout = allowCoreThreadsTimeout;
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorFactoryImpl.java Mon Jun 25 12:45:51 2007
@@ -19,10 +19,6 @@
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
-
-import org.apache.servicemix.executors.Executor;
-import org.apache.servicemix.executors.ExecutorFactory;
-
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
@@ -33,6 +29,9 @@
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.
*
@@ -51,14 +50,14 @@
public class ExecutorFactoryImpl implements ExecutorFactory {
private ExecutorConfig defaultConfig = new ExecutorConfig();
- private Map<String,ExecutorConfig> configs = new HashMap<String, 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());
+ return new ExecutorImpl(createService(id, config), config.getShutdownDelay());
}
-
+
protected ExecutorConfig getConfig(String id) {
ExecutorConfig config = null;
if (configs != null) {
@@ -73,7 +72,7 @@
}
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");
@@ -86,23 +85,17 @@
} else {
queue = new ArrayBlockingQueue<Runnable>(config.getQueueSize());
}
- ThreadFactory factory = new DefaultThreadFactory(id,
- config.isThreadDaemon(),
- config.getThreadPriority());
+ 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);
+ 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 });
+ Method mth = service.getClass().getMethod("allowCoreThreadTimeOut", new Class[] {boolean.class });
+ mth.invoke(service, new Object[] {Boolean.TRUE });
} catch (Throwable t) {
+ // Do nothing
}
}
return service;
@@ -113,30 +106,31 @@
*/
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-";
+ 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)
+ Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
+ if (t.isDaemon() != daemon) {
t.setDaemon(daemon);
- if (t.getPriority() != priority)
+ }
+ if (t.getPriority() != priority) {
t.setPriority(priority);
+ }
return t;
}
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/executors/impl/ExecutorImpl.java Mon Jun 25 12:45:51 2007
@@ -16,12 +16,12 @@
*/
package org.apache.servicemix.executors.impl;
-import org.apache.servicemix.executors.Executor;
-
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.
@@ -31,8 +31,9 @@
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;
@@ -52,6 +53,7 @@
threadPool.shutdownNow();
}
} catch (InterruptedException e) {
+ // Do nothing
}
}
}).start();
@@ -67,5 +69,5 @@
BlockingQueue queue = threadPool.getQueue();
return queue.size();
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/finder/FactoryFinder.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/finder/FactoryFinder.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/finder/FactoryFinder.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/finder/FactoryFinder.java Mon Jun 25 12:45:51 2007
@@ -24,10 +24,10 @@
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) {
@@ -41,18 +41,16 @@
* containing the factory name
* @return a newly created instance
*/
- public Object newInstance(String key)
- throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
- {
+ 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)
+ 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);
@@ -100,6 +98,7 @@
try {
reader.close();
} catch (Exception e) {
+ // Do nothing
}
}
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/id/IdGenerator.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/id/IdGenerator.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/id/IdGenerator.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/id/IdGenerator.java Mon Jun 25 12:45:51 2007
@@ -17,10 +17,10 @@
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
+ * 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;
@@ -31,83 +31,90 @@
* Generator for Globally unique Strings.
*/
-public class IdGenerator{
+public class IdGenerator {
+
+ private static final Log LOG = LogFactory.getLog(IdGenerator.class);
+
+ private static final String UNIQUE_STUB;
+
+ private static int instanceCount;
- 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;
-
- 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;
- }
+
+ 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
+ * 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(){
+
+ public static String getHostName() {
return hostName;
}
-
- /**
- * Construct an IdGenerator
- *
- */
-
- public IdGenerator(String prefix){
- synchronized(UNIQUE_STUB){
- this.seed = prefix + UNIQUE_STUB +(instanceCount++) +":";
- }
- }
-
- public IdGenerator(){
- this("ID:");
+
+ /**
+ * Generate a unqiue id
+ *
+ * @return a unique id
+ */
+
+ public synchronized String generateId() {
+ return this.seed + (this.sequence++);
}
-
- /**
- * 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(){
+ public String generateSanitizedId() {
String result = generateId();
result = result.replace(':', '-');
result = result.replace('_', '-');
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.java Mon Jun 25 12:45:51 2007
@@ -22,30 +22,30 @@
public interface JDBCAdapter {
- public void doCreateTables(Connection connection) throws SQLException, IOException;
+ void doCreateTables(Connection connection) throws SQLException, IOException;
- public void doDropTables(Connection connection) throws SQLException, IOException;
+ void doDropTables(Connection connection) throws SQLException, IOException;
- public byte[] doLoadData(Connection connection, String id) throws SQLException, IOException;
+ byte[] doLoadData(Connection connection, String id) throws SQLException, IOException;
- public byte[][] doLoadData(Connection connection, String[] ids) throws SQLException, IOException;
+ byte[][] doLoadData(Connection connection, String[] ids) throws SQLException, IOException;
- public void doStoreData(Connection connection, String id, byte[] data) throws SQLException, IOException;
+ void doStoreData(Connection connection, String id, byte[] data) throws SQLException, IOException;
- public void doUpdateData(Connection connection, String id, byte[] data) throws SQLException, IOException;
+ void doUpdateData(Connection connection, String id, byte[] data) throws SQLException, IOException;
- public void doRemoveData(Connection connection, String id) throws SQLException, IOException;
+ void doRemoveData(Connection connection, String id) throws SQLException, IOException;
- public void doRemoveData(Connection connection, String[] ids) throws SQLException, IOException;
+ void doRemoveData(Connection connection, String[] ids) throws SQLException, IOException;
- public int doGetCount(Connection connection) throws SQLException, IOException;
+ int doGetCount(Connection connection) throws SQLException, IOException;
- public String[] doGetIds(Connection connection) throws SQLException, IOException;
+ String[] doGetIds(Connection connection) throws SQLException, IOException;
- public String[] doGetIds(Connection connection, int fromIndex, int toIndex) throws SQLException, IOException;
+ String[] doGetIds(Connection connection, int fromIndex, int toIndex) throws SQLException, IOException;
- public Statements getStatements();
+ Statements getStatements();
- public void setStatements(Statements statements);
+ void setStatements(Statements statements);
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/JDBCAdapterFactory.java Mon Jun 25 12:45:51 2007
@@ -24,11 +24,14 @@
import org.apache.servicemix.finder.FactoryFinder;
import org.apache.servicemix.jdbc.adapter.DefaultJDBCAdapter;
-public class JDBCAdapterFactory {
+public final class JDBCAdapterFactory {
- private static final Log log = LogFactory.getLog(JDBCAdapterFactory.class);
+ 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 {
@@ -39,14 +42,14 @@
try {
adapter = (JDBCAdapter) factoryFinder.newInstance(driverName);
- log.info("Database driver recognized: [" + driverName + "]");
+ LOG.info("Database driver recognized: [" + driverName + "]");
} catch (Throwable e) {
- log.warn("Database driver NOT recognized: [" + driverName
+ 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: "
+ LOG.warn("JDBC error occurred while trying to detect database type. Will use default JDBC implementation: "
+ e.getMessage());
log("Failure details: ", e);
}
@@ -61,15 +64,13 @@
}
public static void log(String msg, SQLException e) {
- if (log.isDebugEnabled()) {
- if (log.isDebugEnabled()) {
- String s = msg + e.getMessage();
- while (e.getNextException() != null) {
- e = e.getNextException();
- s += ", due to: " + e.getMessage();
- }
- log.debug(s, 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);
}
}
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/Statements.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/Statements.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/Statements.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/Statements.java Mon Jun 25 12:45:51 2007
@@ -24,11 +24,10 @@
*/
public class Statements {
- private String tablePrefix = "";
protected String storeTableName = "SM_STORE";
-
protected String binaryDataType = "BLOB";
protected String idDataType = "VARCHAR(48)";
+ private String tablePrefix = "";
private String storeDataStatement;
private String updateDataStatement;
private String removeDataStatement;
@@ -42,7 +41,7 @@
public String[] getCreateSchemaStatements() {
if (createSchemaStatements == null) {
createSchemaStatements = new String[] {
- "CREATE TABLE " + getFullStoreTableName() + "(" + "ID " + idDataType + " NOT NULL"
+ "CREATE TABLE " + getFullStoreTableName() + "(" + "ID " + idDataType + " NOT NULL"
+ ", DATA " + binaryDataType
+ ", PRIMARY KEY ( ID ) )",
};
@@ -53,7 +52,7 @@
public String[] getDropSchemaStatements() {
if (dropSchemaStatements == null) {
dropSchemaStatements = new String[] {
- "DROP TABLE " + getFullStoreTableName() + "",
+ "DROP TABLE " + getFullStoreTableName() + "",
};
}
return dropSchemaStatements;
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.java Mon Jun 25 12:45:51 2007
@@ -32,19 +32,18 @@
*/
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);
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/DefaultJDBCAdapter.java Mon Jun 25 12:45:51 2007
@@ -32,28 +32,23 @@
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:
+ * 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);
+ private static final Log LOG = LogFactory.getLog(DefaultJDBCAdapter.class);
protected Statements statements;
@@ -68,49 +63,52 @@
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
+ // 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;
+ ResultSet rs = null;
try {
- rs= connection.getMetaData().getTables(null,null, statements.getFullStoreTableName(), new String[] {"TABLE"});
- alreadyExists = rs.next();
+ 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
+
+ // 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]);
+ 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() );
+ } 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() );
+ 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 {
+ } finally {
close(s);
}
}
@@ -125,16 +123,14 @@
// 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() );
+ } 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 {
+ } finally {
close(s);
}
}
@@ -147,14 +143,14 @@
}
s.setString(1, id);
setBinaryData(s, 2, data);
- if ( s.executeUpdate() != 1 ) {
+ 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;
@@ -166,29 +162,28 @@
return null;
}
return getBinaryData(rs, 1);
- }
- finally {
+ } finally {
close(rs);
close(s);
}
}
-
+
public void doUpdateData(Connection connection, String id, byte[] data) throws SQLException, IOException {
PreparedStatement s = null;
try {
- if( s == null ) {
+ if (s == null) {
s = connection.prepareStatement(statements.getUpdateDataStatement());
}
s.setString(2, id);
setBinaryData(s, 1, data);
- if ( s.executeUpdate() != 1 ) {
+ 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 {
@@ -199,24 +194,26 @@
}
} finally {
close(s);
- }
+ }
}
-
- static private void close(Statement s) {
+
+ private static void close(Statement s) {
try {
if (s != null) {
s.close();
}
} catch (Throwable e) {
+ // Do nothing
}
}
- static private void close(ResultSet rs) {
+ private static void close(ResultSet rs) {
try {
if (rs != null) {
rs.close();
}
} catch (Throwable e) {
+ // Do nothing
}
}
@@ -242,8 +239,7 @@
close(rs);
}
return datas;
- }
- finally {
+ } finally {
close(s);
}
}
@@ -256,8 +252,7 @@
s.setString(1, ids[i]);
s.executeUpdate();
}
- }
- finally {
+ } finally {
close(s);
}
}
@@ -270,8 +265,7 @@
rs = s.executeQuery();
rs.next();
return rs.getInt(1);
- }
- finally {
+ } finally {
close(rs);
close(s);
}
@@ -288,8 +282,7 @@
ids.add(rs.getString(1));
}
return ids.toArray(new String[ids.size()]);
- }
- finally {
+ } finally {
close(rs);
close(s);
}
@@ -311,8 +304,7 @@
}
}
return ids;
- }
- finally {
+ } finally {
close(rs);
close(s);
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.java Mon Jun 25 12:45:51 2007
@@ -23,10 +23,10 @@
* @version $Revision: 1.2 $
*/
public class HsqldbJDBCAdapter extends BytesJDBCAdapter {
-
+
public void setStatements(Statements statements) {
statements.setBinaryDataType("OTHER");
super.setStatements(statements);
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.java Mon Jun 25 12:45:51 2007
@@ -38,34 +38,33 @@
* @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;
- while ((ch = is.read()) >= 0) {
+ 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);
+ 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);
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/LockManager.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/LockManager.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/LockManager.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/LockManager.java Mon Jun 25 12:45:51 2007
@@ -20,6 +20,6 @@
public interface LockManager {
- public Lock getLock(String id);
+ Lock getLock(String id);
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.java Mon Jun 25 12:45:51 2007
@@ -16,17 +16,17 @@
*/
package org.apache.servicemix.locks.impl;
-import org.apache.servicemix.locks.LockManager;
-
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import org.apache.servicemix.locks.LockManager;
+
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) {
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/Store.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/Store.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/Store.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/Store.java Mon Jun 25 12:45:51 2007
@@ -41,7 +41,7 @@
* @param name the feature to check
* @return <code>true</code> if the feature is supported
*/
- public boolean hasFeature(String name);
+ boolean hasFeature(String name);
/**
* Put an object in the store under the given id.
@@ -52,7 +52,7 @@
* @param data the object to store
* @throws IOException if an error occurs
*/
- public void store(String id, Object data) throws IOException;
+ void store(String id, Object data) throws IOException;
/**
* Put an object into the store and return the unique id that
@@ -62,7 +62,7 @@
* @return the id of the object stored
* @throws IOException if an error occurs
*/
- public String store(Object data) throws IOException;
+ String store(Object data) throws IOException;
/**
* Loads an object that has been previously stored under the specified key.
@@ -72,6 +72,6 @@
* @return the object, or <code>null></code> if the object could not be found
* @throws IOException if an error occurs
*/
- public Object load(String id) throws IOException;
+ Object load(String id) throws IOException;
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/StoreFactory.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/StoreFactory.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/StoreFactory.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/StoreFactory.java Mon Jun 25 12:45:51 2007
@@ -20,8 +20,8 @@
public interface StoreFactory {
- public Store open(String name) throws IOException;
+ Store open(String name) throws IOException;
- public void close(Store store) throws IOException;
+ void close(Store store) throws IOException;
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStore.java Mon Jun 25 12:45:51 2007
@@ -29,7 +29,7 @@
public class JdbcStore implements Store {
- private static final Log log = LogFactory.getLog(JdbcStore.class);
+ private static final Log LOG = LogFactory.getLog(JdbcStore.class);
private JdbcStoreFactory factory;
private String name;
@@ -39,14 +39,14 @@
this.name = name;
}
- public boolean hasFeature(String name) {
- return PERSISTENT.equals(name) ||
- (CLUSTERED.equals(name) && factory.isClustered()) ||
- (TRANSACTIONAL.equals(name) && factory.isTransactional());
+ 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);
+ LOG.debug("Storing object with id: " + id);
Connection connection = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
@@ -69,7 +69,7 @@
}
public Object load(String id) throws IOException {
- log.debug("Loading object with id: " + id);
+ LOG.debug("Loading object with id: " + id);
Connection connection = null;
try {
connection = factory.getDataSource().getConnection();
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/jdbc/JdbcStoreFactory.java Mon Jun 25 12:45:51 2007
@@ -68,6 +68,7 @@
try {
connection.close();
} catch (Exception e) {
+ // Do nothing
}
}
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/store/memory/MemoryStore.java Mon Jun 25 12:45:51 2007
@@ -18,14 +18,13 @@
import java.io.IOException;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
-import org.apache.servicemix.id.IdGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.id.IdGenerator;
import org.apache.servicemix.store.Store;
-import java.util.concurrent.ConcurrentHashMap;
-
/**
* A simple memory store implementation based on a simple map.
* This store is neither clusterable, nor persistent, nor transactional.
@@ -33,25 +32,26 @@
* @author gnodet
*/
public class MemoryStore implements Store {
-
- private static final Log log = LogFactory.getLog(MemoryStore.class);
+
+ 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);
+ 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);
@@ -59,8 +59,8 @@
}
public Object load(String id) throws IOException {
- log.debug("Loading object with id: " + id);
+ LOG.debug("Loading object with id: " + id);
return datas.remove(id);
}
-
+
}
Modified: incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java?view=diff&rev=550587&r1=550586&r2=550587
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java (original)
+++ incubator/servicemix/trunk/core/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java Mon Jun 25 12:45:51 2007
@@ -27,12 +27,13 @@
public class TimerManagerImpl implements TimerManager {
- private static final Log log = LogFactory.getLog(TimerManagerImpl.class);
+ 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);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Schedule timer " + listener + " for " + delay);
}
TimerImpl tt = new TimerImpl(listener);
timer.schedule(tt, delay);
@@ -40,48 +41,48 @@
}
public Timer schedule(TimerListener listener, Date date) {
- if (log.isDebugEnabled()) {
- log.debug("Schedule timer " + listener + " at " + 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");
+ 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");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Timer " + timerListener + " expired");
}
this.timerListener.timerExpired(this);
}
-
+
}
}