jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1171155 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ query/ version/
Date Thu, 15 Sep 2011 16:00:16 GMT
Author: mduerig
Date: Thu Sep 15 16:00:15 2011
New Revision: 1171155

URL: http://svn.apache.org/viewvc?rev=1171155&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
refactor: specialise ItemManager to avoid down casting

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java?rev=1171155&r1=1171154&r2=1171155&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java
Thu Sep 15 16:00:15 2011
@@ -18,10 +18,14 @@ package org.apache.jackrabbit.jcr2spi;
 
 import org.apache.commons.collections.map.LRUMap;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import java.util.Map;
 
@@ -42,19 +46,45 @@ public class ItemCache implements ItemLi
     //----------------------------------------------------------< ItemCache >---
 
     /**
-    * Returns the cached {@code Item} that belongs to the given
-    * {@code ItemState} or {@code null} if the cache does not
-    * contain that {@code Item}.
-    *
-    * @param state State of the item that should be retrieved.
-    * @return The item reference stored in the corresponding cache entry
-    * or {@code null} if there's no corresponding cache entry.
-    */
+     * Returns the cached {@code Item} that belongs to the given
+     * {@code ItemState} or {@code null} if the cache does not
+     * contain that {@code Item}.
+     *
+     * @param state State of the item that should be retrieved.
+     * @return The item reference stored in the corresponding cache entry
+     * or {@code null} if there's no corresponding cache entry.
+     */
     public Item getItem(ItemState<?> state) {
         return cache.get(state);
     }
 
     /**
+     * Returns the cached {@code Node} that belongs to the given
+     * {@code NodeState} or {@code null} if the cache does not
+     * contain that {@code Node}.
+     *
+     * @param state State of the node that should be retrieved.
+     * @return The node reference stored in the corresponding cache entry
+     * or {@code null} if there's no corresponding cache entry.
+     */
+    public Node getNode(NodeState state) {
+        return (Node) cache.get(state);
+    }
+
+    /**
+     * Returns the cached {@code Property} that belongs to the given
+     * {@code PropertyState} or {@code null} if the cache does not
+     * contain that {@code Property}.
+     *
+     * @param state State of the property that should be retrieved.
+     * @return The property reference stored in the corresponding cache entry
+     * or {@code null} if there's no corresponding cache entry.
+     */
+    public Property getProperty(PropertyState state) {
+        return (Property) cache.get(state);
+    }
+
+    /**
      * Clear all entries in the ItemCache and free resources.
      */
     public void clear() {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=1171155&r1=1171154&r2=1171155&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Thu Sep 15 16:00:15 2011
@@ -115,7 +115,7 @@ public abstract class ItemImpl<STATE_TYP
         }
 
         NodeEntry parentEntry = getItemState().getHierarchyEntry().getParent();
