[jboss-cvs] JBossCache/src/org/jboss/cache/notifications ...
Manik Surtani
manik at jboss.org
Tue Jul 3 06:56:14 EDT 2007
User: msurtani
Date: 07/07/03 06:56:14
Modified: src/org/jboss/cache/notifications Notifier.java
Log:
- Wrap exceptions encountered when invoking listener methods in a CacheException and re-throw
- Made listenerInvocations map package protected, for access by unit tests
Revision Changes Path
1.35 +13 -3 JBossCache/src/org/jboss/cache/notifications/Notifier.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Notifier.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/notifications/Notifier.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- Notifier.java 2 Jul 2007 10:49:03 -0000 1.34
+++ Notifier.java 3 Jul 2007 10:56:14 -0000 1.35
@@ -9,6 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
@@ -19,6 +20,7 @@
import org.jgroups.View;
import javax.transaction.Transaction;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collections;
@@ -52,7 +54,7 @@
CacheStartedEvent.class, CacheStoppedEvent.class, CacheBlockedEvent.class, CacheUnblockedEvent.class, NodeCreatedEvent.class, NodeRemovedEvent.class, NodeVisitedEvent.class, NodeModifiedEvent.class, NodeMovedEvent.class,
NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLoadedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class, ViewChangedEvent.class
};
- private final Map<Class, List<ListenerInvocation>> listenerInvocations = new ConcurrentHashMap<Class, List<ListenerInvocation>>();
+ final Map<Class, List<ListenerInvocation>> listenerInvocations = new ConcurrentHashMap<Class, List<ListenerInvocation>>();
public Notifier(Cache cache)
{
@@ -667,9 +669,17 @@
{
method.invoke(target, e);
}
- catch (Exception ite)
+ catch (InvocationTargetException e1)
{
- log.warn("Unable to invoke method " + method + " on Object instance " + target + " - removing this target object from list of listeners!", ite);
+ Throwable cause = e1.getCause();
+ if (cause != null)
+ throw new CacheException("Caught exception invoking method " + method + " on listener instance " + target, cause);
+ else
+ throw new CacheException("Caught exception invoking method " + method + " on listener instance " + target, e1);
+ }
+ catch (IllegalAccessException e1)
+ {
+ log.warn("Unable to invoke method " + method + " on Object instance " + target + " - removing this target object from list of listeners!", e1);
removeCacheListener(this.target);
}
}
More information about the jboss-cvs-commits
mailing list