[jbosscache-commits] JBoss Cache SVN: r7484 - in core/branches/flat/src/main/java/org/jboss/starobrno: factories and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Jan 16 06:59:25 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-01-16 06:59:25 -0500 (Fri, 16 Jan 2009)
New Revision: 7484

Removed:
   core/branches/flat/src/main/java/org/jboss/starobrno/container/MVCCEntryCreator.java
Modified:
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CacheLoaderInterceptor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
Log:
Combined MVCCEntryCreator and EntryFactory into a single component

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/container/MVCCEntryCreator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/container/MVCCEntryCreator.java	2009-01-15 22:32:12 UTC (rev 7483)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/container/MVCCEntryCreator.java	2009-01-16 11:59:25 UTC (rev 7484)
@@ -1,197 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.container;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.context.InvocationContext;
-import org.jboss.starobrno.factories.EntryFactory;
-import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.factories.annotations.Start;
-import org.jboss.starobrno.lock.LockManager;
-import org.jboss.starobrno.lock.TimeoutException;
-import org.jboss.starobrno.notifications.Notifier;
-
-/**
- * Wraps mvcc entries.
- *
- * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
- * @since 3.0
- */
-public class MVCCEntryCreator
-{
-   DataContainer container;
-   boolean writeSkewCheck;
-   LockManager lockManager;
-   Configuration configuration;
-   long defaultLockAcquisitionTimeout;
-   EntryFactory entryFactory;
-   Notifier notifier;
-
-   private static final Log log = LogFactory.getLog(MVCCEntryCreator.class);
-   private static final boolean trace = log.isTraceEnabled();
-
-
-   @Inject
-   public void injectDependencies(DataContainer dataContainer, LockManager lockManager, Configuration configuration, EntryFactory entryFactory, Notifier notifier)
-   {
-      this.container = dataContainer;
-      this.configuration = configuration;
-      this.lockManager = lockManager;
-      this.entryFactory = entryFactory;
-      this.notifier = notifier;
-   }
-
-   @Start
-   public void start()
-   {
-      defaultLockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
-      writeSkewCheck = configuration.isWriteSkewCheck();
-   }
-
-   public MVCCEntry wrapEntryForReading(InvocationContext ctx, Object key, boolean putInContext) throws InterruptedException
-   {
-      return wrapEntryForReading(ctx, key, putInContext, false);
-   }
-
-   public MVCCEntry wrapEntryForReading(InvocationContext ctx, Object key, boolean putInContext, boolean forceWriteLock) throws InterruptedException
-   {
-      // TODO: Do we need to wrap for reading if we are not in a TX?
-      // TODO: Also, do we need to wrap for reading even IN a TX if we are using read-committed?
-
-      MVCCEntry mvccEntry;
-      if (forceWriteLock)
-      {
-         if (trace) log.trace("Forcing lock on reading");
-         return wrapEntryForWriting(ctx, key, false, false);
-      }
-      else if ((mvccEntry = ctx.lookupEntry(key)) == null)
-      {
-         if (trace) log.trace("Key " + key + " is not in context, fetching from container.");
-         // simple implementation.  Peek the node, wrap it, put wrapped node in the context.
-         Object value = container.get(key);
-         mvccEntry = entryFactory.createWrappedEntry(key, value, false);
-         if (mvccEntry != null && putInContext) ctx.putLookedUpEntry(key, mvccEntry);
-         return mvccEntry;
-      }
-      else
-      {
-         if (trace) log.trace("Key is already in context");
-         return mvccEntry;
-      }
-   }
-
-   public MVCCEntry wrapEntryForWriting(InvocationContext ctx, Object key, boolean createIfAbsent, boolean forceLockIfAbsent) throws InterruptedException
-   {
-      MVCCEntry mvccEntry = ctx.lookupEntry(key);
-      if (createIfAbsent && mvccEntry != null && mvccEntry.isNullEntry()) mvccEntry = null;
-      if (mvccEntry != null) // exists in context!  Just acquire lock if needed, and wrap.
-      {
-         // acquire lock if needed
-         if (acquireLock(ctx, key))
-         {
-            // create a copy of the underlying node
-            mvccEntry.copyForUpdate(container, writeSkewCheck);
-         }
-         if (trace) log.trace("Exists in context.");
-         if (mvccEntry.isDeleted() && createIfAbsent)
-         {
-            if (trace) log.trace("Node is deleted in current scope.  Need to un-delete.");
-            mvccEntry.setDeleted(false);
-            mvccEntry.setValid(true);
-         }
-      }
-      else
-      {
-         // else, fetch from dataContainer.
-         Object value = container.get(key);
-         if (value != null)
-         {
-            if (trace) log.trace("Retrieved from container.");
-            // exists in cache!  Just acquire lock if needed, and wrap.
-            // do we need a lock?
-            boolean needToCopy = false;
-            if (acquireLock(ctx, key)) needToCopy = true;
-            mvccEntry = entryFactory.createWrappedEntry(key, value, false);
-            ctx.putLookedUpEntry(key, mvccEntry);
-            if (needToCopy) mvccEntry.copyForUpdate(container, writeSkewCheck);
-         }
-         else if (createIfAbsent) // else, do we need to create one?
-         {
-            // this is the *only* point where new entries can be created!!
-            if (trace) log.trace("Creating new entry.");
-            // now to lock and create the node.  Lock first to prevent concurrent creation!
-            acquireLock(ctx, key);
-            notifier.notifyCacheEntryCreated(key, true, ctx);
-            mvccEntry = entryFactory.createWrappedEntry(key, value, true);
-            mvccEntry.setCreated(true);
-            ctx.putLookedUpEntry(key, mvccEntry);
-            mvccEntry.copyForUpdate(container, writeSkewCheck);
-            notifier.notifyCacheEntryCreated(key, false, ctx);
-         }
-      }
-
-      // see if we need to force the lock on nonexistent entries.
-      if (mvccEntry == null && forceLockIfAbsent) acquireLock(ctx, key);
-
-      return mvccEntry;
-   }
-
-   /**
-    * Attempts to lock a node if the lock isn't already held in the current scope, and records the lock in the context.
-    *
-    * @param ctx context
-    * @param key Key to lock
-    * @return true if a lock was needed and acquired, false if it didn't need to acquire the lock (i.e., lock was already held)
-    * @throws InterruptedException if interrupted
-    * @throws org.jboss.starobrno.lock.TimeoutException
-    *                              if we are unable to acquire the lock after a specified timeout.
-    */
-   public boolean acquireLock(InvocationContext ctx, Object key) throws InterruptedException, TimeoutException
-   {
-      // don't EVER use lockManager.isLocked() since with lock striping it may be the case that we hold the relevant
-      // lock which may be shared with another Fqn that we have a lock for already.
-      // nothing wrong, just means that we fail to record the lock.  And that is a problem.
-      // Better to check our records and lock again if necessary.
-      if (!ctx.hasLockedKey(key))
-      {
-         if (ctx.getOptionOverrides().isSuppressLocking())
-         {
-            // just record this in the ctx and rtn
-            ctx.addKeyLocked(key);
-         }
-         else if (!lockManager.lockAndRecord(key, ctx))
-         {
-            Object owner = lockManager.getOwner(key);
-            throw new TimeoutException("Unable to acquire lock on key [" + key + "] after [" + ctx.getLockAcquisitionTimeout(defaultLockAcquisitionTimeout) + "] milliseconds for requestor [" + lockManager.getLockOwner(ctx) + "]! Lock held by [" + owner + "]");
-         }
-         return true;
-      }
-      return false;
-   }
-
-   public void releaseLock(InvocationContext ctx, Object key)
-   {
-      lockManager.unlock(key, lockManager.getOwner(key));
-   }
-}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java	2009-01-15 22:32:12 UTC (rev 7483)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java	2009-01-16 11:59:25 UTC (rev 7484)
@@ -29,7 +29,6 @@
 import org.jboss.starobrno.batch.BatchContainer;
 import org.jboss.starobrno.commands.CommandsFactory;
 import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.container.MVCCEntryCreator;
 import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
 import org.jboss.starobrno.factories.context.ContextFactory;
 import org.jboss.starobrno.invocation.InvocationContextContainer;