-        return (Node) getItemManager().getItem(parentEntry);
+        return getItemManager().getItem(parentEntry);
     }
 
     @Override

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java?rev=1171155&r1=1171154&r2=1171155&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManager.java
Thu Sep 15 16:00:15 2011
@@ -198,7 +198,7 @@ public class ItemManager implements Item
     public synchronized Node getNode(Path path) throws RepositoryException {
         NodeEntry nodeEntry = hierarchyManager.getNodeEntry(path);
         try {
-            return (Node) getItem(nodeEntry);
+            return getItem(nodeEntry);
         } catch (ItemNotFoundException e) {
             throw new PathNotFoundException(LogUtil.safeGetJCRPath(path, session.getNamePathResolver()));
         }
@@ -213,37 +213,68 @@ public class ItemManager implements Item
     public synchronized Property getProperty(Path path) throws RepositoryException {
         PropertyEntry propertyEntry = hierarchyManager.getPropertyEntry(path);
         try {
-            return (Property) getItem(propertyEntry);
+            return getItem(propertyEntry);
         } catch (ItemNotFoundException e) {
             throw new PathNotFoundException(LogUtil.safeGetJCRPath(path, session.getNamePathResolver()));
         }
     }
 
     /**
-     * @param hierarchyEntry
+     * @param nodeEntry
      * @return
-     * @throws ItemNotFoundException
      * @throws RepositoryException
      */
-    public Item getItem(HierarchyEntry<?> hierarchyEntry) throws RepositoryException
{
+    public Node getItem(NodeEntry nodeEntry) throws RepositoryException {
         session.checkIsAlive();
-        ItemState<?> state = hierarchyEntry.getItemState();
+        NodeState state = nodeEntry.getItemState();
         if (!state.isValid()) {
             throw new ItemNotFoundException(LogUtil.safeGetJCRPath(state, session.getNamePathResolver()));
         }
 
-        // first try to access item from cache
-        Item item = itemCache.getItem(state);
+        // first try to access node from cache
+        Node node = itemCache.getNode(state);
         // not yet in cache, need to create instance
-        if (item == null) {
-            // create instance of item
-            if (hierarchyEntry.denotesNode()) {
-                item = createNodeInstance((NodeState) state);
-            } else {
-                item = createPropertyInstance((PropertyState) state);
-            }
+        if (node == null) {
+        // create instance of node
+            node = createNodeInstance(state);
+        }
+        return node;
+    }
+
+    /**
+     * @param propertyEntry
+     * @return
+     * @throws RepositoryException
+     */
+    public Property getItem(PropertyEntry propertyEntry) throws RepositoryException {
+        session.checkIsAlive();
+        PropertyState state = propertyEntry.getItemState();
+        if (!state.isValid()) {
+            throw new ItemNotFoundException(LogUtil.safeGetJCRPath(state, session.getNamePathResolver()));
+        }
+
+        // first try to access property from cache
+        Property property = itemCache.getProperty(state);
+        // not yet in cache, need to create instance
+        if (property == null) {
+        // create instance of property
+            property = createPropertyInstance(state);
+        }
+        return property;
+    }
+
+    /**
+     * @param hierarchyEntry
+     * @return
+     * @throws ItemNotFoundException
+     * @throws RepositoryException
+     */
+    public Item getItem(HierarchyEntry<?> hierarchyEntry) throws RepositoryException
{
+        if (hierarchyEntry.denotesNode()) {
+            return getItem((NodeEntry) hierarchyEntry);
+        } else {
+            return getItem((PropertyEntry) hierarchyEntry);
         }
-        return item;
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java?rev=1171155&r1=1171154&r2=1171155&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
Thu Sep 15 16:00:15 2011
@@ -209,7 +209,7 @@ public class JcrVersionManager implement
 
         NodeImpl n = (NodeImpl) itemManager.getNode(resolver.getQPath(absPath));
         NodeEntry entry = vMgr.createConfiguration(n.getItemState());
-        return (Node) itemManager.getItem(entry);
+        return itemManager.getItem(entry);
     }
 
     @Override
@@ -237,7 +237,7 @@ public class JcrVersionManager implement
             return null;
         } else {
             try {
-                return (Node) itemManager.getItem(session.getHierarchyManager().getNodeEntry(activityId));
+                return itemManager.getItem(session.getHierarchyManager().getNodeEntry(activityId));
             } catch (ItemNotFoundException e) {
                 // the activity doesn't exist any more.
                 log.warn("Activity node with id " + activityId + " doesn't exist any more.");
@@ -252,7 +252,7 @@ public class JcrVersionManager implement
         session.checkIsAlive();
 
         NodeEntry entry = vMgr.createActivity(title);
-        return (Node) itemManager.getItem(entry);
+        return itemManager.getItem(entry);
     }
 
     @Override

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=1171155&r1=1171154&r2=1171155&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
Thu Sep 15 16:00:15 2011
@@ -387,7 +387,7 @@ public class NodeImpl extends ItemImpl<N
             throw new PathNotFoundException(relPath);
         }
         try {
-            return (Node) getItemManager().getItem(nodeEntry);
+            return getItemManager().getItem(nodeEntry);
         } catch (ItemNotFoundException e) {
             throw new PathNotFoundException(relPath, e);
         }
@@ -433,7 +433,7 @@ public class NodeImpl extends ItemImpl<N
             throw new PathNotFoundException(relPath);
         }
         try {
-            return (Property) getItemManager().getItem(entry);
+            return getItemManager().getItem(entry);
         } catch (AccessDeniedException e) {
             throw new PathNotFoundException(relPath);
         } catch (ItemNotFoundException e) {
@@ -1352,7 +1352,7 @@ public class NodeImpl extends ItemImpl<N
             if (nEntry == null) {
                 throw new PathNotFoundException(LogUtil.saveGetJCRName(nodeName, session.getNamePathResolver()));
             }
-            return (Node) getItemManager().getItem(nEntry);
+            return getItemManager().getItem(nEntry);
         } catch (AccessDeniedException e) {
             throw new PathNotFoundException(LogUtil.saveGetJCRName(nodeName, session.getNamePathResolver()));
         }
@@ -1372,7 +1372,7 @@ public class NodeImpl extends ItemImpl<N
             if (pEntry == null) {
                 throw new PathNotFoundException(LogUtil.saveGetJCRName(qName, session.getNamePathResolver()));
             }
-            return (Property) getItemManager().getItem(pEntry);
+            return getItemManager().getItem(pEntry);
         } catch (AccessDeniedException e) {
             throw new PathNotFoundException(LogUtil.saveGetJCRName(qName, session.getNamePathResolver()));
         }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=1171155&r1=1171154&r2=1171155&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Thu Sep 15 16:00:15 2011
@@ -235,7 +235,7 @@ public class SessionImpl extends Abstrac
         checkIsAlive();
 
         NodeEntry re = getHierarchyManager().getRootEntry();
-        return (Node) itemManager.getItem(re);
+        return itemManager.getItem(re);
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java?rev=1171155&r1=1171154&r2=1171155&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/RowIteratorImpl.java
Thu Sep 15 16:00:15 2011
@@ -341,7 +341,7 @@ class RowIteratorImpl implements RowIter
         private Node getNode(NodeId id) throws RepositoryException {
             Node node = null;
             if (id != null) {
-                node = (Node) itemMgr.getItem(hierarchyManager.getNodeEntry(id));
+                node = itemMgr.getItem(hierarchyManager.getNodeEntry(id));
             }
             return node;
         }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java?rev=1171155&r1=1171154&r2=1171155&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/version/VersionHistoryImpl.java
Thu Sep 15 16:00:15 2011
@@ -35,7 +35,6 @@ import org.slf4j.LoggerFactory;
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
-import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.nodetype.ConstraintViolationException;
@@ -341,7 +340,7 @@ public class VersionHistoryImpl extends 
         if (pEntry == null) {
             throw new VersionException("Version with label '" + qLabel + "' does not exist.");
         }
-        Node version = ((Property) getItemManager().getItem(pEntry)).getNode();
+        Node version = getItemManager().getItem(pEntry).getNode();
         return (Version) version;
     }
 



Mime
View raw message