[jboss-cvs] JBossCache/src/org/jboss/cache/notifications/event ...

Manik Surtani manik at jboss.org
Thu Jun 28 12:53:35 EDT 2007


  User: msurtani
  Date: 07/06/28 12:53:35

  Added:       src/org/jboss/cache/notifications/event                    
                        NodeLoadedEvent.java TransactionalEvent.java
                        NodeActivatedEvent.java CacheStartedEvent.java
                        NodeMovedEvent.java NodeEvictedEvent.java
                        NodePassivatedEvent.java EventImpl.java
                        TransactionCompletedEvent.java NodeEvent.java
                        ViewChangedEvent.java NodeRemovedEvent.java
                        TransactionRegisteredEvent.java
                        NodeCreatedEvent.java NodeModifiedEvent.java
                        CacheUnblockedEvent.java CacheStoppedEvent.java
                        Event.java CacheBlockedEvent.java
                        NodeVisitedEvent.java
  Log:
  Notification changes
  
  Revision  Changes    Path
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeLoadedEvent.java
  
  Index: NodeLoadedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import java.util.Map;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeLoaded}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeLoadedEvent extends NodeEvent
  {
     /**
      * @return an unmodifiable {@link Map} of data loaded from a cache loader and into the cache.  If the
      *         {@link org.jboss.cache.Node} is loaded but the data isn't (for example when calling {@link org.jboss.cache.Node#getChildren()})
      *         this method returns <tt>null</tt>.
      */
     Map getData();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/TransactionalEvent.java
  
  Index: TransactionalEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import javax.transaction.Transaction;
  
  /**
   * An event type that includes a transaction context - if one exists - as well as a boolean as to whether the call
   * originated locally or remotely.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface TransactionalEvent extends Event
  {
     /**
      * @return the Transaction associated with the current call.  May be null if the current call is outside the
      *         scope of a transaction.
      */
     Transaction getTransaction();
  
     /**
      * @return true if the call originated on the local cache instance; false if originated from a remote one.
      */
     boolean isOriginLocal();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeActivatedEvent.java
  
  Index: NodeActivatedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import java.util.Map;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeActivated}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeActivatedEvent extends NodeEvent
  {
     /**
      * @return an unmodifiable {@link java.util.Map} of data being activated.  Empty map when {@link #isPre()} returns <tt>true</tt>.
      */
     Map getData();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/CacheStartedEvent.java
  
  Index: CacheStartedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.CacheStarted}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface CacheStartedEvent extends Event
  {
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeMovedEvent.java
  
  Index: NodeMovedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import org.jboss.cache.Fqn;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeMoved}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeMovedEvent extends NodeEvent
  {
     /**
      * @return the new, resultant Fqn after the move
      */
     Fqn getTargetFqn();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeEvictedEvent.java
  
  Index: NodeEvictedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeEvicted}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeEvictedEvent extends NodeEvent
  {
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodePassivatedEvent.java
  
  Index: NodePassivatedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import java.util.Map;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodePassivated}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodePassivatedEvent extends NodeEvent
  {
     /**
      * @return an unmodifiable {@link java.util.Map} of data being passivated.  Empty map when {@link #isPre()} is <tt>false</tt>.
      */
     Map getData();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/EventImpl.java
  
  Index: EventImpl.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import org.jboss.cache.Cache;
  import org.jboss.cache.Fqn;
  import org.jgroups.View;
  
  import javax.transaction.Transaction;
  import java.util.Map;
  
  /**
   * Basic implementation of an event that covers all event types.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public class EventImpl implements CacheBlockedEvent, CacheUnblockedEvent, CacheStartedEvent, CacheStoppedEvent,
          NodeActivatedEvent, NodeCreatedEvent, NodeEvictedEvent, NodeLoadedEvent, NodeModifiedEvent, NodeMovedEvent,
          NodePassivatedEvent, NodeRemovedEvent, NodeVisitedEvent, TransactionCompletedEvent, TransactionRegisteredEvent,
          ViewChangedEvent
  {
     private boolean pre = false; // by default events are after the fact
     private Cache cache;
     private ModificationType modificationType;
     private Map data;
     private Fqn fqn;
     private Transaction transaction;
     private boolean originLocal = true; // by default events all originate locally
     private Fqn targetFqn;
     private boolean successful;
     private View newView;
     private Type type;
  
  
     public EventImpl(boolean pre, Cache cache, ModificationType modificationType, Map data, Fqn fqn, Transaction transaction, boolean originLocal, Fqn targetFqn, boolean successful, View newView, Type type)
     {
        this.pre = pre;
        this.cache = cache;
        this.modificationType = modificationType;
        this.data = data;
        this.fqn = fqn;
        this.transaction = transaction;
        this.originLocal = originLocal;
        this.targetFqn = targetFqn;
        this.successful = successful;
        this.newView = newView;
        this.type = type;
     }
  
     public EventImpl()
     {
     }
  
     public Type getType()
     {
        return type;
     }
  
     public boolean isPre()
     {
        return pre;
     }
  
     public Cache getCache()
     {
        return cache;
     }
  
     public ModificationType getModificationType()
     {
        return modificationType;
     }
  
     public Map getData()
     {
        return data;
     }
  
     public Fqn getFqn()
     {
        return fqn;
     }
  
     public Transaction getTransaction()
     {
        return transaction;
     }
  
     public boolean isOriginLocal()
     {
        return originLocal;
     }
  
     public Fqn getTargetFqn()
     {
        return targetFqn;
     }
  
     public boolean isSuccessful()
     {
        return successful;
     }
  
     public View getNewView()
     {
        return newView;
     }
  
     // ------------------------------ setters -----------------------------
  
     public void setPre(boolean pre)
     {
        this.pre = pre;
     }
  
     public void setCache(Cache cache)
     {
        this.cache = cache;
     }
  
     public void setModificationType(ModificationType modificationType)
     {
        this.modificationType = modificationType;
     }
  
     public void setData(Map data)
     {
        this.data = data;
     }
  
     public void setFqn(Fqn fqn)
     {
        this.fqn = fqn;
     }
  
     public void setTransaction(Transaction transaction)
     {
        this.transaction = transaction;
     }
  
     public void setOriginLocal(boolean originLocal)
     {
        this.originLocal = originLocal;
     }
  
     public void setTargetFqn(Fqn targetFqn)
     {
        this.targetFqn = targetFqn;
     }
  
     public void setSuccessful(boolean successful)
     {
        this.successful = successful;
     }
  
     public void setNewView(View newView)
     {
        this.newView = newView;
     }
  
     public void setType(Type type)
     {
        this.type = type;
     }
  
  
     public boolean equals(Object o)
     {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
  
        EventImpl event = (EventImpl) o;
  
        if (originLocal != event.originLocal) return false;
        if (pre != event.pre) return false;
        if (successful != event.successful) return false;
        if (cache != null ? !cache.equals(event.cache) : event.cache != null) return false;
        if (data != null ? !data.equals(event.data) : event.data != null) return false;
        if (fqn != null ? !fqn.equals(event.fqn) : event.fqn != null) return false;
        if (modificationType != event.modificationType) return false;
        if (targetFqn != null ? !targetFqn.equals(event.targetFqn) : event.targetFqn != null) return false;
        if (transaction != null ? !transaction.equals(event.transaction) : event.transaction != null) return false;
        if (newView != null ? !newView.equals(event.newView) : event.newView != null) return false;
        if (type != null ? !type.equals(event.type) : event.type != null) return false;
  
        return true;
     }
  
     public int hashCode()
     {
        int result;
        result = (pre ? 1 : 0);
        result = 31 * result + (cache != null ? cache.hashCode() : 0);
        result = 31 * result + (modificationType != null ? modificationType.hashCode() : 0);
        result = 31 * result + (data != null ? data.hashCode() : 0);
        result = 31 * result + (fqn != null ? fqn.hashCode() : 0);
        result = 31 * result + (transaction != null ? transaction.hashCode() : 0);
        result = 31 * result + (originLocal ? 1 : 0);
        result = 31 * result + (targetFqn != null ? targetFqn.hashCode() : 0);
        result = 31 * result + (successful ? 1 : 0);
        result = 31 * result + (newView != null ? newView.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        return result;
     }
  
  
     public String toString()
     {
        return "EventImpl{" +
                "pre=" + pre +
                ", cache=" + cache +
                ", modificationType=" + modificationType +
                ", data=" + data +
                ", fqn=" + fqn +
                ", transaction=" + transaction +
                ", originLocal=" + originLocal +
                ", targetFqn=" + targetFqn +
                ", successful=" + successful +
                ", newView=" + newView +
                ", type=" + type +
                '}';
     }
  
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/TransactionCompletedEvent.java
  
  Index: TransactionCompletedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.TransactionCompleted}.
   * <p/>
   * Note that this event is only delivered <i>after the fact</i>, i.e., you will never see an instance of this event
   * with {@link #isPre()} being set to <tt>true</tt>.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface TransactionCompletedEvent extends TransactionalEvent
  {
     /**
      * @return if <tt>true</tt>, the transaction completed by committing successfully.  If <tt>false</tt>, the transaction
      *         completed with a rollback.
      */
     boolean isSuccessful();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeEvent.java
  
  Index: NodeEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import org.jboss.cache.Fqn;
  
  /**
   * Transactional events that additionally expose an Fqn as such events pertain to a specific node.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeEvent extends TransactionalEvent
  {
     /**
      * @return the Fqn pointing to the node that is affected.
      */
     Fqn getFqn();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/ViewChangedEvent.java
  
  Index: ViewChangedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import org.jgroups.View;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.ViewChanged}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface ViewChangedEvent extends Event
  {
     /**
      * @return the new view associated with this view change.
      */
     View getNewView();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeRemovedEvent.java
  
  Index: NodeRemovedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import java.util.Map;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeRemoved}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeRemovedEvent extends NodeEvent
  {
     /**
      * @return an unmodifiable {@link Map} of data.  When <tt>isPre() == true</tt>, this is the initial state of the {@link org.jboss.cache.Node}
      *         before removal.  When called with <tt>isPre() == false</tt>, this is <tt>null</tt>.
      */
     Map getData();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/TransactionRegisteredEvent.java
  
  Index: TransactionRegisteredEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.TransactionRegistered}.
   * <p/>
   * Note that this event is only delivered <i>after the fact</i>, i.e., you will never see an instance of this event
   * with {@link #isPre()} being set to <tt>true</tt>.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface TransactionRegisteredEvent extends TransactionalEvent
  {
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeCreatedEvent.java
  
  Index: NodeCreatedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeCreated}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeCreatedEvent extends NodeEvent
  {
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeModifiedEvent.java
  
  Index: NodeModifiedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import java.util.Map;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeModified}
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeModifiedEvent extends NodeEvent
  {
     /**
      * Different cache modification types.
      */
     enum ModificationType
     {
        PUT_DATA, REMOVE_DATA, PUT_MAP
     }
  
     /**
      * @return an instance of the {@link org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType} enumeration.
      */
     ModificationType getModificationType();
  
     /**
      * When called with <tt>isPre() == true</tt>, this is the initial state of the {@link org.jboss.cache.Node}
      * before modification.
      * <p/>
      * When called with <tt>isPre() == false</tt>, this depends on the value of <tt>getModificationType()</tt>:
      * <ul>
      * <li><b>{@link ModificationType#PUT_DATA}</b>: Map contains the single key/value pair that was added or modified.</li>
      * <li><b>{@link ModificationType#REMOVE_DATA}</b>: Map contains the key/value pairs that were removed.</li>
      * <li><b>{@link ModificationType#PUT_MAP}</b>: Map contains the new state of the {@link org.jboss.cache.Node} following modification.  This map includes modified key/value
      * pairs as well as any that were not affected.</li>
      * </ul>
      * <p/>
      * Implementations interested in seeing the difference in the node data in the {@link ModificationType#PUT_MAP} case
      * can cache the value of <tt>getData()</tt> map passed when <tt>isPre() == true</tt>, and then when the
      * <tt>isPre() == false</tt> callback is received, pass the cached map and the new result of <tt>getData()</tt> to
      * {@link org.jboss.cache.util.Util#diffNodeData(java.util.Map,java.util.Map)}
      *
      * @return Unmodifiable {@link java.util.Map}; will not be <code>null</code>. See description above.
      */
     Map getData();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/CacheUnblockedEvent.java
  
  Index: CacheUnblockedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.CacheUnblocked}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface CacheUnblockedEvent extends Event
  {
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/CacheStoppedEvent.java
  
  Index: CacheStoppedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.CacheStopped}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface CacheStoppedEvent extends Event
  {
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/Event.java
  
  Index: Event.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  import org.jboss.cache.Cache;
  
  /**
   * An interface that defines common characteristics of events
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface Event
  {
     public enum Type
     {
        CACHE_STARTED, CACHE_STOPPED, CACHE_BLOCKED, CACHE_UNBLOCKED, NODE_ACTIVATED, NODE_PASSIVATED,
        NODE_LOADED, NODE_EVICTED, NODE_CREATED, NODE_REMOVED, NODE_MODIFIED, NODE_MOVED, NODE_VISITED,
        TRANSACTION_COMPLETED, TRANSACTION_REGISTERED, VIEW_CHANGED
     }
  
     /**
      * @return the type of event represented by this instance.
      */
     Type getType();
  
     /**
      * @return true if the notification is before the event has occured, false if after the event has occured.
      */
     boolean isPre();
  
     /**
      * @return a handle to the cache instance that generated this notification.
      */
     Cache getCache();
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/CacheBlockedEvent.java
  
  Index: CacheBlockedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.CacheBlocked}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface CacheBlockedEvent extends Event
  {
  }
  
  
  
  1.1      date: 2007/06/28 16:53:35;  author: msurtani;  state: Exp;JBossCache/src/org/jboss/cache/notifications/event/NodeVisitedEvent.java
  
  Index: NodeVisitedEvent.java
  ===================================================================
  package org.jboss.cache.notifications.event;
  
  /**
   * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeVisited}.
   *
   * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
   * @since 2.0.0
   */
  public interface NodeVisitedEvent extends NodeEvent
  {
  }
  
  
  



More information about the jboss-cvs-commits mailing list