Package javax.jcr.lock
Interface Lock
-
public interface LockRepresents a lock placed on an item.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetLockOwner()Returns the value of thejcr:lockOwnerproperty.StringgetLockToken()May return the lock token for this lock.NodegetNode()Returns the lock holding node.longgetSecondsRemaining()Returns the number of seconds remaining until this locks times out.booleanisDeep()Returnstrueif this is a deep lock;falseotherwise.booleanisLive()Returns true if thisLockobject represents a lock that is currently in effect.booleanisLockOwningSession()Returnstrueif the current session is the owner of this lock, either because it is session-scoped and bound to this session or open-scoped and this session currently holds the token for this lock.booleanisSessionScoped()Returnstrueif this is a session-scoped lock and the scope is bound to the current session.voidrefresh()If this lock's time-to-live is governed by a timer, this method resets that timer so that the lock does not timeout and expire.
-
-
-
Method Detail
-
getLockOwner
String getLockOwner()
Returns the value of thejcr:lockOwnerproperty. This is either the client supplied owner information (seeLockManager.lock(String, boolean, boolean, long, String)), an implementation-dependent string identifying the user who either created the lock or who is bound to the session holding the lock, ornullif none of these are available. The lock owner's identity is only provided for informational purposes. It does not govern who can perform an unlock or make changes to the locked nodes; that depends entirely upon who the token holder is.- Returns:
- a user ID.
-
isDeep
boolean isDeep()
Returnstrueif this is a deep lock;falseotherwise.- Returns:
- a boolean
-
getNode
Node getNode()
Returns the lock holding node. Note thatN.getLock().getNode()(whereNis a locked node) will only returnNifNis the lock holder. IfNis in the subgraph of the lock holder,H, then this call will returnH.- Returns:
- an
Node.
-
getLockToken
String getLockToken()
May return the lock token for this lock. If this lock is open-scoped and the current session either holds the lock token for this lock, or the repository chooses to expose the lock token to the current session, then this method will return that lock token. Otherwise this method will returnnull.- Returns:
- a
String.
-
getSecondsRemaining
long getSecondsRemaining() throws RepositoryExceptionReturns the number of seconds remaining until this locks times out. If the lock has already timed out, a negative value is returned. If the number of seconds remaining is infinite or unknown,Long.MAX_VALUEis returned.- Returns:
- the number of seconds remaining until this lock times out.
- Throws:
RepositoryException- if an error occurs.- Since:
- JCR 2.0
-
isLive
boolean isLive() throws RepositoryExceptionReturns true if thisLockobject represents a lock that is currently in effect. If this lock has been unlocked either explicitly or due to an implementation-specific limitation (like a timeout) then it returnsfalse. Note that this method is intended for those cases where one is holding aLockJava object and wants to find out whether the lock (the JCR-level entity that is attached to the lockable node) that this object originally represented still exists. For example, a timeout or explicitunlockwill remove a lock from a node but theLockJava object corresponding to that lock may still exist, and in that case itsisLivemethod will returnfalse.- Returns:
- a
boolean. - Throws:
RepositoryException- if an error occurs.
-
isSessionScoped
boolean isSessionScoped()
Returnstrueif this is a session-scoped lock and the scope is bound to the current session. Returnsfalseotherwise.- Returns:
- a
boolean.
-
isLockOwningSession
boolean isLockOwningSession()
Returnstrueif the current session is the owner of this lock, either because it is session-scoped and bound to this session or open-scoped and this session currently holds the token for this lock. Returnsfalseotherwise.- Returns:
- a
boolean. - Since:
- JCR 2.0
-
refresh
void refresh() throws LockException, RepositoryExceptionIf this lock's time-to-live is governed by a timer, this method resets that timer so that the lock does not timeout and expire. If this lock's time-to-live is not governed by a timer, then this method has no effect.- Throws:
LockException- if thisSessiondoes not hold the correct lock token for this lock.RepositoryException- if another error occurs.
-
-