Move locking into separate class

Patch set moves the locking into a dedicated class, removing the duplicity between ServiceObject and RoleObject. This will also make lock debugging a bit easier.