org.jboss.cache.notifications.event
Class EventImpl

java.lang.Object
  extended by org.jboss.cache.notifications.event.EventImpl
All Implemented Interfaces:
BuddyGroupChangedEvent, CacheBlockedEvent, CacheStartedEvent, CacheStoppedEvent, CacheUnblockedEvent, Event, NodeActivatedEvent, NodeCreatedEvent, NodeEvent, NodeEvictedEvent, NodeLoadedEvent, NodeModifiedEvent, NodeMovedEvent, NodePassivatedEvent, NodeRemovedEvent, NodeVisitedEvent, TransactionalEvent, TransactionCompletedEvent, TransactionRegisteredEvent, ViewChangedEvent

public class EventImpl
extends Object
implements CacheBlockedEvent, CacheUnblockedEvent, CacheStartedEvent, CacheStoppedEvent, NodeActivatedEvent, NodeCreatedEvent, NodeEvictedEvent, NodeLoadedEvent, NodeModifiedEvent, NodeMovedEvent, NodePassivatedEvent, NodeRemovedEvent, NodeVisitedEvent, TransactionCompletedEvent, TransactionRegisteredEvent, ViewChangedEvent, BuddyGroupChangedEvent

Basic implementation of an event that covers all event types.

Since:
2.0.0
Author:
Manik Surtani

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.NodeModifiedEvent
NodeModifiedEvent.ModificationType
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Nested classes/interfaces inherited from interface org.jboss.cache.notifications.event.Event
Event.Type
 
Constructor Summary
EventImpl()
           
EventImpl(boolean pre, Cache cache, NodeModifiedEvent.ModificationType modificationType, Map data, Fqn fqn, Transaction transaction, boolean originLocal, Fqn targetFqn, boolean successful, org.jgroups.View newView, Event.Type type)
           
 
Method Summary
 boolean equals(Object o)
           
 BuddyGroup getBuddyGroup()
           
 Cache getCache()
           
 Map getData()
          When called with isPre() == true, this is the initial state of the Node before modification.
 Fqn getFqn()
           
 NodeModifiedEvent.ModificationType getModificationType()
           
 org.jgroups.View getNewView()
           
 Fqn getTargetFqn()
           
 Transaction getTransaction()
           
 Event.Type getType()
           
 int hashCode()
           
 boolean isOriginLocal()
           
 boolean isPre()
           
 boolean isSuccessful()
           
 void setBuddyGroup(BuddyGroup buddyGroup)
           
 void setCache(Cache cache)
           
 void setData(Map data)
           
 void setFqn(Fqn fqn)
           
 void setModificationType(NodeModifiedEvent.ModificationType modificationType)
           
 void setNewView(org.jgroups.View newView)
           
 void setOriginLocal(boolean originLocal)
           
 void setPre(boolean pre)
           
 void setSuccessful(boolean successful)
           
 void setTargetFqn(Fqn targetFqn)
           
 void setTransaction(Transaction transaction)
           
 void setType(Event.Type type)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventImpl

public EventImpl(boolean pre,
                 Cache cache,
                 NodeModifiedEvent.ModificationType modificationType,
                 Map data,
                 Fqn fqn,
                 Transaction transaction,
                 boolean originLocal,
                 Fqn targetFqn,
                 boolean successful,
                 org.jgroups.View newView,
                 Event.Type type)

EventImpl

public EventImpl()
Method Detail

getType

public Event.Type getType()
Specified by:
getType in interface Event
Returns:
the type of event represented by this instance.

isPre

public boolean isPre()
Specified by:
isPre in interface Event
Returns:
true if the notification is before the event has occured, false if after the event has occured.

getCache

public Cache getCache()
Specified by:
getCache in interface Event
Returns:
a handle to the cache instance that generated this notification.

getModificationType

public NodeModifiedEvent.ModificationType getModificationType()
Specified by:
getModificationType in interface NodeModifiedEvent
Returns:
an instance of the NodeModifiedEvent.ModificationType enumeration.

getData

public Map getData()
Description copied from interface: NodeModifiedEvent
When called with isPre() == true, this is the initial state of the Node before modification.

When called with isPre() == false, this depends on the value of getModificationType():

Implementations interested in seeing the difference in the node data in the NodeModifiedEvent.ModificationType.PUT_MAP case can cache the value of getData() map passed when isPre() == true, and then when the isPre() == false callback is received, pass the cached map and the new result of getData() to Util.diffNodeData(java.util.Map,java.util.Map)

Specified by:
getData in interface NodeActivatedEvent
Specified by:
getData in interface NodeLoadedEvent
Specified by:
getData in interface NodeModifiedEvent
Specified by:
getData in interface NodePassivatedEvent
Specified by:
getData in interface NodeRemovedEvent
Returns:
an unmodifiable Map of data being activated. Empty map when Event.isPre() returns true.

getFqn

public Fqn getFqn()
Specified by:
getFqn in interface NodeEvent
Returns:
the Fqn pointing to the node that is affected.

getTransaction

public Transaction getTransaction()
Specified by:
getTransaction in interface TransactionalEvent
Returns:
the Transaction associated with the current call. May be null if the current call is outside the scope of a transaction.

isOriginLocal

public boolean isOriginLocal()
Specified by:
isOriginLocal in interface TransactionalEvent
Returns:
true if the call originated on the local cache instance; false if originated from a remote one.

getTargetFqn

public Fqn getTargetFqn()
Specified by:
getTargetFqn in interface NodeMovedEvent
Returns:
the new, resultant Fqn after the move

isSuccessful

public boolean isSuccessful()
Specified by:
isSuccessful in interface TransactionCompletedEvent
Returns:
if true, the transaction completed by committing successfully. If false, the transaction completed with a rollback.

getNewView

public org.jgroups.View getNewView()
Specified by:
getNewView in interface ViewChangedEvent
Returns:
the new view associated with this view change.

setPre

public void setPre(boolean pre)

setCache

public void setCache(Cache cache)

setModificationType

public void setModificationType(NodeModifiedEvent.ModificationType modificationType)

setData

public void setData(Map data)

setFqn

public void setFqn(Fqn fqn)

setTransaction

public void setTransaction(Transaction transaction)

setOriginLocal

public void setOriginLocal(boolean originLocal)

setTargetFqn

public void setTargetFqn(Fqn targetFqn)

setSuccessful

public void setSuccessful(boolean successful)

setNewView

public void setNewView(org.jgroups.View newView)

setType

public void setType(Event.Type type)

setBuddyGroup

public void setBuddyGroup(BuddyGroup buddyGroup)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getBuddyGroup

public BuddyGroup getBuddyGroup()
Specified by:
getBuddyGroup in interface BuddyGroupChangedEvent
Returns:
the new buddy group


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.