org.eclipse.emf.transaction
Class TriggerListener

java.lang.Object
  extended by org.eclipse.emf.transaction.ResourceSetListenerImpl
      extended by org.eclipse.emf.transaction.TriggerListener
All Implemented Interfaces:
EventListener, ResourceSetListener, ResourceSetListener.Internal

public abstract class TriggerListener
extends ResourceSetListenerImpl

A convenient superclass for listeners that implement "triggers" to process Notifications one at a time, generating a command for each that will make dependent updates to the model.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.transaction.ResourceSetListener
ResourceSetListener.Internal
 
Constructor Summary
TriggerListener()
          Initializes me with the default filter.
TriggerListener(NotificationFilter filter)
          Initializes me with the specified filter.
 
Method Summary
 boolean isPrecommitOnly()
          I want only ppre-commit events, not post-commit events.
 Command transactionAboutToCommit(ResourceSetChangeEvent event)
          Implements the trigger callback by processing the event's notifications one by one, delegating to the trigger(org.eclipse.emf.transaction.TransactionalEditingDomain, org.eclipse.emf.common.notify.Notification) method for each to generate a command.
protected abstract  Command trigger(TransactionalEditingDomain domain, Notification notification)
          Implemented by subclasses to provide a trigger command for a single change in the model.
 
Methods inherited from class org.eclipse.emf.transaction.ResourceSetListenerImpl
getFilter, getTarget, isAggregatePrecommitListener, isPostcommitOnly, resourceSetChanged, setTarget, unsetTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TriggerListener

public TriggerListener()
Initializes me with the default filter.


TriggerListener

public TriggerListener(NotificationFilter filter)
Initializes me with the specified filter.

Parameters:
filter - a notification filter, or null for the default
Method Detail

transactionAboutToCommit

public Command transactionAboutToCommit(ResourceSetChangeEvent event)
                                 throws RollbackException
Implements the trigger callback by processing the event's notifications one by one, delegating to the trigger(org.eclipse.emf.transaction.TransactionalEditingDomain, org.eclipse.emf.common.notify.Notification) method for each to generate a command. The commands created by the subclass are chained in the order that they are received from the subclass.

Specified by:
transactionAboutToCommit in interface ResourceSetListener
Overrides:
transactionAboutToCommit in class ResourceSetListenerImpl
Parameters:
event - the event object describing the changes that occurred in the resource set
Returns:
a composite of the commands returned by the subclass implementation of the trigger(org.eclipse.emf.transaction.TransactionalEditingDomain, org.eclipse.emf.common.notify.Notification) method
Throws:
RollbackException - to force a roll-back of the current transaction

trigger

protected abstract Command trigger(TransactionalEditingDomain domain,
                                   Notification notification)
Implemented by subclasses to provide a trigger command for a single change in the model.

Parameters:
domain - the editing domain
notification - the notification describing a change in the model
Returns:
the command, or null if none is required for this particular notification

isPrecommitOnly

public boolean isPrecommitOnly()
I want only ppre-commit events, not post-commit events.

Specified by:
isPrecommitOnly in interface ResourceSetListener
Overrides:
isPrecommitOnly in class ResourceSetListenerImpl
Returns:
true if I only am interested in pre-commit events; false, otherwise

Copyright 2002, 2007 IBM Corporation and others.
All Rights Reserved.