[jboss-cvs] JBossCache/src/org/jboss/cache/notifications ...

Brian Stansberry brian.stansberry at jboss.com
Wed Jul 4 22:36:34 EDT 2007


  User: bstansberry
  Date: 07/07/04 22:36:34

  Modified:    src/org/jboss/cache/notifications  Notifier.java
  Log:
  Exception should have a distinct message if listener class is not publicly accessible.
  
  Revision  Changes    Path
  1.37      +6 -9      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.36
  retrieving revision 1.37
  diff -u -b -r1.36 -r1.37
  --- Notifier.java	3 Jul 2007 11:57:48 -0000	1.36
  +++ Notifier.java	5 Jul 2007 02:36:34 -0000	1.37
  @@ -69,8 +69,10 @@
       */
      private void validateAndAddListenerInvocation(Object listener)
      {
  -      if (!isValidListenerClass(listener.getClass()))
  -         throw new IncorrectCacheListenerException("An Object must have the org.jboss.cache.notifications.annotation.CacheListener annotation to be considered a cache listener, and be publicly accesible!");
  +      if (!listener.getClass().isAnnotationPresent(CacheListener.class))
  +         throw new IncorrectCacheListenerException("An Object must have the org.jboss.cache.notifications.annotation.CacheListener annotation to be considered a cache listener, and must be publicly accessible!");
  +      if (!Modifier.isPublic(listener.getClass().getModifiers()))
  +         throw new IncorrectCacheListenerException("An Object's class must be publicly accessible to be considered a cache listener!");
   
         boolean foundMethods = false;
         // now try all methods on the listener for anything that we like.  Note that only PUBLIC methods are scanned.
  @@ -98,11 +100,6 @@
            log.warn("Attempted to register listener of class " + listener.getClass() + ", but no valid, public methods annotated with method-level event annotations found! Ignoring listener.");
      }
   
  -   private boolean isValidListenerClass(Class listenerClass)
  -   {
  -      return (listenerClass.isAnnotationPresent(CacheListener.class) && Modifier.isPublic(listenerClass.getModifiers()));
  -   }
  -
      private boolean isValidListenerMethod(Method m, Class allowedParameter)
      {
         return m.getParameterTypes().length == 1 && m.getParameterTypes()[0].isAssignableFrom(allowedParameter) && m.getReturnType().equals(void.class);
  
  
  



More information about the jboss-cvs-commits mailing list