org.eclipse.ocl.examples.eventmanager.framework
Class AdapterCapsule

java.lang.Object
  extended by org.eclipse.ocl.examples.eventmanager.framework.AdapterCapsule
Direct Known Subclasses:
DeferringNotifier

public class AdapterCapsule
extends java.lang.Object

The Notifier encapsulates the knowledge how to notify the listeners.

Author:
Daniel Vocke (D044825)

Field Summary
protected  java.lang.ref.WeakReference<? extends org.eclipse.emf.common.notify.Adapter> _listener
          the listener that will be notified when an event is fired.
protected  ListenerTypeEnum _listenerType
          the type of the listener that will be notified.
protected  EventManager _manager
           
 
Constructor Summary
AdapterCapsule(java.lang.ref.WeakReference<? extends org.eclipse.emf.common.notify.Adapter> listener, ListenerTypeEnum listenerType, EventManager manager)
           
 
Method Summary
 void cancelDeferment()
          This method is defined here because of convenience reasons.
 void deferNotification()
          This method is defined here because of convenience reasons.
 void deliverDeferredEvents()
          This method is defined here because of convenience reasons.
 void fireEvent(org.eclipse.emf.common.notify.Notification event)
          notifies the encapsulated listener about the passed event
 java.lang.ref.WeakReference<? extends org.eclipse.emf.common.notify.Adapter> getListener()
           
 ListenerTypeEnum getListenerType()
           
 boolean isResponsibleFor(org.eclipse.emf.common.notify.Adapter listener, ListenerTypeEnum listenerType)
          Each Notifier is responsible for exactly one listener and its role.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_listener

protected java.lang.ref.WeakReference<? extends org.eclipse.emf.common.notify.Adapter> _listener
the listener that will be notified when an event is fired.


_listenerType

protected ListenerTypeEnum _listenerType
the type of the listener that will be notified.


_manager

protected EventManager _manager
Constructor Detail

AdapterCapsule

public AdapterCapsule(java.lang.ref.WeakReference<? extends org.eclipse.emf.common.notify.Adapter> listener,
                      ListenerTypeEnum listenerType,
                      EventManager manager)
Method Detail

getListener

public java.lang.ref.WeakReference<? extends org.eclipse.emf.common.notify.Adapter> getListener()
Returns:
the listener associated to this notifier

isResponsibleFor

public boolean isResponsibleFor(org.eclipse.emf.common.notify.Adapter listener,
                                ListenerTypeEnum listenerType)
Each Notifier is responsible for exactly one listener and its role. If a listener implements multiple roles (Pre_Op, Post_Op,postCommit-Listener) then for each role another instance of Notifier handles the invocation of the listener's notify method.

Parameters:
listener - the instance of the listener
listenerType - the role of the listener that shall be notified
Returns:
whether this instance is responsible for the listener-instance and the specified role or not.

getListenerType

public ListenerTypeEnum getListenerType()
Returns:
the type of the listener that this Notifier will notify

deferNotification

public void deferNotification()
This method is defined here because of convenience reasons. The implementation can be found in subclasses.


deliverDeferredEvents

public void deliverDeferredEvents()
This method is defined here because of convenience reasons. The implementation can be found in subclasses.


cancelDeferment

public void cancelDeferment()
This method is defined here because of convenience reasons. The implementation can be found in subclasses.


fireEvent

public void fireEvent(org.eclipse.emf.common.notify.Notification event)
notifies the encapsulated listener about the passed event

Parameters:
event - the event that will be sent to the listener

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
"DeferringNotifier for Pre_Commit_Tx Listener " for example