public class XALockManager extends Object implements LockManager, InternalXAResource
Constructor and Description |
---|
XALockManager(LockManagerImpl lockMgr)
Create a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
addLockToken(SessionImpl session,
String lt)
Invoked by a session to inform that a lock token has been added.
|
void |
afterOperation(TransactionContext tx)
|
void |
associate(TransactionContext tx)
Associate this resource with a transaction.
|
void |
beforeOperation(TransactionContext tx)
|
void |
checkLock(NodeImpl node)
Check whether the node given is locked by somebody else than the
current session.
|
void |
checkLock(Path path,
Session session)
Check whether the path given is locked by somebody else than the
session described.
|
void |
checkUnlock(Session session,
NodeImpl node)
Check whether a session is allowed to unlock a node.
|
void |
commit(TransactionContext tx)
Commit transaction.
|
boolean |
differentXAEnv(LockInfo info)
Return a flag indicating whether a lock info belongs to a different
XA environment.
|
Lock |
getLock(NodeImpl node)
Returns the Lock object that applies to a node.
|
Lock[] |
getLocks(SessionImpl session)
Returns all locks owned by the specified session.
|
boolean |
holdsLock(NodeImpl node)
Returns
true if the node given holds a lock;
otherwise returns false . |
boolean |
isLocked(NodeImpl node)
Returns
true if this node is locked either as a result
of a lock held by this node or by a deep lock on a node above this
node; otherwise returns false |
Lock |
lock(NodeImpl node,
boolean isDeep,
boolean isSessionScoped)
Lock a node.
|
Lock |
lock(NodeImpl node,
boolean isDeep,
boolean isSessionScoped,
long timoutHint,
String ownerInfo)
Lock a node.
|
void |
prepare(TransactionContext tx)
Prepare transaction.
|
void |
removeLockToken(SessionImpl session,
String lt)
Invoked by a session to inform that a lock token has been removed.
|
void |
rollback(TransactionContext tx)
Rollback transaction.
|
void |
unlock(NodeImpl node)
Removes the lock on a node given by its path.
|
public XALockManager(LockManagerImpl lockMgr)
lockMgr
- lockMgr global lock managerpublic Lock lock(NodeImpl node, boolean isDeep, boolean isSessionScoped) throws LockException, RepositoryException
lock
in interface LockManager
node
- nodeisDeep
- whether the lock applies to this node onlyisSessionScoped
- whether the lock is session scopedLockException
- if this node already is locked, or some descendant
node is locked and isDeep
is true
RepositoryException
Node.lock(boolean, boolean)
public Lock lock(NodeImpl node, boolean isDeep, boolean isSessionScoped, long timoutHint, String ownerInfo) throws LockException, RepositoryException
LockManager
lock
in interface LockManager
node
- Node to create the lock for.isDeep
- whether the lock applies to this node onlyisSessionScoped
- whether the lock is session scopedtimoutHint
- Desired lock timeout in seconds.ownerInfo
- Optional string acting as information about the owner.LockException
- if this node already is locked, or some descendant
node is locked and isDeep
is true
RepositoryException
LockManager.lock(NodeImpl, boolean, boolean, long, String)
public Lock getLock(NodeImpl node) throws LockException, RepositoryException
getLock
in interface LockManager
node
- nodeLockException
- if this node is not lockedRepositoryException
Node.getLock()
public Lock[] getLocks(SessionImpl session) throws RepositoryException
getLocks
in interface LockManager
session
- sessionRepositoryException
- if an error occursSessionImpl.getLocks()
public void unlock(NodeImpl node) throws LockException, RepositoryException
unlock
in interface LockManager
node
- nodeLockException
- if this node is not locked or the session
does not have the correct lock tokenRepositoryException
Node.unlock()
public boolean holdsLock(NodeImpl node) throws RepositoryException
true
if the node given holds a lock;
otherwise returns false
.holdsLock
in interface LockManager
node
- nodetrue
if the node given holds a lock;
otherwise returns false
RepositoryException
- If an exception occurs.Node.holdsLock()
public boolean isLocked(NodeImpl node) throws RepositoryException
true
if this node is locked either as a result
of a lock held by this node or by a deep lock on a node above this
node; otherwise returns false
isLocked
in interface LockManager
node
- nodetrue
if this node is locked either as a result
of a lock held by this node or by a deep lock on a node above this
node; otherwise returns false
RepositoryException
- If an exception occurs.Node.isLocked()
public void checkLock(NodeImpl node) throws LockException, RepositoryException
checkLock
in interface LockManager
node
- node to checkLockException
- if write access to the specified node is not allowedRepositoryException
- if some other error occurspublic void checkLock(Path path, Session session) throws LockException, RepositoryException
checkLock
in interface LockManager
path
- path to checksession
- sessionLockException
- if write access to the specified path is not allowedRepositoryException
- if some other error occurspublic void checkUnlock(Session session, NodeImpl node) throws LockException, RepositoryException
checkUnlock
in interface LockManager
LockException
- if unlocking is deniedRepositoryException
- if some other error occurspublic void addLockToken(SessionImpl session, String lt) throws RepositoryException
addLockToken
in interface LockManager
session
- session that has a added lock tokenlt
- added lock tokenLockException
RepositoryException
public void removeLockToken(SessionImpl session, String lt) throws RepositoryException
removeLockToken
in interface LockManager
session
- session that has a removed lock tokenlt
- removed lock tokenLockException
RepositoryException
public void associate(TransactionContext tx)
associate
in interface InternalXAResource
tx
- transaction context, if null
disassociatepublic void beforeOperation(TransactionContext tx)
InternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext)
, InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)
or
InternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)
method is called.beforeOperation
in interface InternalXAResource
tx
- transaction contextpublic void prepare(TransactionContext tx) throws TransactionException
prepare
in interface InternalXAResource
tx
- transaction contextTransactionException
- if an error occurspublic void commit(TransactionContext tx)
This will finish the update and unlock the shared lock manager.
commit
in interface InternalXAResource
tx
- transaction contextpublic void rollback(TransactionContext tx)
This will undo all updates and unlock the shared lock manager.
rollback
in interface InternalXAResource
tx
- transaction context.public void afterOperation(TransactionContext tx)
InternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext)
, InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)
or
InternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)
method has been called.afterOperation
in interface InternalXAResource
tx
- transaction contextpublic boolean differentXAEnv(LockInfo info)
Copyright © 2004–2021 The Apache Software Foundation. All rights reserved.