FileDocCategorySizeDatePackage
SubjectImpl.javaAPI DocJBoss 4.2.12200Fri Jul 13 21:02:26 BST 2007org.jboss.aspects.patterns.observable

SubjectImpl

public class SubjectImpl extends Object implements Subject
The subject implementation.
author
Adrian Brock
version
$Revision: 57186 $

Fields Summary
private Set
observers
The observers
private Object
subject
The subject
Constructors Summary
public SubjectImpl(Object subject)


     
   
      this.subject = subject;
   
Methods Summary
public voidaddObserver(Observer observer)

      if(observers.contains(observer))
         return;  // return right away since we have that already.
      observers.add(observer);
   
public voidnotifyObservers()

      Subject obj = (Subject) subject;
      
      synchronized (observers)
      {
         for (Iterator i = observers.iterator(); i.hasNext();)
         {
            Observer observer = (Observer) i.next();
            observer.fireChange(obj);
         }
      }
   
public voidremoveObserver(Observer observer)

      observers.remove(observer);