activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r703172 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: store/jdbc/DefaultDatabaseLocker.java util/Handler.java
Date Thu, 09 Oct 2008 14:29:25 GMT
Author: chirino
Date: Thu Oct  9 07:29:25 2008
New Revision: 703172

URL: http://svn.apache.org/viewvc?rev=703172&view=rev
Log:
Impl for https://issues.apache.org/activemq/browse/AMQ-1972

Added:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/Handler.java
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java?rev=703172&r1=703171&r2=703172&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
Thu Oct  9 07:29:25 2008
@@ -23,6 +23,7 @@
 
 import javax.sql.DataSource;
 
+import org.apache.activemq.util.Handler;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -41,7 +42,8 @@
 
     private Connection connection;
     private boolean stopping;
-
+    private Handler<Exception> exceptionHandler;
+    
     public DefaultDatabaseLocker(JDBCPersistenceAdapter persistenceAdapter) throws IOException
{
         this(persistenceAdapter.getLockDataSource(), persistenceAdapter.getStatements());
     }
@@ -68,7 +70,20 @@
                 if (stopping) {
                     throw new Exception("Cannot start broker as being asked to shut down.
Interrupted attempt to acquire lock: " + e, e);
                 }
-                LOG.error("Failed to acquire lock: " + e, e);
+
+                if (exceptionHandler != null) {
+                    try {
+                        exceptionHandler.handle(e);
+                    } catch (Throwable handlerException) {
+                        LOG.error("The exception handler " + exceptionHandler.getClass().getCanonicalName()
+ " threw this exception: " + handlerException
+                                + " while trying to handle this excpetion: " + e, handlerException);
+                    }
+
+                } else {
+                    LOG.error("Failed to acquire lock: " + e, e);
+                }
+            } finally {
+
                 if (null != statement) {
                     try {
                         statement.close();
@@ -133,4 +148,13 @@
     public void setLockAcquireSleepInterval(long lockAcquireSleepInterval) {
         this.lockAcquireSleepInterval = lockAcquireSleepInterval;
     }
+    
+    public Handler getExceptionHandler() {
+		return exceptionHandler;
+	}
+
+	public void setExceptionHandler(Handler exceptionHandler) {
+		this.exceptionHandler = exceptionHandler;
+	}
+
 }

Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/Handler.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/Handler.java?rev=703172&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/Handler.java (added)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/Handler.java Thu Oct
 9 07:29:25 2008
@@ -0,0 +1,7 @@
+package org.apache.activemq.util;
+
+public interface Handler<T> {
+	
+	void handle(T e);
+
+}



Mime
View raw message