org.infinispan.container
Interface EntryFactory

All Known Implementing Classes:
EntryFactoryImpl

public interface EntryFactory

A factory for constructing MVCCEntry instances for use in the InvocationContext. Implementations of this interface would typically wrap an internal CacheEntry with an MVCCEntry, optionally acquiring the necessary locks via the LockManager.

Since:
4.0
Author:
Manik Surtani (manik@jboss.org), Galder ZamarreƱo

Method Summary
 boolean acquireLock(InvocationContext ctx, Object key)
          Attempts to lock an entry if the lock isn't already held in the current scope, and records the lock in the context.
 void releaseLock(Object key)
           
 CacheEntry wrapEntryForReading(InvocationContext ctx, Object key)
          Wraps an entry for reading.
 MVCCEntry wrapEntryForWriting(InvocationContext ctx, InternalCacheEntry entry, boolean createIfAbsent, boolean forceLockIfAbsent, boolean alreadyLocked, boolean forRemoval, boolean undeleteIfNeeded)
          Wraps an entry for writing.
 MVCCEntry wrapEntryForWriting(InvocationContext ctx, Object key, boolean createIfAbsent, boolean forceLockIfAbsent, boolean alreadyLocked, boolean forRemoval, boolean undeleteIfNeeded)
          Wraps an entry for writing.
 

Method Detail

releaseLock

void releaseLock(Object key)

acquireLock

boolean acquireLock(InvocationContext ctx,
                    Object key)
                    throws InterruptedException,
                           TimeoutException
Attempts to lock an entry if the lock isn't already held in the current scope, and records the lock in the context.

Parameters:
ctx - context
key - Key to lock
Returns:
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
TimeoutException - if we are unable to acquire the lock after a specified timeout.

wrapEntryForWriting

MVCCEntry wrapEntryForWriting(InvocationContext ctx,
                              Object key,
                              boolean createIfAbsent,
                              boolean forceLockIfAbsent,
                              boolean alreadyLocked,
                              boolean forRemoval,
                              boolean undeleteIfNeeded)
                              throws InterruptedException
Wraps an entry for writing. This would typically acquire write locks if necessary, and place the wrapped entry in the invocation context.

Parameters:
ctx - current invocation context
key - key to look up and wrap
createIfAbsent - if true, an entry is created if it does not exist in the data container.
forceLockIfAbsent - forces a lock even if the entry is absent
alreadyLocked - if true, this hint prevents the method from acquiring any locks and the existence and ownership of the lock is presumed.
forRemoval - if true, this hint informs this method that the lock is being acquired for removal.
undeleteIfNeeded - if true, if the entry is found in the current scope (perhaps a transaction) and is deleted, it will be undeleted. If false, it will be considered deleted.
Returns:
an MVCCEntry instance
Throws:
InterruptedException - when things go wrong, usually trying to acquire a lock

wrapEntryForWriting

MVCCEntry wrapEntryForWriting(InvocationContext ctx,
                              InternalCacheEntry entry,
                              boolean createIfAbsent,
                              boolean forceLockIfAbsent,
                              boolean alreadyLocked,
                              boolean forRemoval,
                              boolean undeleteIfNeeded)
                              throws InterruptedException
Wraps an entry for writing. This would typically acquire write locks if necessary, and place the wrapped entry in the invocation context.

Parameters:
ctx - current invocation context
entry - an internal entry to wrap
createIfAbsent - if true, an entry is created if it does not exist in the data container.
forceLockIfAbsent - forces a lock even if the entry is absent
alreadyLocked - if true, this hint prevents the method from acquiring any locks and the existence and ownership of the lock is presumed.
forRemoval - if true, this hint informs this method that the lock is being acquired for removal.
undeleteIfNeeded - if true, if the entry is found in the current scope (perhaps a transaction) and is deleted, it will be undeleted. If false, it will be considered deleted. * @return an MVCCEntry instance
Throws:
InterruptedException - when things go wrong, usually trying to acquire a lock

wrapEntryForReading

CacheEntry wrapEntryForReading(InvocationContext ctx,
                               Object key)
                               throws InterruptedException
Wraps an entry for reading. Usually this is just a raw CacheEntry but certain combinations of isolation levels and the presence of an ongoing JTA transaction may force this to be a proper, wrapped MVCCEntry. The entry is also typically placed in the invocation context.

Parameters:
ctx - current invocation context
key - key to look up and wrap
Returns:
an entry for reading
Throws:
InterruptedException - when things go wrong, usually trying to acquire a lock

-->

Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.