@@ -50,7 +49,7 @@
  */
 @DefaultFactoryFor(classes = {Notifier.class, RegionRegistry.class,
       ChannelMessageListener.class, CacheLoaderManager.class, ExtendedMarshaller.class, InvocationContextContainer.class,
-      CacheInvocationDelegate.class, TransactionTable.class, MVCCEntryCreator.class,
+      CacheInvocationDelegate.class, TransactionTable.class,
       LockStrategyFactory.class, BuddyFqnTransformer.class, BatchContainer.class,
       ContextFactory.class, EntryFactory.class, CommandsFactory.class})
 public class EmptyConstructorFactory extends ComponentFactory

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactory.java	2009-01-15 22:32:12 UTC (rev 7483)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactory.java	2009-01-16 11:59:25 UTC (rev 7484)
@@ -22,6 +22,8 @@
 package org.jboss.starobrno.factories;
 
 import org.jboss.starobrno.container.MVCCEntry;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.lock.TimeoutException;
 
 /**
  * // TODO: MANIK: Document this
@@ -31,5 +33,25 @@
  */
 public interface EntryFactory
 {
+   void releaseLock(Object key);
+
+   /**
+    * Attempts to lock a node if the lock isn't already held in the current scope, and records the lock in the context.
+    *
+    * @param ctx context
+    * @param key Key to lock
+    * @return true if a lock was needed and acquired, false if it didn't need to acquire the lock (i.e., lock was already held)
+    * @throws InterruptedException if interrupted
+    * @throws org.jboss.starobrno.lock.TimeoutException
+    *                              if we are unable to acquire the lock after a specified timeout.
+    */
+   boolean acquireLock(InvocationContext ctx, Object key) throws InterruptedException, TimeoutException;
+
+   MVCCEntry wrapEntryForWriting(InvocationContext ctx, Object key, boolean createIfAbsent, boolean forceLockIfAbsent) throws InterruptedException;
+
+   MVCCEntry wrapEntryForReading(InvocationContext ctx, Object key, boolean putInContext, boolean forceWriteLock) throws InterruptedException;
+
+   MVCCEntry wrapEntryForReading(InvocationContext ctx, Object key, boolean putInContext) throws InterruptedException;
+
    MVCCEntry createWrappedEntry(Object key, Object value, boolean isForInsert);
 }

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java	2009-01-15 22:32:12 UTC (rev 7483)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java	2009-01-16 11:59:25 UTC (rev 7484)
@@ -21,14 +21,21 @@
  */
 package org.jboss.starobrno.factories;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.container.DataContainer;
 import org.jboss.starobrno.container.MVCCEntry;
 import org.jboss.starobrno.container.NullMarkerEntry;
 import org.jboss.starobrno.container.ReadCommittedEntry;
 import org.jboss.starobrno.container.RepeatableReadEntry;
