You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by md...@apache.org on 2011/09/16 19:11:04 UTC
svn commit: r1171677 - in
/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy:
ChildNodeEntries.java ChildNodeEntriesImpl.java ChildPropertyEntries.java
ChildPropertyEntriesImpl.java NodeEntry.java
Author: mduerig
Date: Fri Sep 16 17:11:04 2011
New Revision: 1171677
URL: http://svn.apache.org/viewvc?rev=1171677&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
refactor: remove ChildNodeEntries and ChildPropertyEntries interfaces
Added:
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java
- copied, changed from r1171436, jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntries.java
- copied, changed from r1171667, jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java
Modified:
jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.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/NodeEntry.java
Copied: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java (from r1171436, jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java?p2=jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java&p1=jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java&r1=1171436&r2=1171677&rev=1171677&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntries.java Fri Sep 16 17:11:04 2011
@@ -38,11 +38,11 @@ import java.util.Map;
import java.util.NoSuchElementException;
/**
- * {@code ChildNodeEntriesImpl} implements a memory sensitive implementation
- * of the {@code ChildNodeEntries} interface.
+ * {@code ChildNodeEntries} represents a collection of {@code NodeEntry}s that
+ * also maintains the index values of same-name siblings on insertion and removal.
*/
-final class ChildNodeEntriesImpl implements ChildNodeEntries {
- private static final Logger log = LoggerFactory.getLogger(ChildNodeEntriesImpl.class);
+final class ChildNodeEntries {
+ private static final Logger log = LoggerFactory.getLogger(ChildNodeEntries.class);
private boolean complete;
@@ -67,12 +67,12 @@ final class ChildNodeEntriesImpl impleme
* @param parent
* @param factory
* @param childNodeInfos The complete list of child infos or
- * {@code null} if an 'empty' ChildNodeEntriesImpl should be created.
+ * {@code null} if an 'empty' ChildNodeEntries should be created.
* In the latter case, individual child entries will be added on demand
* and the complete list will be retrieved only to answer {@link #iterator()}
* if the passed boolean is {@code true}.
*/
- ChildNodeEntriesImpl(NodeEntry parent, EntryFactory factory, Iterator<ChildInfo> childNodeInfos) {
+ ChildNodeEntries(NodeEntry parent, EntryFactory factory, Iterator<ChildInfo> childNodeInfos) {
this.parent = parent;
this.factory = factory;
@@ -112,14 +112,22 @@ final class ChildNodeEntriesImpl impleme
return prevLn == null ? null : prevLn.getNodeEntry();
}
- @Override
+ /**
+ * @return {@code true} if this {@code ChildNodeEntries} have
+ * been updated or completely loaded without being invalidated in the
+ * mean time.
+ */
public boolean isComplete() {
return parent.getStatus() != Status.INVALIDATED && complete ||
parent.getStatus() == Status.NEW ||
Status.isTerminal(parent.getStatus());
}
- @Override
+ /**
+ * Reloads this {@code ChildNodeEntries} object.
+ *
+ * @throws RepositoryException
+ */
public synchronized void reload() throws RepositoryException {
if (isComplete()) {
// nothing to do
@@ -175,7 +183,12 @@ final class ChildNodeEntriesImpl impleme
complete = true;
}
- @Override
+ /**
+ * Returns an unmodifiable iterator over all NodeEntry objects present in
+ * this ChildNodeEntries collection irrespective of their status.
+ *
+ * @return Iterator over all NodeEntry object
+ */
public Iterator<NodeEntry> iterator() {
List<NodeEntry> l = new ArrayList<NodeEntry>(entries.size());
for (Iterator<LinkedEntries.LinkNode> it = entries.linkNodeIterator(); it.hasNext();) {
@@ -184,12 +197,28 @@ final class ChildNodeEntriesImpl impleme
return Collections.unmodifiableList(l).iterator();
}
- @Override
+ /**
+ * Returns a {@code List} of {@code NodeEntry}s for the
+ * given {@code nodeName}. This method does <b>not</b> filter out
+ * removed {@code NodeEntry}s.
+ *
+ * @param nodeName the child node name.
+ * @return same name sibling nodes with the given {@code nodeName}.
+ */
public List<NodeEntry> get(Name nodeName) {
return entriesByName.getList(nodeName);
}
- @Override
+ /**
+ * Returns the {@code NodeEntry} with the given
+ * {@code nodeName} and {@code index}. Note, that this method
+ * does <b>not</b> filter out removed {@code NodeEntry}s.
+ *
+ * @param nodeName name of the child node entry.
+ * @param index the index of the child node entry.
+ * @return the {@code NodeEntry} or {@code null} if there
+ * is no such {@code NodeEntry}.
+ */
public NodeEntry get(Name nodeName, int index) {
if (index < Path.INDEX_DEFAULT) {
throw new IllegalArgumentException("index is 1-based");
@@ -197,7 +226,15 @@ final class ChildNodeEntriesImpl impleme
return entriesByName.getNodeEntry(nodeName, index);
}
- @Override
+ /**
+ * Return the {@code NodeEntry} that matches the given nodeName and
+ * uniqueID or {@code null} if no matching entry can be found.
+ *
+ * @param nodeName
+ * @param uniqueID
+ * @return
+ * @throws IllegalArgumentException if the given uniqueID is null.
+ */
public NodeEntry get(Name nodeName, String uniqueID) {
if (uniqueID == null || nodeName == null) {
throw new IllegalArgumentException();
@@ -216,12 +253,22 @@ final class ChildNodeEntriesImpl impleme
*
* @param cne the {@code NodeEntry} to add.
*/
- @Override
public synchronized void add(NodeEntry cne) {
internalAdd(cne, Path.INDEX_UNDEFINED);
}
- @Override
+ /**
+ * Adds a {@code NodeEntry}.<br>
+ * Note the following special cases:
+ * <ol>
+ * <li>If an entry with the given index already exists, the the new sibling
+ * is inserted before.</li>
+ * <li>If the given index is bigger that the last entry in the siblings list,
+ * intermediate entries will be created.</li>
+ * </ol>
+ *
+ * @param cne the {@code NodeEntry} to add.
+ */
public synchronized void add(NodeEntry cne, int index) {
if (index < Path.INDEX_UNDEFINED) {
throw new IllegalArgumentException("Invalid index" + index);
@@ -229,7 +276,13 @@ final class ChildNodeEntriesImpl impleme
internalAdd(cne, index);
}
- @Override
+ /**
+ * Adds a the new {@code NodeEntry} before {@code beforeEntry}.
+ *
+ * @param entry
+ * @param index
+ * @param beforeEntry
+ */
public synchronized void add(NodeEntry entry, int index, NodeEntry beforeEntry) {
if (beforeEntry != null) {
// the link node where the new entry is ordered before
@@ -303,7 +356,6 @@ final class ChildNodeEntriesImpl impleme
* @param childEntry the entry to be removed.
* @return the removed entry or {@code null} if there is no such entry.
*/
- @Override
public synchronized NodeEntry remove(NodeEntry childEntry) {
LinkedEntries.LinkNode ln = entries.removeNodeEntry(childEntry);
if (ln != null) {
@@ -315,20 +367,19 @@ final class ChildNodeEntriesImpl impleme
}
/**
- * Reorders an existing {@code NodeState} before another
- * {@code NodeState}. If {@code beforeNode} is
- * {@code null} {@code insertNode} is moved to the end of the
+ * Reorders an existing {@code NodeEntry} before another
+ * {@code NodeEntry}. If {@code beforeEntry} is
+ * {@code null} {@code insertEntry} is moved to the end of the
* child node entries.
*
* @param insertEntry the NodeEntry to move.
- * @param beforeEntry the NodeEntry where {@code insertNode} is
+ * @param beforeEntry the NodeEntry where {@code insertEntry} is
* reordered to.
- * @return the NodeEntry that followed the 'insertNode' before the reordering.
- * @throws NoSuchElementException if {@code insertNode} or
- * {@code beforeNode} does not have a {@code NodeEntry}
+ * @return the NodeEntry that followed the 'insertEntry' before the reordering.
+ * @throws NoSuchElementException if {@code insertEntry} or
+ * {@code beforeEntry} does not have a {@code NodeEntry}
* in this {@code ChildNodeEntries}.
*/
- @Override
public synchronized NodeEntry reorder(NodeEntry insertEntry, NodeEntry beforeEntry) {
// the link node to move
LinkedEntries.LinkNode insertLN = entries.getLinkNode(insertEntry);
@@ -348,7 +399,19 @@ final class ChildNodeEntriesImpl impleme
return previousBefore;
}
- @Override
+ /**
+ * Reorders an existing {@code NodeEntry} after another
+ * {@code NodeEntry}. If {@code afterEntry} is
+ * {@code null} {@code insertEntry} is moved to the beginning of
+ * the child node entries.
+ *
+ * @param insertEntry the NodeEntry to move.
+ * @param afterEntry the NodeEntry where {@code insertEntry} is
+ * reordered behind.
+ * @throws NoSuchElementException if {@code insertEntry} or
+ * {@code afterEntry} does not have a {@code NodeEntry}
+ * in this {@code ChildNodeEntries}.
+ */
public void reorderAfter(NodeEntry insertEntry, NodeEntry afterEntry) {
// the link node to move
LinkedEntries.LinkNode insertLN = entries.getLinkNode(insertEntry);
Copied: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntries.java (from r1171667, 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/ChildPropertyEntries.java?p2=jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntries.java&p1=jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildPropertyEntriesImpl.java&r1=1171667&r2=1171677&rev=1171677&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/ChildPropertyEntries.java Fri Sep 16 17:11:04 2011
@@ -28,24 +28,40 @@ import java.util.Set;
/**
* {@code ChildPropertyEntriesImpl}...
*/
-public class ChildPropertyEntriesImpl implements ChildPropertyEntries {
+public class ChildPropertyEntries {
private final Map<Name, PropertyEntry> properties;
- ChildPropertyEntriesImpl() {
+ ChildPropertyEntries() {
properties = new HashMap<Name, PropertyEntry>();
}
- @Override
+ /**
+ * Returns true if a property entry with the given name exists.
+ *
+ * @param propertyName
+ * @return true if a property entry with the given name exists.
+ */
public boolean contains(Name propertyName) {
return properties.containsKey(propertyName);
}
- @Override
+ /**
+ * Return the PropertyEntry with the given {@code Name} or
+ * {@code null}.
+ *
+ * @param propertyName
+ * @return
+ */
public PropertyEntry get(Name propertyName) {
return properties.get(propertyName);
}
- @Override
+ /**
+ * Returns an unmodifiable collection containing all {@code PropertyEntry}
+ * objects present.
+ *
+ * @return Collection of all {@code PropertyEntry} objects present.
+ */
public Collection<PropertyEntry> getPropertyEntries() {
synchronized (properties) {
Set<PropertyEntry> entries = new HashSet<PropertyEntry>(properties.values());
@@ -53,26 +69,45 @@ public class ChildPropertyEntriesImpl im
}
}
- @Override
+ /**
+ * Returns an unmodifiable collection containing all existing property names.
+ *
+ * @return Collection of {@code Name}
+ */
public Collection<Name> getPropertyNames() {
return Collections.unmodifiableCollection(properties.keySet());
}
- @Override
+ /**
+ * Adds the new {@code PropertyEntry} to this {@code ChildPropertyEntries}.
+ *
+ * @param propertyEntry
+ */
public void add(PropertyEntry propertyEntry) {
synchronized (properties) {
properties.put(propertyEntry.getName(), propertyEntry);
}
}
- @Override
+ /**
+ * Adds all {@code PropertyEntry}s from the given collection to this
+ * {@code ChildPropertyEntries}.
+ *
+ * @param propertyEntries
+ */
public void addAll(Collection<PropertyEntry> propertyEntries) {
for (PropertyEntry pe : propertyEntries) {
add(pe);
}
}
- @Override
+ /**
+ * Remove the collection entry with the given {@code Name}.
+ *
+ * @param propertyEntry
+ * @return true If this {@code ChildPropertyEntries} contained the
+ * given entry. False otherwise.
+ */
public boolean remove(PropertyEntry propertyEntry) {
synchronized (properties) {
Name pName = propertyEntry.getName();
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=1171677&r1=1171676&r2=1171677&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:11:04 2011
@@ -86,7 +86,7 @@ public class NodeEntry extends Hierarchy
/**
* Insertion-ordered collection of NodeEntry objects.
*/
- private final ChildNodeEntriesImpl childNodeEntries;
+ private final ChildNodeEntries childNodeEntries;
/**
* Map used to remember transiently removed or moved childNodeEntries, that
@@ -173,8 +173,8 @@ public class NodeEntry extends Hierarchy
super(parent, name, factory);
this.uniqueID = uniqueID;
- properties = new ChildPropertyEntriesImpl();
- childNodeEntries = new ChildNodeEntriesImpl(this, factory, null);
+ properties = new ChildPropertyEntries();
+ childNodeEntries = new ChildNodeEntries(this, factory, null);
propertiesInAttic = new HashMap<Name, PropertyEntry>();
childNodeAttic = new ChildNodeAttic();
@@ -1812,7 +1812,7 @@ public class NodeEntry extends Hierarchy
private void dispose(boolean persisted) {
if (!persisted) {
NodeEntry ne = NodeEntry.this;
- ChildNodeEntriesImpl parentCNEs = parent.childNodeEntries;
+ ChildNodeEntries parentCNEs = parent.childNodeEntries;
parentCNEs.reorderAfter(ne, revertInfo.oldPredecessor);
try {
if (oldIndex != ne.getIndex()) {