jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r713076 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/cluster/ main/java/org/apache/jackrabbit/core/journal/ main/java/org/apache/jackrabbit/core/observation/ main/jav...
Date Tue, 11 Nov 2008 16:30:38 GMT
Author: mreutegg
Date: Tue Nov 11 08:30:37 2008
New Revision: 713076

URL: http://svn.apache.org/viewvc?rev=713076&view=rev
Log:
JCR-1839: Introduce Event.getDate()

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordDeserializer.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ReadRecord.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Tue Nov 11 08:30:37 2008
@@ -2096,11 +2096,14 @@
         /**
          * {@inheritDoc}
          */
-        public void externalUpdate(ChangeLog external, List events) throws RepositoryException
{
+        public void externalUpdate(ChangeLog external,
+                                   List events,
+                                   long timestamp) throws RepositoryException {
             try {
                 EventStateCollection esc = new EventStateCollection(
                         getObservationDispatcher(), null, null);
                 esc.addAll(events);
+                esc.setTimestamp(timestamp);
 
                 getItemStateProvider().externalUpdate(external, esc);
             } catch (IllegalStateException e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ChangeLogRecord.java
Tue Nov 11 08:30:37 2008
@@ -43,6 +43,11 @@
 public class ChangeLogRecord extends ClusterRecord {
 
     /**
+     * Identifier: DATE
+     */
+    static final char DATE_IDENTIFIER = 'D';
+
+    /**
      * Identifier: NODE.
      */
     static final char NODE_IDENTIFIER = 'N';
@@ -78,6 +83,11 @@
     private ChangeLog changes;
 
     /**
+     * The time when the changes happened. Milliseconds since January 1 1970 UTC.
+     */
+    private long timestamp = System.currentTimeMillis();
+
+    /**
      * List of <code>EventState</code>s.
      */
     private List events;
@@ -96,7 +106,7 @@
      * Create a new instance of this class. Used when serializing.
      *
      * @param changes changes
-     * @param list of <code>EventState</code>s
+     * @param events list of <code>EventState</code>s
      * @param record record
      * @param workspace workspace
      */
@@ -131,6 +141,9 @@
 
         while (identifier != END_MARKER) {
             switch (identifier) {
+            case DATE_IDENTIFIER:
+                readTimestampRecord();
+                break;
             case NODE_IDENTIFIER:
                 readNodeRecord();
                 break;
@@ -158,6 +171,15 @@
     }
 
     /**
+     * Reads the timestamp record.
+     *
+     * @throws JournalException if an error occurs.
+     */
+    private void readTimestampRecord() throws JournalException {
+        timestamp = record.readLong();
+    }
+
+    /**
      * Read a node record.
      *
      * @throws JournalException if an error occurs
@@ -288,6 +310,7 @@
      * {@inheritDoc}
      */
     protected void doWrite() throws JournalException {
+        writeTimestampRecord();
         Iterator deletedStates = changes.deletedStates();
         while (deletedStates.hasNext()) {
             ItemState state = (ItemState) deletedStates.next();
@@ -324,6 +347,16 @@
     }
 
     /**
+     * Writes the timestamp record.
+     *
+     * @throws JournalException if an error occurs.
+     */
+    private void writeTimestampRecord() throws JournalException {
+        record.writeChar(DATE_IDENTIFIER);
+        record.writeLong(timestamp);
+    }
+
+    /**
      * Write a node record
      *
      * @param operation operation
@@ -397,9 +430,17 @@
      * Return the events.
      *
      * @return events
-     * @return
      */
     public List getEvents() {
         return Collections.unmodifiableList(events);
     }
+
+    /**
+     * Returns the timestamp.
+     *
+     * @return the timestamp.
+     */
+    public long getTimestamp() {
+        return timestamp;
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
Tue Nov 11 08:30:37 2008
@@ -849,7 +849,8 @@
             }
         }
         try {
-            listener.externalUpdate(record.getChanges(), record.getEvents());
+            listener.externalUpdate(record.getChanges(),
+                    record.getEvents(), record.getTimestamp());
         } catch (RepositoryException e) {
             String msg = "Unable to deliver update events: " + e.getMessage();
             log.error(msg);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordDeserializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordDeserializer.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordDeserializer.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterRecordDeserializer.java
Tue Nov 11 08:30:37 2008
@@ -40,6 +40,7 @@
         case ChangeLogRecord.NODE_IDENTIFIER:
         case ChangeLogRecord.PROPERTY_IDENTIFIER:
         case ChangeLogRecord.EVENT_IDENTIFIER:
+        case ChangeLogRecord.DATE_IDENTIFIER:
             clusterRecord = new ChangeLogRecord(c, record, workspace);
             clusterRecord.read();
             break;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/Update.java
Tue Nov 11 08:30:37 2008
@@ -57,4 +57,11 @@
      */
     List getEvents();
 
+    /**
+     * Returns the timestamp whe this update occured.
+     *
+     * @return the timestamp whe this update occured.
+     */
+    long getTimestamp();
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventListener.java
Tue Nov 11 08:30:37 2008
@@ -30,8 +30,10 @@
      *
      * @param changes external changes containing only node and property ids.
      * @param events events to deliver
+     * @param timestamp when the change occured.
      * @throws RepositoryException if the update cannot be processed
      */
-    void externalUpdate(ChangeLog changes, List events) throws RepositoryException;
+    void externalUpdate(ChangeLog changes, List events, long timestamp)
+            throws RepositoryException;
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java
Tue Nov 11 08:30:37 2008
@@ -205,6 +205,20 @@
     /**
      * {@inheritDoc}
      */
+    public void writeLong(long n) throws JournalException {
+        checkOutput();
+
+        try {
+            dataOut.writeLong(n);
+        } catch (IOException e) {
+            String msg = "I/O error while writing long.";
+            throw new JournalException(msg, e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void writeString(String s) throws JournalException {
         checkOutput();
 
@@ -386,6 +400,10 @@
         throw unsupported();
     }
 
+    public long readLong() throws JournalException {
+        throw unsupported();
+    }
+
     public String readString() throws JournalException {
         throw unsupported();
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ReadRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ReadRecord.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ReadRecord.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ReadRecord.java
Tue Nov 11 08:30:37 2008
@@ -154,6 +154,20 @@
     /**
      * {@inheritDoc}
      */
+    public long readLong() throws JournalException {
+        consumed = true;
+
+        try {
+            return dataIn.readLong();
+        } catch (IOException e) {
+            String msg = "I/O error while reading long.";
+            throw new JournalException(msg, e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public String readString() throws JournalException {
         consumed = true;
 
@@ -241,6 +255,10 @@
         throw unsupported();
     }
 
+    public void writeLong(long n) throws JournalException {
+        throw unsupported();
+    }
+
     public void writeString(String s) throws JournalException {
         throw unsupported();
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/Record.java
Tue Nov 11 08:30:37 2008
@@ -81,6 +81,14 @@
     int readInt() throws JournalException;
 
     /**
+     * Read a long from the underlying stream.
+     *
+     * @return long value.
+     * @throws JournalException if an error occurs
+     */
+    long readLong() throws JournalException;
+
+    /**
      * Read a string from the underlying stream.
      *
      * @return string or <code>null</code>
@@ -177,6 +185,14 @@
     void writeInt(int n) throws JournalException;
 
     /**
+     * Write a long to the underlying stream.
+     *
+     * @param n long
+     * @throws JournalException if an error occurs
+     */
+    void writeLong(long n) throws JournalException;
+
+    /**
      * Write a string to the underlying stream.
      *
      * @param s string, may be <code>null</code>

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
Tue Nov 11 08:30:37 2008
@@ -26,7 +26,6 @@
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.RepositoryException;
-import javax.jcr.observation.Event;
 
 /**
  * Implementation of the {@link javax.jcr.observation.Event} and
@@ -46,14 +45,14 @@
     private final SessionImpl session;
 
     /**
-     * The <code>ItemManager</code> of the session.
+     * The shared {@link EventState} object.
      */
-    //private final ItemManager itemMgr;
+    private final EventState eventState;
 
     /**
-     * The shared {@link EventState} object.
+     * The timestamp of this event.
      */
-    private final EventState eventState;
+    private final long timestamp;
 
     /**
      * Cached String value of this <code>Event</code> instance.
@@ -67,10 +66,12 @@
      * @param session    the session of the registerd <code>EventListener</code>
      *                   where this <code>Event</code> will be delivered to.
      * @param eventState the underlying <code>EventState</code>.
+     * @param timestamp  the time when the change occured that caused this event.
      */
-    EventImpl(SessionImpl session, EventState eventState) {
+    EventImpl(SessionImpl session, EventState eventState, long timestamp) {
         this.session = session;
         this.eventState = eventState;
+        this.timestamp = timestamp;
     }
 
     //---------------------------------------------------------------< Event >
@@ -96,6 +97,13 @@
         return eventState.getUserId();
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public long getDate() {
+        return timestamp;
+    }
+
     //-----------------------------------------------------------< EventImpl >
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
Tue Nov 11 08:30:37 2008
@@ -88,6 +88,11 @@
     private final Path pathPrefix;
 
     /**
+     * Timestamp when this collection was created.
+     */
+    private long timestamp = System.currentTimeMillis();
+
+    /**
      * Creates a new empty <code>EventStateCollection</code>.
      * <p/>
      * Because the item state manager in {@link #createEventStates} may represent
@@ -434,6 +439,22 @@
     }
 
     /**
+     * @return the timestamp when this collection was created.
+     */
+    public long getTimestamp() {
+        return timestamp;
+    }
+
+    /**
+     * Sets a new timestamp for this collection.
+     *
+     * @param timestamp the new timestamp value.
+     */
+    public void setTimestamp(long timestamp) {
+        this.timestamp = timestamp;
+    }
+
+    /**
      * Returns an iterator over {@link EventState} instance.
      *
      * @return an iterator over {@link EventState} instance.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
Tue Nov 11 08:30:37 2008
@@ -63,6 +63,11 @@
     private long pos = 0;
 
     /**
+     * The timestamp when the events occured.
+     */
+    private long timestamp;
+
+    /**
      * Creates a new <code>FilteredEventIterator</code>.
      *
      * @param c      an unmodifiable Collection of {@link javax.jcr.observation.Event}s.
@@ -78,6 +83,7 @@
         actualEvents = c.iterator();
         this.filter = filter;
         this.denied = denied;
+        this.timestamp = c.getTimestamp();
         fetchNext();
     }
 
@@ -158,7 +164,8 @@
             // check denied set
             if (denied == null || !denied.contains(state.getTargetId())) {
                 try {
-                    next = filter.blocks(state) ? null : new EventImpl(filter.getSession(),
state);
+                    next = filter.blocks(state) ? null : new EventImpl(
+                            filter.getSession(), state, timestamp);
                 } catch (RepositoryException e) {
                     log.error("Exception while applying filter.", e);
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Tue Nov 11 08:30:37 2008
@@ -515,6 +515,11 @@
         private HashMap attributes;
 
         /**
+         * Timestamp when this update was created.
+         */
+        private long timestamp = System.currentTimeMillis();
+
+        /**
          * Create a new instance of this class.
          */
         public Update(ChangeLog local, EventStateCollectionFactory factory,
@@ -835,6 +840,13 @@
         }
 
         /**
+         * {@inheritDoc}
+         */
+        public long getTimestamp() {
+            return timestamp;
+        }
+
+        /**
          * Updates the target node references collections based on the
          * modifications in the change log (i.e. added/removed/modified
          * <code>REFERENCE</code> properties).
@@ -843,9 +855,6 @@
          * only be called <i>once</i> per change log and the change log
          * should not be modified anymore afterwards.
          *
-         * @param changes change log
-         * @param virtualProvider virtual provider that may already contain a
-         *                        node references object
          * @throws ItemStateException if an error occurs
          */
         private void updateReferences() throws ItemStateException {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Tue Nov 11 08:30:37 2008
@@ -494,9 +494,11 @@
     /**
      * {@inheritDoc}
      */
-    public void externalUpdate(ChangeLog changes, List events) throws RepositoryException
{
+    public void externalUpdate(ChangeLog changes, List events, long timestamp)
+            throws RepositoryException {
         EventStateCollection esc = getEscFactory().createEventStateCollection(null);
         esc.addAll(events);
+        esc.setTimestamp(timestamp);
 
         sharedStateMgr.externalUpdate(changes, esc);
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java
Tue Nov 11 08:30:37 2008
@@ -28,7 +28,6 @@
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 
 import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.cluster.LockEventListener;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.state.ChangeLog;
@@ -413,10 +412,10 @@
     /**
      * {@inheritDoc}
      */
-    public void externalUpdate(ChangeLog changes, List events)
+    public void externalUpdate(ChangeLog changes, List events, long timestamp)
             throws RepositoryException {
 
-        clusterEvents.add(new UpdateEvent(changes, events));
+        clusterEvents.add(new UpdateEvent(changes, events, timestamp));
 
     }
 
@@ -441,14 +440,21 @@
         private final transient Map attributes = new HashMap();
 
         /**
+         * Timestamp when the changes in this update event occured.
+         */
+        private final long timestamp;
+
+        /**
          * Create a new instance of this class.
          *
          * @param changes change log
          * @param events list of <code>EventState</code>s
+         * @param timestamp time when the changes in this event occured.
          */
-        public UpdateEvent(ChangeLog changes, List events) {
+        public UpdateEvent(ChangeLog changes, List events, long timestamp) {
             this.changes = changes;
             this.events = events;
+            this.timestamp = timestamp;
         }
 
         /**
@@ -472,6 +478,13 @@
         /**
          * {@inheritDoc}
          */
+        public long getTimestamp() {
+            return timestamp;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
         public void setAttribute(String name, Object value) {
             attributes.put(name, value);
         }
@@ -487,7 +500,7 @@
          * {@inheritDoc}
          */
         public int hashCode() {
-            return changes.hashCode() ^ events.hashCode();
+            return changes.hashCode() ^ events.hashCode() ^ (int) (timestamp ^ (timestamp
>>> 32));
         }
 
         /**
@@ -497,7 +510,8 @@
             if (obj instanceof UpdateEvent) {
                 UpdateEvent other = (UpdateEvent) obj;
                 return SimpleEventListener.equals(changes, other.changes) &&
-                    SimpleEventListener.equals(events, other.events);
+                    SimpleEventListener.equals(events, other.events) &&
+                    timestamp == other.timestamp;
             }
             return false;
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java?rev=713076&r1=713075&r2=713076&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/UpdateEventFactory.java
Tue Nov 11 08:30:37 2008
@@ -116,7 +116,7 @@
         events.add(createEventState(p2, n2, Event.PROPERTY_REMOVED));
         events.add(createEventState(n3, Event.NODE_REMOVED, "{}n3"));
 
-        return new UpdateEvent(changes, events);
+        return new UpdateEvent(changes, events, System.currentTimeMillis());
     }
 
 
@@ -139,6 +139,7 @@
      *
      * @param parentId parent node id
      * @param name property name
+     * @return property state.
      */
     protected PropertyState createPropertyState(NodeId parentId, String name) {
         Name propName = nameFactory.create(name);
@@ -176,9 +177,9 @@
     /**
      * Create an event state for a property operation.
      *
-     * @param n node state
+     * @param p property state
+     * @param parent parent node state
      * @param type <code>Event.NODE_ADDED</code> or <code>Event.NODE_REMOVED</code>
-     * @param name property name
      * @return event state
      */
     protected EventState createEventState(PropertyState p, NodeState parent, int type) {



Mime
View raw message