+import org.jboss.starobrno.context.InvocationContext;
 import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.lock.LockManager;
+import org.jboss.starobrno.lock.TimeoutException;
+import org.jboss.starobrno.notifications.Notifier;
 
 /**
  * // TODO: MANIK: Document this
@@ -40,18 +47,31 @@
 {
    private boolean useRepeatableRead;
    private static final NullMarkerEntry NULL_MARKER = new NullMarkerEntry();
-   private Configuration configuration;
+   DataContainer container;
+   boolean writeSkewCheck;
+   LockManager lockManager;
+   Configuration configuration;
+   long defaultLockAcquisitionTimeout;
+   Notifier notifier;
 
+   private static final Log log = LogFactory.getLog(EntryFactoryImpl.class);
+   private static final boolean trace = log.isTraceEnabled();
+
    @Inject
-   public void injectDependencies(Configuration configuration)
+   public void injectDependencies(DataContainer dataContainer, LockManager lockManager, Configuration configuration, Notifier notifier)
    {
+      this.container = dataContainer;
       this.configuration = configuration;
+      this.lockManager = lockManager;
+      this.notifier = notifier;
    }
 
    @Start
    public void init()
    {
       useRepeatableRead = configuration.getIsolationLevel() == IsolationLevel.REPEATABLE_READ;
+      defaultLockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
+      writeSkewCheck = configuration.isWriteSkewCheck();
    }
 
    public MVCCEntry createWrappedEntry(Object key, Object value, boolean isForInsert)
@@ -61,4 +81,130 @@
       MVCCEntry mvccEntry = useRepeatableRead ? new RepeatableReadEntry(key, value) : new ReadCommittedEntry(key, value);
       return mvccEntry;
    }
+
+   public MVCCEntry wrapEntryForReading(InvocationContext ctx, Object key, boolean putInContext) throws InterruptedException
+   {
+      return wrapEntryForReading(ctx, key, putInContext, false);
+   }
+
+   public MVCCEntry wrapEntryForReading(InvocationContext ctx, Object key, boolean putInContext, boolean forceWriteLock) throws InterruptedException
+   {
+      // TODO: Do we need to wrap for reading if we are not in a TX?
+      // TODO: Also, do we need to wrap for reading even IN a TX if we are using read-committed?
+
+      MVCCEntry mvccEntry;
+      if (forceWriteLock)
+      {
+         if (trace) log.trace("Forcing lock on reading");
+         return wrapEntryForWriting(ctx, key, false, false);
+      }
+      else if ((mvccEntry = ctx.lookupEntry(key)) == null)
+      {
+         if (trace) log.trace("Key " + key + " is not in context, fetching from container.");
+         // simple implementation.  Peek the node, wrap it, put wrapped node in the context.
+         Object value = container.get(key);
+         mvccEntry = createWrappedEntry(key, value, false);
+         if (mvccEntry != null && putInContext) ctx.putLookedUpEntry(key, mvccEntry);
+         return mvccEntry;
+      }
+      else
+      {
+         if (trace) log.trace("Key is already in context");
+         return mvccEntry;
+      }
+   }
+
+   public MVCCEntry wrapEntryForWriting(InvocationContext ctx, Object key, boolean createIfAbsent, boolean forceLockIfAbsent) throws InterruptedException
+   {
+      MVCCEntry mvccEntry = ctx.lookupEntry(key);
+      if (createIfAbsent && mvccEntry != null && mvccEntry.isNullEntry()) mvccEntry = null;
+      if (mvccEntry != null) // exists in context!  Just acquire lock if needed, and wrap.
+      {
+         // acquire lock if needed
+         if (acquireLock(ctx, key))
+         {
+            // create a copy of the underlying node
+            mvccEntry.copyForUpdate(container, writeSkewCheck);
+         }
+         if (trace) log.trace("Exists in context.");
+         if (mvccEntry.isDeleted() && createIfAbsent)
+         {
+            if (trace) log.trace("Node is deleted in current scope.  Need to un-delete.");
+            mvccEntry.setDeleted(false);
+            mvccEntry.setValid(true);
+         }
+      }
+      else
+      {
+         // else, fetch from dataContainer.
+         Object value = container.get(key);
+         if (value != null)
+         {
+            if (trace) log.trace("Retrieved from container.");
+            // exists in cache!  Just acquire lock if needed, and wrap.
+            // do we need a lock?
+            boolean needToCopy = false;
+            if (acquireLock(ctx, key)) needToCopy = true;
+            mvccEntry = createWrappedEntry(key, value, false);
+            ctx.putLookedUpEntry(key, mvccEntry);
+            if (needToCopy) mvccEntry.copyForUpdate(container, writeSkewCheck);
+         }
+         else if (createIfAbsent) // else, do we need to create one?
+         {
+            // this is the *only* point where new entries can be created!!
+            if (trace) log.trace("Creating new entry.");
+            // now to lock and create the node.  Lock first to prevent concurrent creation!
+            acquireLock(ctx, key);
+            notifier.notifyCacheEntryCreated(key, true, ctx);
+            mvccEntry = createWrappedEntry(key, value, true);
+            mvccEntry.setCreated(true);
+            ctx.putLookedUpEntry(key, mvccEntry);
+            mvccEntry.copyForUpdate(container, writeSkewCheck);
+            notifier.notifyCacheEntryCreated(key, false, ctx);
+         }
+      }
+
+      // see if we need to force the lock on nonexistent entries.
+      if (mvccEntry == null && forceLockIfAbsent) acquireLock(ctx, key);
+
+      return mvccEntry;
+   }
+
+   /**
+    * Attempts to lock a node if the lock isn't already held in the current scope, and records the lock in the context.
+    *
+    * @param ctx context
+    * @param key Key to lock
+    * @return true if a lock was needed and acquired, false if it didn't need to acquire the lock (i.e., lock was already held)
+    * @throws InterruptedException if interrupted
+    * @throws org.jboss.starobrno.lock.TimeoutException
+    *                              if we are unable to acquire the lock after a specified timeout.
+    */
+   public boolean acquireLock(InvocationContext ctx, Object key) throws InterruptedException, TimeoutException
+   {
+      // don't EVER use lockManager.isLocked() since with lock striping it may be the case that we hold the relevant
+      // lock which may be shared with another Fqn that we have a lock for already.
+      // nothing wrong, just means that we fail to record the lock.  And that is a problem.
+      // Better to check our records and lock again if necessary.
+      if (!ctx.hasLockedKey(key))
+      {
+         if (ctx.getOptionOverrides().isSuppressLocking())
+         {
+            // just record this in the ctx and rtn
+            ctx.addKeyLocked(key);
+         }
+         else if (!lockManager.lockAndRecord(key, ctx))
+         {
+            Object owner = lockManager.getOwner(key);
+            throw new TimeoutException("Unable to acquire lock on key [" + key + "] after [" + ctx.getLockAcquisitionTimeout(defaultLockAcquisitionTimeout) + "] milliseconds for requestor [" + lockManager.getLockOwner(ctx) + "]! Lock held by [" + owner + "]");
+         }
+         return true;
+      }
+      return false;
+   }
+
+   public void releaseLock(Object key)
+   {
+      lockManager.unlock(key, lockManager.getOwner(key));
+   }
 }

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CacheLoaderInterceptor.java	2009-01-15 22:32:12 UTC (rev 7483)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CacheLoaderInterceptor.java	2009-01-16 11:59:25 UTC (rev 7484)
@@ -21,18 +21,14 @@
  */
 package org.jboss.starobrno.interceptors;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.jboss.starobrno.commands.read.GetKeyValueCommand;
 import org.jboss.starobrno.commands.write.PutKeyValueCommand;
 import org.jboss.starobrno.commands.write.RemoveCommand;
 import org.jboss.starobrno.commands.write.ReplaceCommand;
