Author: ruschein
Date: 2011-05-24 13:10:14 -0700 (Tue, 24 May 2011)
New Revision: 25515

Modified:
   
core3/event-impl/trunk/impl/src/main/java/org/cytoscape/event/internal/CyListenerAdapter.java
Log:
Improved error reporting.

Modified: 
core3/event-impl/trunk/impl/src/main/java/org/cytoscape/event/internal/CyListenerAdapter.java
===================================================================
--- 
core3/event-impl/trunk/impl/src/main/java/org/cytoscape/event/internal/CyListenerAdapter.java
       2011-05-24 19:31:23 UTC (rev 25514)
+++ 
core3/event-impl/trunk/impl/src/main/java/org/cytoscape/event/internal/CyListenerAdapter.java
       2011-05-24 20:10:14 UTC (rev 25515)
@@ -1,13 +1,6 @@
 /*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
+ Copyright (c) 2011, The Cytoscape Consortium (www.cytoscape.org)
 
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
  This library is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as published
  by the Free Software Foundation; either version 2.1 of the License, or
@@ -34,6 +27,7 @@
 */
 package org.cytoscape.event.internal;
 
+
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.HashMap;
@@ -55,7 +49,6 @@
  * Some static utility methods that help you fire events.
  */
 public class CyListenerAdapter {
-       
        private static final Logger logger = 
LoggerFactory.getLogger(CyListenerAdapter.class);
        private static final Executor EXEC = Executors.newCachedThreadPool();
        private static final ServiceComparator serviceComparator = new 
ServiceComparator(); 
@@ -94,26 +87,28 @@
                        return;
                } 
 
+               Object lastListener = null;
                try {
                        final Method method = 
listenerClass.getMethod("handleEvent", event.getClass());
 
                        for (final Object listener : listeners) {
+                               lastListener = listener;
                                //System.out.println("event: " + 
event.getClass().getName() + "  listener: " + listener.getClass().getName());
                                method.invoke(listenerClass.cast(listener), 
event);
                        }
                } catch (NoSuchMethodException e) {
                        logger.error("Listener doesn't implement 
\"handleEvent\" method: "
-                                          + listenerClass.getName(), e);
+                                    + listenerClass.getName(), e);
                } catch (InvocationTargetException e) {
-                       logger.error("Listener threw exception as part of 
\"handleEvent\" invocation: "
-                                          + listenerClass.getName(), e);
+                       logger.error("Listener \"" + 
lastListener.getClass().getName()
+                                    + "\" threw exception as part of 
\"handleEvent\" invocation: "
+                                    + listenerClass.getName(), e);
                } catch (IllegalAccessException e) {
                        logger.error("Listener can't execute \"handleEvent\" 
method: "
-                                          + listenerClass.getName(), e);
+                                    + listenerClass.getName(), e);
                }
        }
 
-
        /**
         * Calls each listener found in the Service Registry identified by the 
listenerClass
         * and filter with the supplied event in a new thread.<p>This method 
should <b>ONLY</b>

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to