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 2012/03/09 16:49:56 UTC
svn commit: r1298888 - in
/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit:
./ state/
Author: mduerig
Date: Fri Mar 9 15:49:56 2012
New Revision: 1298888
URL: http://svn.apache.org/viewvc?rev=1298888&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- rename NodeState to TransientNodeState to avoid naming conflict with NodeState interface in Microkernel
Added:
jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java
- copied, changed from r1298846, jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
Removed:
jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
Modified:
jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCache.java
jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCacheImpl.java
Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java?rev=1298888&r1=1298887&r2=1298888&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java Fri Mar 9 15:49:56 2012
@@ -25,7 +25,7 @@ import org.apache.jackrabbit.json.JsonVa
import org.apache.jackrabbit.spi.commons.iterator.Iterators;
import org.apache.jackrabbit.spi.commons.iterator.Predicate;
import org.apache.jackrabbit.spi.commons.iterator.Transformer;
-import org.apache.jackrabbit.state.NodeState;
+import org.apache.jackrabbit.state.TransientNodeState;
import org.apache.jackrabbit.utils.ItemNameMatcher;
import org.apache.jackrabbit.utils.NodeIteratorAdapter;
import org.apache.jackrabbit.utils.PropertyIteratorAdapter;
@@ -57,24 +57,24 @@ import java.util.Iterator;
import java.util.Map.Entry;
public class NodeImpl extends ItemImpl implements Node {
- private final NodeState nodeState;
+ private final TransientNodeState state;
static boolean exist(Context sessionContext, Path path) {
- return NodeState.hasNodeState(sessionContext, path);
+ return TransientNodeState.hasNodeState(sessionContext, path);
}
static Node create(Context sessionContext, Path path) throws PathNotFoundException {
- NodeState nodeState = getNodeState(sessionContext, path);
- return new NodeImpl(sessionContext, nodeState);
+ TransientNodeState state = getNodeState(sessionContext, path);
+ return new NodeImpl(sessionContext, state);
}
- static Node create(Context sessionContext, NodeState nodeState) {
- return new NodeImpl(sessionContext, nodeState);
+ static Node create(Context sessionContext, TransientNodeState state) {
+ return new NodeImpl(sessionContext, state);
}
- private NodeImpl(Context sessionContext, NodeState nodeState) {
+ private NodeImpl(Context sessionContext, TransientNodeState state) {
super(sessionContext);
- this.nodeState = nodeState;
+ this.state = state;
}
//------------------------------------------< Item/Node >---
@@ -86,7 +86,7 @@ public class NodeImpl extends ItemImpl i
@Override
public String getName() throws RepositoryException {
- return nodeState.getName();
+ return state.getName();
}
@Override
@@ -101,7 +101,7 @@ public class NodeImpl extends ItemImpl i
@Override
public Node getParent() throws RepositoryException {
- if (nodeState.isRoot()) {
+ if (state.isRoot()) {
throw new ItemNotFoundException("Root has no parent");
}
@@ -120,19 +120,19 @@ public class NodeImpl extends ItemImpl i
@Override
public boolean isNew() {
- return nodeState.isNew();
+ return state.isNew();
}
@Override
public boolean isModified() {
- return nodeState.isModified();
+ return state.isModified();
}
@Override
public Node addNode(String relPath) throws RepositoryException {
Path newPath = path().concat(relPath);
- NodeState parentState = getNodeState(sessionContext, newPath.getParent());
- NodeState childState = parentState.addNode(newPath.getName());
+ TransientNodeState parentState = getNodeState(sessionContext, newPath.getParent());
+ TransientNodeState childState = parentState.addNode(newPath.getName());
return create(sessionContext, childState);
}
@@ -145,38 +145,38 @@ public class NodeImpl extends ItemImpl i
@Override
public void remove() throws RepositoryException {
- nodeState.remove();
+ state.remove();
}
@Override
public Property setProperty(String name, Value value, int type) throws RepositoryException {
- nodeState.setProperty(name, ValueConverter.toJsonValue(value));
+ state.setProperty(name, ValueConverter.toJsonValue(value));
return getProperty(name);
}
@Override
public Property setProperty(String name, Value[] values, int type) throws RepositoryException {
- nodeState.setProperty(name, ValueConverter.toJsonValue(values));
+ state.setProperty(name, ValueConverter.toJsonValue(values));
return getProperty(name);
}
@Override
public void setPrimaryType(String nodeTypeName) throws RepositoryException {
- nodeState.setProperty("jcr:primaryType", JsonAtom.string(nodeTypeName));
+ state.setProperty("jcr:primaryType", JsonAtom.string(nodeTypeName));
}
@Override
public void addMixin(String mixinName) throws RepositoryException {
- JsonValue mixins = nodeState.getPropertyValue("jcr:mixinTypes");
+ JsonValue mixins = state.getPropertyValue("jcr:mixinTypes");
mixins.asArray().add(JsonAtom.string(mixinName));
- nodeState.setProperty("jcr:mixinTypes", mixins);
+ state.setProperty("jcr:mixinTypes", mixins);
}
@Override
public void removeMixin(String mixinName) throws RepositoryException {
- JsonValue mixins = nodeState.getPropertyValue("jcr:mixinTypes");
+ JsonValue mixins = state.getPropertyValue("jcr:mixinTypes");
mixins.asArray().remove(JsonAtom.string(mixinName));
- nodeState.setProperty("jcr:mixinTypes", mixins);
+ state.setProperty("jcr:mixinTypes", mixins);
}
@@ -292,20 +292,20 @@ public class NodeImpl extends ItemImpl i
@Override
public boolean hasNodes() throws RepositoryException {
- return nodeState.hasChildNodeStates();
+ return state.hasChildNodeStates();
}
@Override
public NodeIterator getNodes() throws RepositoryException {
- Iterator<NodeState> childNodeStates = nodeState.getChildNodeStates();
+ Iterator<TransientNodeState> childNodeStates = state.getChildNodeStates();
return new NodeIteratorAdapter(nodeIterator(childNodeStates));
}
@Override
public NodeIterator getNodes(final String namePattern) throws RepositoryException {
- Iterator<NodeState> childNodeStates = nodeState.getChildNodeStates(new Predicate<NodeState>() {
+ Iterator<TransientNodeState> childNodeStates = state.getChildNodeStates(new Predicate<TransientNodeState>() {
@Override
- public boolean evaluate(NodeState nodeState) {
+ public boolean evaluate(TransientNodeState nodeState) {
return ItemNameMatcher.matches(nodeState.getName(), namePattern);
}
});
@@ -315,9 +315,9 @@ public class NodeImpl extends ItemImpl i
@Override
public NodeIterator getNodes(final String[] nameGlobs) throws RepositoryException {
- Iterator<NodeState> childNodeStates = nodeState.getChildNodeStates(new Predicate<NodeState>() {
+ Iterator<TransientNodeState> childNodeStates = state.getChildNodeStates(new Predicate<TransientNodeState>() {
@Override
- public boolean evaluate(NodeState nodeState) {
+ public boolean evaluate(TransientNodeState nodeState) {
return ItemNameMatcher.matches(nodeState.getName(), nameGlobs);
}
});
@@ -337,18 +337,18 @@ public class NodeImpl extends ItemImpl i
@Override
public boolean hasProperties() throws RepositoryException {
- return nodeState.hasProperties();
+ return state.hasProperties();
}
@Override
public PropertyIterator getProperties() throws RepositoryException {
- Iterator<Entry<String,JsonValue>> properties = nodeState.getProperties();
+ Iterator<Entry<String,JsonValue>> properties = state.getProperties();
return new PropertyIteratorAdapter(propertyIterator(properties));
}
@Override
public PropertyIterator getProperties(final String namePattern) throws RepositoryException {
- Iterator<Entry<String, JsonValue>> properties = nodeState.getProperties(
+ Iterator<Entry<String, JsonValue>> properties = state.getProperties(
new Predicate<Entry<String, JsonValue>>() {
@Override
public boolean evaluate(Entry<String, JsonValue> entry) {
@@ -361,7 +361,7 @@ public class NodeImpl extends ItemImpl i
@Override
public PropertyIterator getProperties(final String[] nameGlobs) throws RepositoryException {
- Iterator<Entry<String, JsonValue>> propertyNames = nodeState.getProperties(
+ Iterator<Entry<String, JsonValue>> propertyNames = state.getProperties(
new Predicate<Entry<String, JsonValue>>() {
@Override
public boolean evaluate(Entry<String, JsonValue> entry) {
@@ -577,24 +577,24 @@ public class NodeImpl extends ItemImpl i
//------------------------------------------< private >---
- private static NodeState getNodeState(Context sessionContext, Path path) throws PathNotFoundException {
- NodeState nodeState = NodeState.getNodeState(sessionContext, path);
- if (nodeState == null) {
+ private static TransientNodeState getNodeState(Context sessionContext, Path path) throws PathNotFoundException {
+ TransientNodeState state = TransientNodeState.getNodeState(sessionContext, path);
+ if (state == null) {
throw new PathNotFoundException(path.toJcrPath());
}
- return nodeState;
+ return state;
}
private Path path() {
- return nodeState.getPath();
+ return state.getPath();
}
- private Iterator<Node> nodeIterator(Iterator<NodeState> childNodeStates) {
- return Iterators.transformIterator(childNodeStates, new Transformer<NodeState, Node>() {
+ private Iterator<Node> nodeIterator(Iterator<TransientNodeState> childNodeStates) {
+ return Iterators.transformIterator(childNodeStates, new Transformer<TransientNodeState, Node>() {
@Override
- public Node transform(NodeState nodeState) {
- return NodeImpl.create(sessionContext, nodeState);
+ public Node transform(TransientNodeState state) {
+ return NodeImpl.create(sessionContext, state);
}
});
}
@@ -603,7 +603,7 @@ public class NodeImpl extends ItemImpl i
return Iterators.transformIterator(properties, new Transformer<Entry<String, JsonValue>, Property>() {
@Override
public Property transform(Entry<String, JsonValue> entry) {
- return PropertyImpl.create(sessionContext, nodeState, entry.getKey(), entry.getValue());
+ return PropertyImpl.create(sessionContext, state, entry.getKey(), entry.getValue());
}
});
}
Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java?rev=1298888&r1=1298887&r2=1298888&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java Fri Mar 9 15:49:56 2012
@@ -21,7 +21,7 @@ package org.apache.jackrabbit;
import org.apache.jackrabbit.SessionImpl.Context;
import org.apache.jackrabbit.json.JsonValue;
-import org.apache.jackrabbit.state.NodeState;
+import org.apache.jackrabbit.state.TransientNodeState;
import org.apache.jackrabbit.utils.ValueConverter;
import javax.jcr.Binary;
@@ -43,19 +43,19 @@ import java.math.BigDecimal;
import java.util.Calendar;
public class PropertyImpl extends ItemImpl implements Property {
- private final NodeState parentState;
+ private final TransientNodeState parentState;
private final String name;
private final JsonValue value;
public static boolean exist(Context sessionContext, Path path) {
- NodeState parentState = NodeState.getNodeState(sessionContext, path.getParent());
+ TransientNodeState parentState = TransientNodeState.getNodeState(sessionContext, path.getParent());
return parentState != null && parentState.hasProperty(path.getName());
}
static Property create(Context sessionContext, Path path) throws PathNotFoundException,
ItemNotFoundException {
- NodeState parentState = NodeState.getNodeState(sessionContext, path.getParent());
+ TransientNodeState parentState = TransientNodeState.getNodeState(sessionContext, path.getParent());
if (parentState == null) {
throw new PathNotFoundException(path.toJcrPath());
}
@@ -65,11 +65,11 @@ public class PropertyImpl extends ItemIm
return new PropertyImpl(sessionContext, parentState, name, value);
}
- static Property create(Context sessionContext, NodeState parentState, String name, JsonValue value) {
+ static Property create(Context sessionContext, TransientNodeState parentState, String name, JsonValue value) {
return new PropertyImpl(sessionContext, parentState, name, value);
}
- private PropertyImpl(Context sessionContext, NodeState parentState, String name, JsonValue value) {
+ private PropertyImpl(Context sessionContext, TransientNodeState parentState, String name, JsonValue value) {
super(sessionContext);
this.parentState = parentState;
this.name = name;
Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java?rev=1298888&r1=1298887&r2=1298888&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java Fri Mar 9 15:49:56 2012
@@ -23,7 +23,7 @@ import org.apache.jackrabbit.configurati
import org.apache.jackrabbit.mk.api.MicroKernel;
import org.apache.jackrabbit.security.Authenticator;
import org.apache.jackrabbit.security.CredentialsInfo;
-import org.apache.jackrabbit.state.NodeState;
+import org.apache.jackrabbit.state.TransientNodeState;
import org.apache.jackrabbit.state.NodeStateCache;
import org.apache.jackrabbit.state.TransientSpace;
import org.xml.sax.ContentHandler;
@@ -256,7 +256,7 @@ public class SessionImpl implements Sess
checkLive();
Path sourcePath = Path.create(workspaceName, srcAbsPath);
- NodeState sourceParent = NodeState.getNodeState(sessionContext, sourcePath.getParent());
+ TransientNodeState sourceParent = TransientNodeState.getNodeState(sessionContext, sourcePath.getParent());
if (sourceParent == null) {
throw new PathNotFoundException(srcAbsPath);
}
Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCache.java?rev=1298888&r1=1298887&r2=1298888&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCache.java (original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCache.java Fri Mar 9 15:49:56 2012
@@ -22,8 +22,8 @@ package org.apache.jackrabbit.state;
import org.apache.jackrabbit.Path;
public interface NodeStateCache {
- NodeState get(Path path);
- void put(Path path, NodeState nodeState);
+ TransientNodeState get(Path path);
+ void put(Path path, TransientNodeState state);
void remove(Path path);
void clear();
}
Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCacheImpl.java?rev=1298888&r1=1298887&r2=1298888&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCacheImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeStateCacheImpl.java Fri Mar 9 15:49:56 2012
@@ -38,12 +38,12 @@ public class NodeStateCacheImpl implemen
private static final NodeStateCache NO_CACHE = new NodeStateCache() {
@Override
- public NodeState get(Path path) {
+ public TransientNodeState get(Path path) {
return null;
}
@Override
- public void put(Path path, NodeState nodeState) { }
+ public void put(Path path, TransientNodeState state) { }
@Override
public void remove(Path path) { }
@@ -52,20 +52,20 @@ public class NodeStateCacheImpl implemen
public void clear() { }
};
- private final Map<Path, NodeState> cache;
+ private final Map<Path, TransientNodeState> cache;
public NodeStateCacheImpl(int size) {
cache = Unchecked.cast(new LRUMap(size));
}
@Override
- public NodeState get(Path path) {
+ public TransientNodeState get(Path path) {
return cache.get(path);
}
@Override
- public void put(Path path, NodeState nodeState) {
- cache.put(path, nodeState);
+ public void put(Path path, TransientNodeState state) {
+ cache.put(path, state);
}
@Override
Copied: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java (from r1298846, jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java?p2=jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java&p1=jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java&r1=1298846&r2=1298888&rev=1298888&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java (original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java Fri Mar 9 15:49:56 2012
@@ -40,14 +40,14 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-public class NodeState {
+public class TransientNodeState {
private final Context sessionContext;
private final Provider<NodeDelta> nodeDelta;
private String revision;
private JsonObject jsonObject;
- private NodeState(Context sessionContext, final NodeDelta nodeDelta) {
+ private TransientNodeState(Context sessionContext, final NodeDelta nodeDelta) {
this.sessionContext = sessionContext;
this.nodeDelta = new Provider<NodeDelta>() {
@@ -82,7 +82,7 @@ public class NodeState {
return nodeDelta.get().isTransient();
}
- public NodeState addNode(String name) throws ItemExistsException {
+ public TransientNodeState addNode(String name) throws ItemExistsException {
NodeDelta child = nodeDelta.get().addNode(name);
return getNodeState(sessionContext, child);
}
@@ -106,7 +106,7 @@ public class NodeState {
return getChildNodeStates().hasNext();
}
- public Iterator<NodeState> getChildNodeStates() {
+ public Iterator<TransientNodeState> getChildNodeStates() {
Map<String, JsonValue> childEntries = getJsonObject().value();
Iterator<Entry<String, JsonValue>> childNodeEntries =
@@ -118,18 +118,18 @@ public class NodeState {
}
});
- Iterator<NodeState> childNodeStates = Iterators.transformIterator(childNodeEntries,
- new Transformer<Entry<String, JsonValue>, NodeState>() {
+ Iterator<TransientNodeState> childNodeStates = Iterators.transformIterator(childNodeEntries,
+ new Transformer<Entry<String, JsonValue>, TransientNodeState>() {
@Override
- public NodeState transform(Entry<String, JsonValue> entry) {
+ public TransientNodeState transform(Entry<String, JsonValue> entry) {
return getNodeState(sessionContext, nodeDelta.get().getNode(entry.getKey()));
}
});
- Iterator<NodeState> modifiedNodeStates = Iterators.transformIterator(nodeDelta.get().getNodes(),
- new Transformer<NodeDelta, NodeState>() {
+ Iterator<TransientNodeState> modifiedNodeStates = Iterators.transformIterator(nodeDelta.get().getNodes(),
+ new Transformer<NodeDelta, TransientNodeState>() {
@Override
- public NodeState transform(NodeDelta delta) {
+ public TransientNodeState transform(NodeDelta delta) {
return getNodeState(sessionContext, delta);
}
});
@@ -137,7 +137,7 @@ public class NodeState {
return Iterators.iteratorChain(childNodeStates, modifiedNodeStates);
}
- public Iterator<NodeState> getChildNodeStates(Predicate<NodeState> condition) {
+ public Iterator<TransientNodeState> getChildNodeStates(Predicate<TransientNodeState> condition) {
return Iterators.filterIterator(getChildNodeStates(), condition);
}
@@ -191,7 +191,7 @@ public class NodeState {
nodeDelta.get().setValue(name, null);
}
- public static NodeState getNodeState(Context sessionContext, Path path) {
+ public static TransientNodeState getNodeState(Context sessionContext, Path path) {
NodeDelta delta = sessionContext.getTransientSpace().getNodeDelta(path);
return delta == null ? null : getNodeState(sessionContext, delta);
}
@@ -223,16 +223,16 @@ public class NodeState {
return sessionContext.getTransientSpace();
}
- private static NodeState getNodeState(Context sessionContext, NodeDelta nodeDelta) {
+ private static TransientNodeState getNodeState(Context sessionContext, NodeDelta nodeDelta) {
NodeStateCache cache = sessionContext.getNodeStateCache();
Path path = nodeDelta.getPath();
- NodeState nodeState = cache.get(path);
- if (nodeState == null) {
- nodeState = new NodeState(sessionContext, nodeDelta);
- cache.put(path, nodeState);
+ TransientNodeState state = cache.get(path);
+ if (state == null) {
+ state = new TransientNodeState(sessionContext, nodeDelta);
+ cache.put(path, state);
}
- return nodeState;
+ return state;
}
private static boolean isNode(JsonValue value) {