So to answer my original question: It is possible but not in 2.2.9.
See https://issues.apache.org/jira/browse/JCR-2859
Following code sample should do it:
LockManager lockManager =
session.getWorkspace().getLockManager();
Lock lock = null;
try {
lock = lockManager.getLock(node.getPath());
} catch (LockException ex) {
}
if (lock != null) {
lockManager.addLockToken(lock.getLockToken());
lockManager.unlock(node.getPath());
}
Unfortunately from Jackrabbit JIRA I am not able to say in which version is
will appear. (Of course I could backport this
patch and it should work as it is simple.) But as I said above I will use in
memory locking because it is what I need. I do not need persistent locking when
only one application writes to repository.
Marek