-import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.container.DataContainer;
 import org.jboss.starobrno.container.MVCCEntry;
-import org.jboss.starobrno.container.MVCCEntryCreator;
 import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.EntryFactory;
 import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.annotations.Start;
 import org.jboss.starobrno.interceptors.base.JmxStatsCommandInterceptor;
@@ -43,6 +39,9 @@
 import org.jboss.starobrno.notifications.Notifier;
 import org.jboss.starobrno.transaction.TransactionTable;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Loads nodes that don't exist at the time of the call into memory from the CacheLoader
  *
@@ -59,7 +58,7 @@
    protected CacheLoader<Object, Object> loader;
    protected DataContainer<Object, Object> dataContainer;
    protected Notifier notifier;
-   protected MVCCEntryCreator creator;
+   protected EntryFactory entryFactory;
 
    protected boolean isActivation = false;
 //   protected boolean usingVersionedInvalidation = false;
@@ -73,8 +72,8 @@
    protected boolean useCacheStore = true;
 
    @Inject
-   protected void injectDependencies(TransactionTable txTable, CacheLoaderManager clm, Configuration configuration,
-                                     DataContainer<Object, Object> dataContainer, MVCCEntryCreator creator, Notifier notifier)
+   protected void injectDependencies(TransactionTable txTable, CacheLoaderManager clm,
+                                     DataContainer<Object, Object> dataContainer, EntryFactory entryFactory, Notifier notifier)
    {
       this.txTable = txTable;
       this.clm = clm;
@@ -82,7 +81,7 @@
 //      usingVersionedInvalidation = mode.isInvalidation();
       this.dataContainer = dataContainer;
       this.notifier = notifier;
-      this.creator = creator;
+      this.entryFactory = entryFactory;
    }
 
    @Start
