Package org.apache.jackrabbit.util
Class LockedWrapper<T>
- java.lang.Object
-
- org.apache.jackrabbit.util.Locked
-
- org.apache.jackrabbit.util.LockedWrapper<T>
-
public abstract class LockedWrapper<T> extends Locked
LockedWrapperis a wrapper class toLockedwhich adds generics support and wraps theLocked.TIMED_OUTobject into aLockException.
-
-
Constructor Summary
Constructors Constructor Description LockedWrapper()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Trun(Node node)This method is executed while holding the lock.Twith(Node lockable, boolean isDeep)ExecutesLocked.run(javax.jcr.Node)while the lock onlockableis held.Twith(Node lockable, boolean isDeep, boolean isSessionScoped)ExecutesLocked.run(javax.jcr.Node)while the lock onlockableis held.Twith(Node lockable, boolean isDeep, long timeout)Executes the methodLocked.run(javax.jcr.Node)within the scope of a lock held onlockable.Objectwith(Node lockable, boolean isDeep, long timeout, boolean isSessionScoped)Executes the methodLocked.run(javax.jcr.Node)within the scope of a lock held onlockable.
-
-
-
Method Detail
-
with
public T with(Node lockable, boolean isDeep) throws RepositoryException, InterruptedException
Description copied from class:LockedExecutesLocked.run(javax.jcr.Node)while the lock onlockableis held. This method will block untilLocked.run(javax.jcr.Node)is executed while holding the lock on nodelockable.- Overrides:
within classLocked- Parameters:
lockable- a lockable node.isDeep-trueiflockablewill be locked deep.- Returns:
- the object returned by
Locked.run(javax.jcr.Node). - Throws:
RepositoryException- ifLocked.run(javax.jcr.Node)throws an exception.InterruptedException- if this thread is interrupted while waiting for the lock on nodelockable.
-
with
public T with(Node lockable, boolean isDeep, boolean isSessionScoped) throws RepositoryException, InterruptedException
Description copied from class:LockedExecutesLocked.run(javax.jcr.Node)while the lock onlockableis held. This method will block untilLocked.run(javax.jcr.Node)is executed while holding the lock on nodelockable.- Overrides:
within classLocked- Parameters:
lockable- a lockable node.isDeep-trueiflockablewill be locked deep.isSessionScoped-trueif the lock is session scoped.- Returns:
- the object returned by
Locked.run(javax.jcr.Node). - Throws:
RepositoryException- ifLocked.run(javax.jcr.Node)throws an exception.InterruptedException- if this thread is interrupted while waiting for the lock on nodelockable.
-
with
public T with(Node lockable, boolean isDeep, long timeout) throws UnsupportedRepositoryOperationException, RepositoryException, InterruptedException
Description copied from class:LockedExecutes the methodLocked.run(javax.jcr.Node)within the scope of a lock held onlockable.- Overrides:
within classLocked- Parameters:
lockable- the node where the lock is obtained from.isDeep-trueiflockablewill be locked deep.timeout- time in milliseconds to wait at most to acquire the lock.- Returns:
- the object returned by
Locked.run(javax.jcr.Node)orLocked.TIMED_OUTif the lock onlockablecould not be acquired within the specified timeout. - Throws:
UnsupportedRepositoryOperationException- if this repository does not support locking.RepositoryException- ifLocked.run(javax.jcr.Node)throws an exception.InterruptedException- if this thread is interrupted while waiting for the lock on nodelockable.
-
with
public Object with(Node lockable, boolean isDeep, long timeout, boolean isSessionScoped) throws UnsupportedRepositoryOperationException, RepositoryException, InterruptedException
Description copied from class:LockedExecutes the methodLocked.run(javax.jcr.Node)within the scope of a lock held onlockable.- Overrides:
within classLocked- Parameters:
lockable- the node where the lock is obtained from.isDeep-trueiflockablewill be locked deep.timeout- time in milliseconds to wait at most to acquire the lock.isSessionScoped-trueif the lock is session scoped.- Returns:
- the object returned by
Locked.run(javax.jcr.Node)orLocked.TIMED_OUTif the lock onlockablecould not be acquired within the specified timeout. - Throws:
UnsupportedRepositoryOperationException- if this repository does not support locking.RepositoryException- ifLocked.run(javax.jcr.Node)throws an exception.InterruptedException- if this thread is interrupted while waiting for the lock on nodelockable.
-
run
protected abstract T run(Node node) throws RepositoryException
This method is executed while holding the lock.- Specified by:
runin classLocked- Parameters:
node- TheNodeon which the lock is placed.- Returns:
- an object which is then returned by
with(). - Throws:
RepositoryException- if an error occurs.
-
-