Package wt.locks
Class LockHelper
java.lang.Object
wt.locks.LockHelper
- All Implemented Interfaces:
Externalizable,Serializable
Provides an abstraction as the API (Application Programming Interface)
to the lock services. This API includes only class methods and must be
used accordingly. These methods can be categorized as local and remote
invocations. The local methods are getters of information, typically
from cookies, that are held in the client. The remote methods serve as
wrappers to services that promote server-side functionality to clients.
Supported API: true
Extendable: false
Supported API: true
Extendable: false
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanAn indication, passed to getSearchCondition, to build a search condition to find all locked objects.static final LockService
Supported API: truestatic final booleanAn indication, passed to getSearchCondition, to build a search condition to find all unlocked objects. -
Method Summary
Modifier and TypeMethodDescriptionstatic WTCollectionassignLock(WTCollection lockables, WTPrincipalReference locker, String note) Assigns a lock on the given lockable objects by the given principal.static LockableassignLock(Lockable object, WTPrincipalReference locker, String note) Assigns a lock on the given lockable object by the given principal.static LockableassignLock(Lockable object, WTPrincipalReference locker, String note, Timestamp date) Assigns a lock on the given lockable object to the given principal, note and date.static TimestampGets the time when the object was locked.static WTPrincipalGets the principal who placed the lock.static WTPrincipalReferencegetLockerReference(Lockable object) Gets the principal who placed the lock.static StringGets the reason why the object was locked.static SearchConditiongetSearchCondition(Class target, boolean state) Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked.static SearchConditiongetSearchCondition(Class target, WTPrincipal principal, boolean state) Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked for a given principal.static SearchConditiongetSearchCondition(Class target, WTPrincipalReference principal, boolean state) Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked for a given principal.static booleanTests if the given object has been locked.static WTCollectionreleaseLock(WTCollection objectSet) Releases the lock that has been placed on the given collection of lockable objects.static LockablereleaseLock(Lockable object) Releases the lock that has been placed on the given lockable object.
-
Field Details
-
LOCKED
public static final boolean LOCKEDAn indication, passed to getSearchCondition, to build a search condition to find all locked objects. If it is used in conjunction with a principal then the search condition is built to find all objects locked by the principal.
Supported API: true- See Also:
-
UNLOCKED
public static final boolean UNLOCKEDAn indication, passed to getSearchCondition, to build a search condition to find all unlocked objects. If it is used in conjunction with a principal then the search condition is built to find all objects not locked by the principal.
Supported API: true- See Also:
-
service
Supported API: true
-
-
Method Details
-
assignLock
public static Lockable assignLock(Lockable object, WTPrincipalReference locker, String note) throws WTException, LockException, WTPropertyVetoException Assigns a lock on the given lockable object by the given principal. This method is synchronous to allow for concurrent processing on shared lockable objects between threads.
Supported API: true- Parameters:
object-locker-note-- Returns:
- Lockable
- Throws:
WTExceptionLockExceptionWTPropertyVetoException
-
releaseLock
public static Lockable releaseLock(Lockable object) throws WTException, LockException, WTPropertyVetoException Releases the lock that has been placed on the given lockable object. This method is synchronous to allow for concurrent processing on shared lockable objects between threads.
Supported API: true- Parameters:
object-- Returns:
- Lockable
- Throws:
WTExceptionLockExceptionWTPropertyVetoException
-
isLocked
Tests if the given object has been locked.
Supported API: true- Parameters:
object-- Returns:
- boolean
- Throws:
LockException
-
getDate
Gets the time when the object was locked.
Supported API: true- Parameters:
object-- Returns:
- Timestamp
- Throws:
LockException
-
getNote
Gets the reason why the object was locked.
Supported API: true- Parameters:
object-- Returns:
- String
- Throws:
LockException
-
getLocker
Gets the principal who placed the lock. If this is done directly from an existing object, the lock of which has been set, then the principal exists within the lock and can be immediately returned. Otherwise, the object and its lock was initialized via a query and the principal does not exist within the lock. So the principal must be fetched from the database given the OID for the principal stored within the lock.
Supported API: true- Parameters:
object-- Returns:
- WTPrincipal
- Throws:
LockException
-
getLockerReference
Gets the principal who placed the lock. If this is done directly from an existing object, the lock of which has been set, then the principal exists within the lock and can be immediately returned. Otherwise, the object and its lock was initialized via a query and the principal does not exist within the lock. So the principal must be fetched from the database given the OID for the principal stored within the lock.
Supported API: true- Parameters:
object-- Returns:
- WTPrincipalReference
- Throws:
LockException
-
getSearchCondition
public static SearchCondition getSearchCondition(Class target, boolean state) throws LockException, QueryException Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked. This search condition can be used as a way to find out what objects are (un)locked regardless of who is the principal.
Supported API: true- Parameters:
target-state-- Returns:
- SearchCondition
- Throws:
LockExceptionQueryException
-
getSearchCondition
public static SearchCondition getSearchCondition(Class target, WTPrincipal principal, boolean state) throws WTException, LockException, QueryException Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked for a given principal. This search condition can be used as a way to find out what objects are (un)locked based on a particular principal.
Supported API: true- Parameters:
target-principal-state-- Returns:
- SearchCondition
- Throws:
WTExceptionLockExceptionQueryException
-
getSearchCondition
public static SearchCondition getSearchCondition(Class target, WTPrincipalReference principal, boolean state) throws WTException, LockException, QueryException Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked for a given principal. This search condition can be used as a way to find out what objects are (un)locked based on a particular principal.
Supported API: true- Parameters:
target-principal-state-- Returns:
- SearchCondition
- Throws:
WTExceptionLockExceptionQueryException
-
releaseLock
public static WTCollection releaseLock(WTCollection objectSet) throws WTException, LockException, WTPropertyVetoException Releases the lock that has been placed on the given collection of lockable objects.
Supported API: true- Parameters:
objectSet-- Returns:
- WTCollection
- Throws:
WTExceptionLockExceptionWTPropertyVetoException- See Also:
-
releaseLock(Lockable object)
-
assignLock
public static WTCollection assignLock(WTCollection lockables, WTPrincipalReference locker, String note) throws LockException Assigns a lock on the given lockable objects by the given principal. This method is synchronous to allow for concurrent processing on shared lockable objects between threads.
Supported API: true- Parameters:
lockables-locker-note-- Returns:
- WTCollection
- Throws:
LockException
-
assignLock
public static Lockable assignLock(Lockable object, WTPrincipalReference locker, String note, Timestamp date) throws WTException, LockException, WTPropertyVetoException Assigns a lock on the given lockable object to the given principal, note and date. If the principal is null the current session principal is used. If the date is null the current system time down to milliseconds is used. This method is only intended to be used when loading information into the lockable object before it is persisted. Otherwise, if it is already persistent an exception will occur. This method is synchronous to allow for concurrent processing on shared lockable objects between threads.
Supported API: true- Parameters:
object-locker-note-date-- Returns:
- Lockable
- Throws:
WTExceptionLockExceptionWTPropertyVetoException
-