本文整理了Java中javax.jcr.Node.lock()
方法的一些代码示例,展示了Node.lock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.lock()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:lock
[英]Places a lock on this node. If successful, this node is said to hold the lock.
If isDeep
is true
then the lock applies to this node and all its descendant nodes; if false
, the lock applies only to this, the holding node.
If isSessionScoped
is true
then this lock will expire upon the expiration of the current session (either through an automatic or explicit Session.logout
); if false
, this lock does not expire until explicitly unlocked or automatically unlocked due to a implementation-specific limitation, such as a timeout.
Returns a Lock
object reflecting the state of the new lock.
If the lock is open-scoped the returned lock will include a lock token.
The lock token is also automatically added to the set of lock tokens held by the current Session
.
If successful, then the property jcr:lockOwner
is created and set to the value of Session.getUserID
for the current session and the property jcr:lockIsDeep
is set to the value passed in as isDeep
. These changes are persisted automatically; there is no need to call save
.
Note that it is possible to lock a node even if it is checked-in (the lock-related properties will be changed despite the checked-in status).
[中]将锁定此节点。如果成功,则称该节点持有锁。
如果isDeep
为true
,则锁将应用于此节点及其所有子节点;如果false
,则锁仅适用于该持有节点。
如果isSessionScoped
为true
,则此锁将在当前会话到期时过期(通过自动或显式Session.logout
);如果false
,此锁在显式解锁或由于特定于实现的限制(如超时)而自动解锁之前不会过期。
返回一个Lock
对象,反映新锁的状态。
如果锁的作用域是打开的,则返回的锁将包含一个锁令牌。
锁令牌也会自动添加到当前Session
持有的锁令牌集中。
如果成功,则为当前会话创建属性jcr:lockOwner
,并将其设置为Session.getUserID
的值,并且将属性jcr:lockIsDeep
设置为作为isDeep
传入的值。这些变化会自动保持;无需致电save
。
请注意,即使节点已签入,也可以锁定该节点(尽管处于签入状态,但与锁定相关的属性仍将更改)。
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Lock lock(boolean isDeep, boolean isSessionScoped) throws LockException, RepositoryException {
return this.node.lock(isDeep, isSessionScoped);
}
代码示例来源:origin: nl.vpro/jcr-criteria
@Override
@Deprecated
public Lock lock(boolean isDeep, boolean isSessionScoped) throws RepositoryException {
return getNode().lock(isDeep, isSessionScoped);
}
代码示例来源:origin: apache/jackrabbit
public Object run() throws RepositoryException {
Node n = getNode(nodeId, sInfo);
Lock lock = n.lock(deep, sessionScoped);
return LockInfoImpl.createLockInfo(lock, idFactory);
}
}, sInfo);
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr
public Object run() throws RepositoryException {
Node n = getNode(nodeId, sInfo);
Lock lock = n.lock(deep, sessionScoped);
return LockInfoImpl.createLockInfo(lock, idFactory);
}
}, sInfo);
代码示例来源:origin: brix-cms/brix-cms
public Lock execute() throws Exception {
return getDelegate().lock(isDeep, isSessionScoped);
}
});
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
return getWrappedNode().lock(isDeep, isSessionScoped);
}
代码示例来源:origin: apache/jackrabbit
private Node getLockedChildNode() throws NotExecutableException, RepositoryException {
checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
Node child = testRootNode.addNode(nodeName2, testNodeType);
ensureMixinType(child, mixLockable);
testRootNode.getSession().save();
child.lock(false, true); // session-scoped lock clean upon superuser-logout.
return child;
}
代码示例来源:origin: apache/jackrabbit
private Node getLockedChildNode() throws NotExecutableException, RepositoryException {
checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
Node child = testRootNode.addNode(nodeName2, testNodeType);
ensureMixinType(child, mixLockable);
testRootNode.getSession().save();
child.lock(false, true); // session-scoped lock clean upon superuser-logout.
return child;
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public RemoteLock lock(boolean isDeep, boolean isSessionScoped)
throws RepositoryException, RemoteException {
try {
Lock lock = node.lock(isDeep, isSessionScoped);
return getFactory().getRemoteLock(lock);
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
代码示例来源:origin: apache/jackrabbit
private Node createLockedNode(Node parent) throws RepositoryException, NotExecutableException {
Node n = createLockableNode(parent);
// create a deep, session scoped lock
n.lock(true, true);
return n;
}
代码示例来源:origin: brix-cms/brix-cms
/**
* @deprecated
*/
@Deprecated
public Lock lock(boolean isDeep, boolean isSessionScoped) throws RepositoryException {
getActionHandler().beforeNodeLock(this, isDeep, isSessionScoped);
Lock result = getDelegate().lock(isDeep, isSessionScoped);
getActionHandler().afterNodeLock(this, isDeep, isSessionScoped, result);
return result;
}
代码示例来源:origin: apache/jackrabbit
public void execute(Session session, Node test) throws RepositoryException {
Node n = test.addNode("test");
n.addMixin(mixLockable);
session.save();
for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
n.lock(false, true);
n.unlock();
}
}
}, CONCURRENCY);
代码示例来源:origin: ModeShape/modeshape
@SuppressWarnings( "deprecation" )
protected void lock( Node node,
boolean isDeep,
boolean isSessionScoped ) throws RepositoryException {
if (useDeprecatedApi()) {
node.lock(isDeep, isSessionScoped);
} else {
session.getWorkspace().getLockManager().lock(node.getPath(), isDeep, isSessionScoped, 1L, "owner");
}
}
代码示例来源:origin: apache/jackrabbit
public void execute(Session session, Node test) throws RepositoryException {
// add versionable nodes
for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
Node n = test.addNode("test" + i);
n.addMixin(mixLockable);
session.save();
Lock l = n.lock(false, true);
l.refresh();
n.unlock();
}
}
}, CONCURRENCY);
代码示例来源:origin: apache/jackrabbit
public void execute(Session session, Node test) throws RepositoryException {
Node n = test.addNode("test");
n.addMixin(mixLockable);
session.save();
for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
if (n.isLocked()) {
n.unlock();
}
n.lock(false, true);
}
}
}, CONCURRENCY);
代码示例来源:origin: apache/jackrabbit
@Override
protected void setUp() throws Exception {
super.setUp();
lockedNode = testRootNode.addNode(nodeName1, testNodeType);
lockedNode.addMixin(mixLockable);
childNode = lockedNode.addNode(nodeName2, testNodeType);
testRootNode.save();
lock = lockedNode.lock(isDeep, isSessionScoped);
}
代码示例来源:origin: apache/jackrabbit
public void testLock2() throws RepositoryException, NotExecutableException {
Node n = createLockableNode(testRootNode);
modifyPrivileges(n.getPath(), PrivilegeRegistry.REP_WRITE, false);
modifyPrivileges(n.getPath(), Privilege.JCR_LOCK_MANAGEMENT, true);
Node n2 = getTestNode().getNode(nodeName1);
// all lock operations must succeed
Lock l = n2.lock(true, true);
l.refresh();
n2.unlock();
}
代码示例来源:origin: apache/jackrabbit
public void testParentChildDeepLock() throws RepositoryException {
childNode.addMixin(mixLockable);
testRootNode.save();
// try to lock child node
try {
childNode.lock(false, isSessionScoped);
fail("child node is already locked by deep lock on parent.");
} catch (LockException e) {
// ok
}
}
代码示例来源:origin: apache/jackrabbit
@Override
protected void setUp() throws Exception {
super.setUp();
otherSession = getHelper().getSuperuserSession();
lockedNode = testRootNode.addNode(nodeName1, testNodeType);
lockedNode.addMixin(mixLockable);
childNode = lockedNode.addNode(nodeName2, testNodeType);
testRootNode.save();
lock = lockedNode.lock(false, isSessionScoped());
}
代码示例来源:origin: apache/jackrabbit
public void testParentChildLock2() throws Exception {
childNode.addMixin(mixLockable);
testRootNode.save();
try {
Lock l = childNode.lock(false, isSessionScoped());
assertTrue("child node must still hold lock", l.getNode().isSame(childNode));
} finally {
childNode.unlock();
}
}
内容来源于网络,如有侵权,请联系作者删除!