[Core, Locking]: Refactoring for supporting RestXQ
Merge pull request #687 from JensErat/visitor-locking

[Core, Locking]: Refactoring for supporting RestXQ