|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.ocl.examples.eventmanager.framework.EventManagerTableBased
public class EventManagerTableBased
A scalable implementation of the EventManager interface, using hash tables to quickly dispatch
incoming Notifications to the sets of registered event listeners. Uses a single
EContentAdapter to listen to all changes in those ResourceSets for which it is responsible.
| Field Summary | |
|---|---|
protected java.util.WeakHashMap<org.eclipse.emf.common.notify.Adapter,java.util.Collection<AdapterCapsule>> |
notifierByListener
listeners are not notified directly. |
| Constructor Summary | |
|---|---|
EventManagerTableBased()
|
|
EventManagerTableBased(org.eclipse.emf.ecore.resource.ResourceSet set)
|
|
| Method Summary | |
|---|---|
void |
addToObservedResourceSets(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Adds resourceSet to the resource sets from which this event manager receives notifications
that it dispatches to adapters subscribed to this event manager. |
void |
beginCommand()
|
void |
cancelCommand()
|
void |
deregister(org.eclipse.emf.common.notify.Adapter listener)
|
protected void |
finalize()
|
void |
fireChangeEvent(org.eclipse.emf.common.notify.Notification event)
|
void |
firePreChangeEvent(org.eclipse.emf.common.notify.Notification event)
|
void |
handleEMFEvent(org.eclipse.emf.common.notify.Notification notification)
Initialize the filtering process for a given Notification, all Adapter registered with a matching filter
will be notified. |
void |
postCommitCommand()
|
void |
preCommitCommand()
|
void |
registerCommitListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree)
|
void |
registerPreChangeListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree)
|
void |
registerPreCommitListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree)
|
void |
removeFromObservedResourceSets(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Stops receiving and dispatching notifications coming from resourceSet. |
void |
setActive(boolean active)
Sometimes it can be convenient to temporarily stop the flow of events. |
void |
setFireEvents(boolean doFireEventsValue)
Toogle the EventManager off, on given false and no Notifications will be delivered |
void |
subscribe(EventFilter eventFilterTree,
org.eclipse.emf.common.notify.Adapter listener)
Register an Adapter on the EventManager which will be notified for any Notification which matches
the given filter. |
java.lang.String |
toString()
|
boolean |
unsubscribe(org.eclipse.emf.common.notify.Adapter caller)
Removes the given Adapter from the EventManager and the linked AbstractEventFilter, so that the given
Adapter will not be notified anymore |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.util.WeakHashMap<org.eclipse.emf.common.notify.Adapter,java.util.Collection<AdapterCapsule>> notifierByListener
| Constructor Detail |
|---|
public EventManagerTableBased(org.eclipse.emf.ecore.resource.ResourceSet set)
public EventManagerTableBased()
| Method Detail |
|---|
public void setFireEvents(boolean doFireEventsValue)
EventManager off, on given false and no Notifications will be delivered
doFireEventsValue - false to disable Notificationdelivery, true to enablepublic void setActive(boolean active)
EventManagerResourceSet and thus removing the
adapter from all objects in the resource set, it is more efficient to just block forwarding the events to the
Adapters subscribed with this event manager.
Calling this method with active==false will stop this event manager from forwarding events to
the Adapters subscribed. Calling it with active==true again will forward events received
after the call again. Events that arrived in between are not forwarded and therefore "lost" for the
subscribers to this event manager.
By default, an event manager starts in the "active" state.
setActive in interface EventManager
public void subscribe(EventFilter eventFilterTree,
org.eclipse.emf.common.notify.Adapter listener)
EventManagerAdapter on the EventManager which will be notified for any Notification which matches
the given filter. If an equal or the same caller registers multiple times using equal filters,
the caller will get notified as many times as it subscribed.
subscribe in interface EventManagereventFilterTree - the AbstractEventFilter which is used to filter events for the given Adapter.
Currently, there are still a few limitations as to the filter trees permissible. It is
considered an error if the filter, after conversion into disjunctive normal form,
contains more than one filter of a kind in an "AND" clause. Such filters, passed
to this method, cause an IllegalArgumentException to be thrown.listener - the adapter which should receive event which matches the filter. This event manager will only
maintain weak references to the listener which means that the client should hold a strong reference
in order to make sure that notifications will be received. This is a good idea anyhow since for
de-registration using EventManager.unsubscribe(Adapter) the listener is required as well.
public void registerPreChangeListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree)
public void registerCommitListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree)
public void registerPreCommitListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree)
public void deregister(org.eclipse.emf.common.notify.Adapter listener)
public void fireChangeEvent(org.eclipse.emf.common.notify.Notification event)
public void firePreChangeEvent(org.eclipse.emf.common.notify.Notification event)
public void beginCommand()
public void postCommitCommand()
public void preCommitCommand()
public void cancelCommand()
public void handleEMFEvent(org.eclipse.emf.common.notify.Notification notification)
EventManagerNotification, all Adapter registered with a matching filter
will be notified. Normally, clients don't have to call this method explicitly. It will be called by the
event manager automatically when an event has been received from any elements in the ResourceSet
for which the event manager has been obtained (see EventManagerFactory.getEventManagerFor(ResourceSet)).
However, for testing purposes and in case clients want to explicitly send events that have not emerged
from the ResourceSet to registered clients, they may use this method.
handleEMFEvent in interface EventManagernotification - Notification to send to clients whose event filter matches the notificationpublic boolean unsubscribe(org.eclipse.emf.common.notify.Adapter caller)
EventManagerAdapter from the EventManager and the linked AbstractEventFilter, so that the given
Adapter will not be notified anymore
unsubscribe in interface EventManagercaller - the Adapter to unsubscribe
true if the adapter was registered
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic java.lang.String toString()
toString in class java.lang.Objectpublic void addToObservedResourceSets(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
EventManagerresourceSet to the resource sets from which this event manager receives notifications
that it dispatches to adapters subscribed to this event manager. If this event manager already
does receive notifications from resourceSet it is not registered a second time. In
particular, it won't receive the same notifications multiple times.
addToObservedResourceSets in interface EventManagerEventManager.removeFromObservedResourceSets(ResourceSet)public void removeFromObservedResourceSets(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
EventManagerresourceSet.
removeFromObservedResourceSets in interface EventManagerEventManager.addToObservedResourceSets(ResourceSet)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||