use of com.b2international.snowowl.core.locks.DefaultOperationLockManager in project snow-owl by b2ihealthcare.
the class LockPlugin method preRun.
@Override
public void preRun(SnowOwlConfiguration configuration, Environment env) throws Exception {
if (env.isServer()) {
final Index locksIndex = Indexes.createIndex(LOCKS_INDEX, env.service(ObjectMapper.class), new Mappings(DatastoreLockIndexEntry.class), env.service(IndexSettings.class).forIndex(env.service(RepositoryConfiguration.class).getIndexConfiguration(), LOCKS_INDEX));
final DefaultOperationLockManager lockManager = new DefaultOperationLockManager(locksIndex);
final RemoteLockTargetListener remoteLockTargetListener = new RemoteLockTargetListener();
lockManager.addLockTargetListener(new Slf4jOperationLockTargetListener());
lockManager.addLockTargetListener(remoteLockTargetListener);
env.services().registerService(IOperationLockManager.class, lockManager);
final RpcSession session = RpcUtil.getInitialServerSession(env.container());
session.registerClassLoader(IOperationLockManager.class, DefaultOperationLockManager.class.getClassLoader());
} else {
env.services().registerService(IOperationLockManager.class, RpcUtil.createProxy(env.container(), IOperationLockManager.class));
}
}
Aggregations