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
LockedWrapper
is a wrapper class toLocked
which adds generics support and wraps theLocked.TIMED_OUT
object 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 T
run(Node node)
This method is executed while holding the lock.T
with(Node lockable, boolean isDeep)
ExecutesLocked.run(javax.jcr.Node)
while the lock onlockable
is held.T
with(Node lockable, boolean isDeep, boolean isSessionScoped)
ExecutesLocked.run(javax.jcr.Node)
while the lock onlockable
is held.T
with(Node lockable, boolean isDeep, long timeout)
Executes the methodLocked.run(javax.jcr.Node)
within the scope of a lock held onlockable
.Object
with(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:Locked
ExecutesLocked.run(javax.jcr.Node)
while the lock onlockable
is held. This method will block untilLocked.run(javax.jcr.Node)
is executed while holding the lock on nodelockable
.- Overrides:
with
in classLocked
- Parameters:
lockable
- a lockable node.isDeep
-true
iflockable
will 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:Locked
ExecutesLocked.run(javax.jcr.Node)
while the lock onlockable
is held. This method will block untilLocked.run(javax.jcr.Node)
is executed while holding the lock on nodelockable
.- Overrides:
with
in classLocked
- Parameters:
lockable
- a lockable node.isDeep
-true
iflockable
will be locked deep.isSessionScoped
-true
if 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:Locked
Executes the methodLocked.run(javax.jcr.Node)
within the scope of a lock held onlockable
.- Overrides:
with
in classLocked
- Parameters:
lockable
- the node where the lock is obtained from.isDeep
-true
iflockable
will 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_OUT
if the lock onlockable
could 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:Locked
Executes the methodLocked.run(javax.jcr.Node)
within the scope of a lock held onlockable
.- Overrides:
with
in classLocked
- Parameters:
lockable
- the node where the lock is obtained from.isDeep
-true
iflockable
will be locked deep.timeout
- time in milliseconds to wait at most to acquire the lock.isSessionScoped
-true
if the lock is session scoped.- Returns:
- the object returned by
Locked.run(javax.jcr.Node)
orLocked.TIMED_OUT
if the lock onlockable
could 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:
run
in classLocked
- Parameters:
node
- TheNode
on which the lock is placed.- Returns:
- an object which is then returned by
with()
. - Throws:
RepositoryException
- if an error occurs.
-
-