jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1167171 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ItemCacheImpl.java ItemImpl.java ItemLifeCycleListener.java
Date Fri, 09 Sep 2011 13:56:41 GMT
Author: mduerig
Date: Fri Sep  9 13:56:41 2011
New Revision: 1167171

URL: http://svn.apache.org/viewvc?rev=1167171&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
refactor: simplify ItemCache

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.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/ItemLifeCycleListener.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java?rev=1167171&r1=1167170&r2=1167171&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
Fri Sep  9 13:56:41 2011
@@ -57,29 +57,12 @@ public class ItemCacheImpl implements It
      * @see ItemLifeCycleListener#itemCreated(Item)
      */
     @Override
-    public void itemCreated(Item item) {
-        if (!(item instanceof ItemImpl)) {
-            String msg = "Incompatible Item object: " + ItemImpl.class.getName() + " expected.";
-            throw new IllegalArgumentException(msg);
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("created item " + item);
-        }
-        // add instance to cache
-        cacheItem(((ItemImpl)item).getItemState(), item);
+    public void itemCreated(Item item, ItemState state) {
+        cacheItem(state, item);
     }
 
     @Override
-    public void itemUpdated(Item item, boolean modified) {
-        if (!(item instanceof ItemImpl)) {
-            String msg = "Incompatible Item object: " + ItemImpl.class.getName() + " expected.";
-            throw new IllegalArgumentException(msg);
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("update item " + item);
-        }
-
-        ItemState state = ((ItemImpl) item).getItemState();
+    public void itemUpdated(Item item, ItemState state, boolean modified) {
         // touch the corresponding cache entry
         Item cacheEntry = getItem(state);
         if (cacheEntry == null) {
@@ -88,20 +71,9 @@ public class ItemCacheImpl implements It
         }
     }
 
-    /**
-     * @see ItemLifeCycleListener#itemDestroyed(Item)
-     */
     @Override
-    public void itemDestroyed(Item item) {
-        if (!(item instanceof ItemImpl)) {
-            String msg = "Incompatible Item object: " + ItemImpl.class.getName() + " expected.";
-            throw new IllegalArgumentException(msg);
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("destroyed item " + item);
-        }
-        // remove instance from cache
-        evictItem(((ItemImpl)item).getItemState());
+    public void itemDestroyed(Item item, ItemState state) {
+        evictItem(state);
     }
 
     //-------------------------------------------------< item cache methods >---
@@ -113,13 +85,13 @@ public class ItemCacheImpl implements It
      * @param item the item to cache
      */
     private synchronized void cacheItem(ItemState state, Item item) {
-        if (cache.containsKey(state)) {
-            if (log.isDebugEnabled()) {
+        if (log.isDebugEnabled()) {
+            if (cache.containsKey(state)) {
                 log.debug("overwriting cached item " + state);
             }
-        }
-        if (log.isDebugEnabled()) {
-            log.debug("caching item " + state);
+            else {
+                log.debug("caching item " + state);
+            }
         }
         cache.put(state, item);
     }

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=1167171&r1=1167170&r2=1167171&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
Fri Sep  9 13:56:41 2011
@@ -311,7 +311,7 @@ public abstract class ItemImpl implement
      */
     private void notifyCreated() {
         if (listener != null) {
-            listener.itemCreated(this);
+            listener.itemCreated(this, state);
         }
     }
 
@@ -320,7 +320,7 @@ public abstract class ItemImpl implement
      */
     private void notifyUpdated(boolean modified) {
         if (listener != null) {
-            listener.itemUpdated(this, modified);
+            listener.itemUpdated(this, state, modified);
         }
     }
 
@@ -329,7 +329,7 @@ public abstract class ItemImpl implement
      */
     private void notifyDestroyed() {
         if (listener != null) {
-            listener.itemDestroyed(this);
+            listener.itemDestroyed(this, state);
             listener = null;  // item is gone for good
         }
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.java?rev=1167171&r1=1167170&r2=1167171&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.java
Fri Sep  9 13:56:41 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
+
 import javax.jcr.Item;
 
 /**
@@ -31,7 +33,7 @@ public interface ItemLifeCycleListener {
      *
      * @param item the instance which has been created
      */
-    void itemCreated(Item item);
+    void itemCreated(Item item, ItemState state);
 
     /**
      * Called when an {@code Item} instance has been refreshed. If
@@ -40,7 +42,7 @@ public interface ItemLifeCycleListener {
      *
      * @param item the instance which has been refreshed
      */
-    void itemUpdated(Item item, boolean modified);
+    void itemUpdated(Item item, ItemState state, boolean modified);
 
     /**
      * Called when an {@code ItemImpl} instance has been destroyed
@@ -53,5 +55,5 @@ public interface ItemLifeCycleListener {
      *
      * @param item the instance which has been destroyed
      */
-    void itemDestroyed(Item item);
+    void itemDestroyed(Item item, ItemState state);
 }



Mime
View raw message