org.apache.jackrabbit.util
Class LockedWrapper<T>

java.lang.Object
  extended by org.apache.jackrabbit.util.Locked
      extended by org.apache.jackrabbit.util.LockedWrapper<T>

public abstract class LockedWrapper<T>
extends Locked

LockedWrapper is a wrapper class to Locked which adds generics support and wraps the Locked.TIMED_OUT object into a LockException.


Field Summary
 
Fields inherited from class org.apache.jackrabbit.util.Locked
TIMED_OUT
 
Constructor Summary
LockedWrapper()
           
 
Method Summary
protected abstract  T run(Node node)
          This method is executed while holding the lock.
 T with(Node lockable, boolean isDeep)
          Executes Locked.run(javax.jcr.Node) while the lock on lockable is held.
 T with(Node lockable, boolean isDeep, boolean isSessionScoped)
          Executes Locked.run(javax.jcr.Node) while the lock on lockable is held.
 T with(Node lockable, boolean isDeep, long timeout)
          Executes the method Locked.run(javax.jcr.Node) within the scope of a lock held on lockable.
 Object with(Node lockable, boolean isDeep, long timeout, boolean isSessionScoped)
          Executes the method Locked.run(javax.jcr.Node) within the scope of a lock held on lockable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockedWrapper

public LockedWrapper()
Method Detail

with

public T with(Node lockable,
              boolean isDeep)
       throws RepositoryException,
              InterruptedException
Description copied from class: Locked
Executes Locked.run(javax.jcr.Node) while the lock on lockable is held. This method will block until Locked.run(javax.jcr.Node) is executed while holding the lock on node lockable.

Overrides:
with in class Locked
Parameters:
lockable - a lockable node.
isDeep - true if lockable will be locked deep.
Returns:
the object returned by Locked.run(javax.jcr.Node).
Throws:
RepositoryException - if Locked.run(javax.jcr.Node) throws an exception.
InterruptedException - if this thread is interrupted while waiting for the lock on node lockable.

with

public T with(Node lockable,
              boolean isDeep,
              boolean isSessionScoped)
       throws RepositoryException,
              InterruptedException
Description copied from class: Locked
Executes Locked.run(javax.jcr.Node) while the lock on lockable is held. This method will block until Locked.run(javax.jcr.Node) is executed while holding the lock on node lockable.

Overrides:
with in class Locked
Parameters:
lockable - a lockable node.
isDeep - true if lockable will be locked deep.
isSessionScoped - true if the lock is session scoped.
Returns:
the object returned by Locked.run(javax.jcr.Node).
Throws:
RepositoryException - if Locked.run(javax.jcr.Node) throws an exception.
InterruptedException - if this thread is interrupted while waiting for the lock on node lockable.

with

public T with(Node lockable,
              boolean isDeep,
              long timeout)
       throws UnsupportedRepositoryOperationException,
              RepositoryException,
              InterruptedException
Description copied from class: Locked
Executes the method Locked.run(javax.jcr.Node) within the scope of a lock held on lockable.

Overrides:
with in class Locked
Parameters:
lockable - the node where the lock is obtained from.
isDeep - true if lockable 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) or Locked.TIMED_OUT if the lock on lockable could not be acquired within the specified timeout.
Throws:
UnsupportedRepositoryOperationException - if this repository does not support locking.
RepositoryException - if Locked.run(javax.jcr.Node) throws an exception.
InterruptedException - if this thread is interrupted while waiting for the lock on node lockable.

with

public Object with(Node lockable,
                   boolean isDeep,
                   long timeout,
                   boolean isSessionScoped)
            throws UnsupportedRepositoryOperationException,
                   RepositoryException,
                   InterruptedException
Description copied from class: Locked
Executes the method Locked.run(javax.jcr.Node) within the scope of a lock held on lockable.

Overrides:
with in class Locked
Parameters:
lockable - the node where the lock is obtained from.
isDeep - true if lockable 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) or Locked.TIMED_OUT if the lock on lockable could not be acquired within the specified timeout.
Throws:
UnsupportedRepositoryOperationException - if this repository does not support locking.
RepositoryException - if Locked.run(javax.jcr.Node) throws an exception.
InterruptedException - if this thread is interrupted while waiting for the lock on node lockable.

run

protected abstract T run(Node node)
                  throws RepositoryException
This method is executed while holding the lock.

Specified by:
run in class Locked
Parameters:
node - The Node on which the lock is placed.
Returns:
an object which is then returned by with().
Throws:
RepositoryException - if an error occurs.


Copyright © 2011-2013 Adobe Systems Incorporated. All Rights Reserved.