org.multiverse.api.commitlock
Interface CommitLockPolicy

All Known Implementing Classes:
GenericCommitLockPolicy

public interface CommitLockPolicy

A policy responsible for acquiring the lock of a set of CommitLocks.

When a Transaction commits, it needs to acquire locks on the objects of the writeset. With this LockPolicy this behavior can be influenced.

If the locks could not be acquired, the policy is responsible for making sure that all locks are released. So a callee is guaranteed to own all locks or no locks at all.

The reason that the WriteSetLockPolicy works with an array, is that it doesn't createReference a lot of gc-litter.

It is important to realize that locks should be acquired and if that fails, should all be released. The implementer has to realize that ... 2 phase locking (todo: better explanation).

Author:
Peter Veentjer.

Method Summary
 boolean tryAcquire(CommitLock lock, CommitLockFilter filter, Transaction lockOwner)
          Tries to acquire the lock.
 boolean tryAcquireAll(java.util.Collection<CommitLock> locks, CommitLockFilter filter, Transaction lockOwner)
           
 boolean tryAcquireAll(CommitLock[] locks, CommitLockFilter filter, Transaction lockOwner)
          Tries to acquire all the locks that should be locked (so are allowed by the lock filter).
 

Method Detail

tryAcquire

boolean tryAcquire(CommitLock lock,
                   CommitLockFilter filter,
                   Transaction lockOwner)
Tries to acquire the lock.

Parameters:
lock - the CommitLock to acquire.
filter - the filter that selects to objects to lock.
lockOwner - the Transaction that wants to own the lock.
Returns:
true if the lock is acquired, false otherwise.

tryAcquireAll

boolean tryAcquireAll(CommitLock[] locks,
                      CommitLockFilter filter,
                      Transaction lockOwner)
Tries to acquire all the locks that should be locked (so are allowed by the lock filter).

The filter is useful for dealing with a read/write set where only the writes need to be locked.

Parameters:
locks - the CommitLocks where some need to be acquired.
filter - selects which CommitLocks need to be acquired
lockOwner - the Transaction that wants to acquire the locks.
Returns:
true if desired locks are acquired, false otherwise.

tryAcquireAll

boolean tryAcquireAll(java.util.Collection<CommitLock> locks,
                      CommitLockFilter filter,
                      Transaction lockOwner)


Copyright © 2008-2010 Multiverse. All Rights Reserved.