jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1171667 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy: ChildNodeAttic.java ChildPropertyEntriesImpl.java EntryFactory.java NodeEntry.java PropertyEntry.java
Date Fri, 16 Sep 2011 17:00:05 GMT
Author: mduerig
Date: Fri Sep 16 17:00:04 2011
New Revision: 1171667

URL: http://svn.apache.org/viewvc?rev=1171667&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
don't use soft references for property entries   

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntry.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java?rev=1171667&r1=1171666&r2=1171667&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeAttic.java
Fri Sep 16 17:00:04 2011
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.jcr2spi.hi
 import org.apache.jackrabbit.spi.Name;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -53,6 +54,11 @@ class ChildNodeAttic {
     }
 
     List<NodeEntry> get(Name name) {
+        if (attic.isEmpty()) {
+            // shortcut
+            return Collections.emptyList();
+        }
+        
         List<NodeEntry> l = new ArrayList<NodeEntry>();
         for (NodeEntry ne : attic) {
             if (ne.matches(name)) {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java?rev=1171667&r1=1171666&r2=1171667&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java
Fri Sep 16 17:00:04 2011
@@ -16,31 +16,23 @@
  */
 package org.apache.jackrabbit.jcr2spi.hierarchy;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.spi.Name;
 
-import java.util.Map;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
-import java.util.Set;
 import java.util.HashSet;
-import java.util.Collections;
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * {@code ChildPropertyEntriesImpl}...
  */
 public class ChildPropertyEntriesImpl implements ChildPropertyEntries {
-    private final Map<Name, Reference<PropertyEntry>> properties;
-    private final NodeEntry parent;
-    private final EntryFactory factory;
-
-    ChildPropertyEntriesImpl(NodeEntry parent, EntryFactory factory) {
-        properties = new HashMap<Name, Reference<PropertyEntry>>();
-        this.parent = parent;
-        this.factory = factory;
+    private final Map<Name, PropertyEntry> properties;
+
+    ChildPropertyEntriesImpl() {
+        properties = new HashMap<Name, PropertyEntry>();
     }
 
     @Override
@@ -50,28 +42,13 @@ public class ChildPropertyEntriesImpl im
 
     @Override
     public PropertyEntry get(Name propertyName) {
-        Reference<PropertyEntry> ref = properties.get(propertyName);
-        if (ref == null) {
-            // no entry exists with the given name
-            return null;
-        }
-
-        PropertyEntry entry = ref.get();
-        if (entry == null) {
-            // entry has been g-collected -> create new entry and return it.
-            entry = factory.createPropertyEntry(parent, propertyName);
-            add(entry);
-        }
-        return entry;
+        return properties.get(propertyName);
     }
 
     @Override
     public Collection<PropertyEntry> getPropertyEntries() {
         synchronized (properties) {
-            Set<PropertyEntry> entries = new HashSet<PropertyEntry>(properties.size());
-            for (Name propName : properties.keySet()) {
-                entries.add(get(propName));
-            }
+            Set<PropertyEntry> entries = new HashSet<PropertyEntry>(properties.values());
             return Collections.unmodifiableCollection(entries);
         }
     }
@@ -84,8 +61,7 @@ public class ChildPropertyEntriesImpl im
     @Override
     public void add(PropertyEntry propertyEntry) {
         synchronized (properties) {
-            Reference<PropertyEntry> ref = new SoftReference<PropertyEntry>(propertyEntry);
-            properties.put(propertyEntry.getName(), ref);
+            properties.put(propertyEntry.getName(), propertyEntry);
         }
     }
 
@@ -100,7 +76,7 @@ public class ChildPropertyEntriesImpl im
     public boolean remove(PropertyEntry propertyEntry) {
         synchronized (properties) {
             Name pName = propertyEntry.getName();
-            PropertyEntry pe = get(pName);
+            PropertyEntry pe = properties.get(pName);
             if (pe == propertyEntry) {
                 properties.remove(pName);
                 return true;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java?rev=1171667&r1=1171666&r2=1171667&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
Fri Sep 16 17:00:04 2011
@@ -94,10 +94,7 @@ public final class EntryFactory {
     }
 
     public PropertyEntry createPropertyEntry(NodeEntry parent, Name qName) {
-        if (!(parent instanceof NodeEntry)) {
-            throw new IllegalArgumentException();
-        }
-        return PropertyEntry.create(parent, qName, this);
+        return new PropertyEntry(parent, qName, this);
     }
 
     public IdFactory getIdFactory() {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=1171667&r1=1171666&r2=1171667&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
Fri Sep 16 17:00:04 2011
@@ -46,6 +46,8 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.name.PathBuilder;
 import org.apache.jackrabbit.spi.commons.util.Arrays;
 import org.apache.jackrabbit.spi.commons.util.Function1;
+import org.apache.jackrabbit.spi.commons.util.Iterators;
+import org.apache.jackrabbit.spi.commons.util.Predicate1;
 import org.apache.jackrabbit.spi.commons.util.Unchecked;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -171,7 +173,7 @@ public class NodeEntry extends Hierarchy
         super(parent, name, factory);
         this.uniqueID = uniqueID; 
 
-        properties = new ChildPropertyEntriesImpl(this, factory);
+        properties = new ChildPropertyEntriesImpl();
         childNodeEntries = new ChildNodeEntriesImpl(this, factory, null);
 
         propertiesInAttic = new HashMap<Name, PropertyEntry>();
@@ -820,22 +822,18 @@ public class NodeEntry extends Hierarchy
      * PropertyEntries.
      */
     public synchronized Iterator<PropertyEntry> getPropertyEntries() {
-        Collection<PropertyEntry> props;
         if (getStatus() == Status.EXISTING_MODIFIED) {
-            // filter out removed properties
-            props = new ArrayList<PropertyEntry>();
-            // use array since upon validation the entry might be removed.
-            Collection<PropertyEntry> propertyEntries = properties.getPropertyEntries();
-            for (PropertyEntry propEntry : propertyEntries.toArray(new PropertyEntry[propertyEntries.size()]))
{
-                if (EntryValidation.isValidPropertyEntry(propEntry)) {
-                    props.add(propEntry);
+            return Iterators.filterIterator(properties.getPropertyEntries().iterator(), new
Predicate1<PropertyEntry>() {
+                @Override
+                public Boolean apply(PropertyEntry entry) throws Exception {
+                    // filter out removed properties
+                    return !EntryValidation.isValidPropertyEntry(entry);
                 }
-            }
+            });
         } else {
             // no need to filter out properties, there are no removed properties
-            props = properties.getPropertyEntries();
+            return properties.getPropertyEntries().iterator();
         }
-        return props.iterator();
     }
 
     /**
@@ -1449,10 +1447,8 @@ public class NodeEntry extends Hierarchy
             chain.addIterator(new ArrayList<PropertyEntry>(attic).iterator());
         }
         // add props
-        synchronized (properties) {
-            Collection<PropertyEntry> props = properties.getPropertyEntries();
-            chain.addIterator(props.iterator());
-        }
+        chain.addIterator(properties.getPropertyEntries().iterator());
+
         // add childNodeEntries
         synchronized (childNodeEntries) {
             chain.addIterator(childNodeEntries.iterator());

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntry.java?rev=1171667&r1=1171666&r2=1171667&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/PropertyEntry.java
Fri Sep 16 17:00:04 2011
@@ -37,27 +37,14 @@ public class PropertyEntry extends Hiera
     /**
      * Creates a new {@code PropertyEntryImpl}.
      *
-     * @param parent    the parent {@code NodeEntry} where the property
-     *                  belongs to.
+     * @param parent    the parent {@code NodeEntry} where the property belongs to.
      * @param name      the name of the property.
      * @param factory
      */
-    private PropertyEntry(NodeEntry parent, Name name, EntryFactory factory) {
+    PropertyEntry(NodeEntry parent, Name name, EntryFactory factory) {
         super(parent, name, factory);
     }
 
-    /**
-     * Creates a new {@code PropertyEntry}.
-     *
-     * @param parent
-     * @param name
-     * @param factory
-     * @return new {@code PropertyEntry}
-     */
-    static PropertyEntry create(NodeEntry parent, Name name, EntryFactory factory) {
-        return new PropertyEntry(parent, name, factory);
-    }
-
     //------------------------------------------------------< HierarchyEntry >---
     @Override
     PropertyState doResolve() throws RepositoryException {



Mime
View raw message