@@ -138,16 +137,16 @@
          return;
 
       // Obtain a temporary lock to verify the key is not being concurrently added
-      boolean release = creator.acquireLock(ctx, key);
+      boolean release = entryFactory.acquireLock(ctx, key);
       if (dataContainer.containsKey(key))
       {
          if (release)
-            creator.releaseLock(ctx, key);
+            entryFactory.releaseLock(key);
          return;
       }
 
       // Reuse the lock and create a new entry for loading
-      MVCCEntry n = creator.wrapEntryForWriting(ctx, key, true, false);
+      MVCCEntry n = entryFactory.wrapEntryForWriting(ctx, key, true, false);
       n = loadEntry(ctx, key, n);
    }
 

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java	2009-01-15 22:32:12 UTC (rev 7483)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java	2009-01-16 11:59:25 UTC (rev 7484)
@@ -36,8 +36,8 @@
 import org.jboss.starobrno.commands.write.ReplaceCommand;
 import org.jboss.starobrno.container.DataContainer;
 import org.jboss.starobrno.container.MVCCEntry;
-import org.jboss.starobrno.container.MVCCEntryCreator;
 import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.EntryFactory;
 import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.annotations.Start;
 import org.jboss.starobrno.interceptors.base.CommandInterceptor;
@@ -59,15 +59,15 @@
 {
    LockManager lockManager;
    DataContainer dataContainer;
-   MVCCEntryCreator entryWrapper;
+   EntryFactory entryFactory;
    boolean useReadCommitted;
 
    @Inject
-   public void setDependencies(LockManager lockManager, DataContainer dataContainer, MVCCEntryCreator entryWrapper)
+   public void setDependencies(LockManager lockManager, DataContainer dataContainer, EntryFactory entryFactory)
    {
       this.lockManager = lockManager;
       this.dataContainer = dataContainer;
-      this.entryWrapper = entryWrapper;
+      this.entryFactory = entryFactory;
    }
 
    @Start
@@ -122,7 +122,7 @@
    {
       try
       {
-         entryWrapper.wrapEntryForReading(ctx, command.getKey(), true);
+         entryFactory.wrapEntryForReading(ctx, command.getKey(), true);
          return invokeNextInterceptor(ctx, command);
       }
       finally
@@ -153,7 +153,7 @@
       try
       {
          // get a snapshot of all keys in the data container
-         for (Object key : dataContainer.keySet()) entryWrapper.wrapEntryForWriting(ctx, key, false, false);
+         for (Object key : dataContainer.keySet()) entryFactory.wrapEntryForWriting(ctx, key, false, false);
 
          return invokeNextInterceptor(ctx, command);
       }
@@ -168,7 +168,7 @@
    {
       try
       {
-         entryWrapper.wrapEntryForWriting(ctx, command.getKey(), false, true);
+         entryFactory.wrapEntryForWriting(ctx, command.getKey(), false, true);
          return invokeNextInterceptor(ctx, command);
       }
       finally
@@ -182,7 +182,7 @@
    {
       try
       {
-         entryWrapper.wrapEntryForWriting(ctx, command.getKey(), true, false);
+         entryFactory.wrapEntryForWriting(ctx, command.getKey(), true, false);
          Object o = invokeNextInterceptor(ctx, command);
          return o;
       }
@@ -199,7 +199,7 @@
       {
          for (Object key : command.getMap().keySet())
          {
-            entryWrapper.wrapEntryForWriting(ctx, key, true, false);
+            entryFactory.wrapEntryForWriting(ctx, key, true, false);
          }
          return invokeNextInterceptor(ctx, command);
       }
@@ -214,7 +214,7 @@
    {
       try
       {
-         entryWrapper.wrapEntryForWriting(ctx, command.getKey(), false, true);
+         entryFactory.wrapEntryForWriting(ctx, command.getKey(), false, true);
          return invokeNextInterceptor(ctx, command);
       }
       finally
@@ -228,7 +228,7 @@
    {
       try
       {
-         entryWrapper.wrapEntryForWriting(ctx, command.getKey(), false, true);
+         entryFactory.wrapEntryForWriting(ctx, command.getKey(), false, true);
          return invokeNextInterceptor(ctx, command);
       }
       finally
@@ -242,7 +242,7 @@
    {
       try
       {
-         entryWrapper.wrapEntryForReading(ctx, command.getKey(), true);
+         entryFactory.wrapEntryForReading(ctx, command.getKey(), true);
          return invokeNextInterceptor(ctx, command);
       }
       finally




More information about the jbosscache-commits mailing list