openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r820389 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Date Wed, 30 Sep 2009 19:00:08 GMT
Author: dblevins
Date: Wed Sep 30 19:00:07 2009
New Revision: 820389

URL: http://svn.apache.org/viewvc?rev=820389&view=rev
Log:
Removed duplicate add/remove code

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=820389&r1=820388&r2=820389&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Wed Sep 30 19:00:07 2009
@@ -88,21 +88,11 @@
         set.add(observerImpl);
     }
 
-    public <T> void addObserver(Observer<T> observer, TypeLiteral<T> eventType,
Annotation... annotations)
+    public <T> void addObserver(Observer<T> observer, TypeLiteral<T> typeLiteral,
Annotation... annotations)
     {
-        EventUtil.checkEventType(eventType.getRawType());
-        EventUtil.checkEventBindings(annotations);
-
-        ObserverWrapper<T> observerImpl = new ObserverWrapper<T>(observer, eventType.getRawType(),
annotations);
-
-        Set<ObserverWrapper<?>> set = observers.get(eventType.getRawType());
-        if (set == null)
-        {
-            set = new HashSet<ObserverWrapper<?>>();
-            observers.put(eventType.getRawType(), set);
-        }
+        EventUtil.checkEventType(typeLiteral.getRawType());
 
-        set.add(observerImpl);
+        addObserver(observer, false, TransactionalObserverType.NONE, typeLiteral.getRawType(),
annotations);
     }
 
     public <T> void removeObserver(Observer<T> observer, Class<T> eventType,
Annotation... annotations)
@@ -129,28 +119,9 @@
         }
     }
 
-    public <T> void removeObserver(Observer<T> observer, TypeLiteral<T>
eventType, Annotation... annotations)
+    public <T> void removeObserver(Observer<T> observer, TypeLiteral<T>
typeLiteral, Annotation... annotations)
     {
-        EventUtil.checkEventType(eventType.getRawType());
-        EventUtil.checkEventBindings(annotations);
-
-        if (observers.containsKey(eventType.getRawType()))
-        {
-            Set<ObserverWrapper<?>> set = observers.get(eventType.getRawType());
-            for (ObserverWrapper<?> s : set)
-            {
-                Observer<T> ob = (Observer<T>) ((ObserverWrapper<?>) s).getObserver();
-
-                Set<Annotation> evenBindings = s.getEventQualifiers();
-                Annotation[] anns = new Annotation[evenBindings.size()];
-                anns = evenBindings.toArray(anns);
-
-                if (ob.equals(observer) && Arrays.equals(anns, annotations))
-                {
-                    set.remove(s);
-                }
-            }
-        }
+        removeObserver(observer, typeLiteral.getRawType(), annotations);
     }
 
     public <T> Set<Observer<T>> resolveObservers(T event, Annotation...
bindings)



Mime
View raw message