jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1185836 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state: AbstractItemStateFactory.java ItemState.java NodeState.java
Date Tue, 18 Oct 2011 20:24:17 GMT
Author: mduerig
Date: Tue Oct 18 20:24:16 2011
New Revision: 1185836

URL: http://svn.apache.org/viewvc?rev=1185836&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
- remove unnecessary synchronization
- simplify

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java?rev=1185836&r1=1185835&r2=1185836&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/AbstractItemStateFactory.java
Tue Oct 18 20:24:16 2011
@@ -29,28 +29,21 @@ public abstract class AbstractItemStateF
 
     @Override
     public void addCreationListener(ItemStateCreationListener listener) {
-        synchronized (creationListeners) {
-            creationListeners.add(listener);
-        }
+        creationListeners.add(listener);
     }
 
     @Override
     public void removeCreationListener(ItemStateCreationListener listener) {
-        synchronized (creationListeners) {
-            creationListeners.remove(listener);
-        }
+        creationListeners.remove(listener);
     }
 
     //------------------------------------------------< private | protected >---
 
     /**
-     *
      * @return
      */
     private ItemStateCreationListener[] getListeners() {
-        synchronized (creationListeners) {
-            return creationListeners.toArray(new ItemStateCreationListener[creationListeners.size()]);
-        }
+        return creationListeners.toArray(new ItemStateCreationListener[creationListeners.size()]);
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java?rev=1185836&r1=1185835&r2=1185836&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
Tue Oct 18 20:24:16 2011
@@ -56,7 +56,7 @@ public abstract class ItemState<ENTRY_TY
      * The {@code ItemStateFactory} which is used to create new
      * {@code ItemState} instances.
      */
-    final ItemStateFactory isf;
+    final ItemStateFactory itemStateFactory;
 
     final ItemDefinitionProvider definitionProvider;
 
@@ -64,21 +64,21 @@ public abstract class ItemState<ENTRY_TY
      * Constructs an item state
      *
      * @param entry
-     * @param isf
+     * @param itemStateFactory
      * @param definitionProvider
      */
-    protected ItemState(ENTRY_TYPE entry, ItemStateFactory isf, ItemDefinitionProvider definitionProvider)
{
-        this(getInitialStatus(entry.getParent()), entry, isf, definitionProvider);
+    protected ItemState(ENTRY_TYPE entry, ItemStateFactory itemStateFactory, ItemDefinitionProvider
definitionProvider) {
+        this(getInitialStatus(entry.getParent()), entry, itemStateFactory, definitionProvider);
     }
 
     /**
      * Constructs an item state
      *
      * @param hierarchyEntry
-     * @param isf
+     * @param itemStateFactory
      * @param definitionProvider
      */
-    protected ItemState(Status status, ENTRY_TYPE hierarchyEntry, ItemStateFactory isf,
+    protected ItemState(Status status, ENTRY_TYPE hierarchyEntry, ItemStateFactory itemStateFactory,
             ItemDefinitionProvider definitionProvider) {
         
         if (hierarchyEntry == null) {
@@ -95,22 +95,21 @@ public abstract class ItemState<ENTRY_TY
 
         this.status = status;
         this.hierarchyEntry = hierarchyEntry;
-        this.isf = isf;
+        this.itemStateFactory = itemStateFactory;
         this.definitionProvider = definitionProvider;
     }
 
     private static Status getInitialStatus(NodeEntry parent) {
-        Status status = Status.EXISTING;
         // walk up hierarchy and check if any of the parents is transiently
         // removed, in which case the status must be set to EXISTING_REMOVED.
         while (parent != null) {
             if (parent.getStatus() == Status.EXISTING_REMOVED) {
-                status = Status.EXISTING_REMOVED;
-                break;
+                return  Status.EXISTING_REMOVED;
             }
             parent = parent.getParent();
         }
-        return status;
+
+        return Status.EXISTING;
     }
 
     //----------------------------------------------------------< ItemState >---
@@ -161,7 +160,7 @@ public abstract class ItemState<ENTRY_TY
      * @return the identifier of this item state..
      */
     public ItemId getId() throws RepositoryException {
-        return getHierarchyEntry().getId();
+        return hierarchyEntry.getId();
     }
 
     /**
@@ -172,7 +171,7 @@ public abstract class ItemState<ENTRY_TY
      * @return the identifier of this item state..
      */
     public ItemId getWorkspaceId() throws RepositoryException {
-        return getHierarchyEntry().getWorkspaceId();
+        return hierarchyEntry.getWorkspaceId();
     }
 
     /**
@@ -238,14 +237,11 @@ public abstract class ItemState<ENTRY_TY
         }
 
         // Notify listeners about status change
-        // copy listeners to array to avoid ConcurrentModificationException
-        ItemStateLifeCycleListener[] la;
-        synchronized (listeners) {
-            la = listeners.toArray(new ItemStateLifeCycleListener[listeners.size()]);
-        }
-        for (ItemStateLifeCycleListener aLa : la) {
-            if (aLa != null) {
-                aLa.statusChanged(this, oldStatus);
+        // Copy listeners to array to avoid ConcurrentModificationException
+        ItemStateLifeCycleListener[] la = listeners.toArray(new ItemStateLifeCycleListener[listeners.size()]);
+        for (ItemStateLifeCycleListener listener : la) {
+            if (listener != null) {
+                listener.statusChanged(this, oldStatus);
             }
         }
     }
@@ -275,9 +271,7 @@ public abstract class ItemState<ENTRY_TY
      * @param listener the new listener to be informed on modifications
      */
     public void addListener(ItemStateLifeCycleListener listener) {
-        synchronized (listeners) {
-            listeners.add(listener);
-        }
+        listeners.add(listener);
     }
 
     /**
@@ -286,9 +280,7 @@ public abstract class ItemState<ENTRY_TY
      * @param listener an existing listener
      */
     public void removeListener(ItemStateLifeCycleListener listener) {
-        synchronized (listeners) {
-            listeners.remove(listener);
-        }
+        listeners.remove(listener);
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=1185836&r1=1185835&r2=1185836&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Tue Oct 18 20:24:16 2011
@@ -288,7 +288,7 @@ public class NodeState extends ItemState
      * @return reference property identifiers
      */
     public Iterator<PropertyId> getNodeReferences(Name propertyName, boolean weak)
throws RepositoryException {
-        return isf.getNodeReferences(this, propertyName, weak);
+        return itemStateFactory.getNodeReferences(this, propertyName, weak);
     }
 
     /**



Mime
View raw message