@Test public void world() throws Exception { Map<String, String> conf = new HashMap<>(); conf.put(BasicLockProvider.KEY_DIRECTORY, folder.getRoot().getAbsolutePath()); conf.put(ExecutionLockProvider.KEY_SCOPE, ExecutionLock.Scope.WORLD.getSymbol()); ServiceProfile<ExecutionLockProvider> profile = new ServiceProfile<>( "testing", BasicLockProvider.class, conf, ProfileContext.system(getClass().getClassLoader())); ExecutionLockProvider instance1 = profile.newInstance(); ExecutionLockProvider instance2 = profile.newInstance(); try (ExecutionLock lock = instance1.newInstance("batch1")) { try { instance2.newInstance("batch1"); fail("cannot run same batch"); } catch (IOException e) { } try { instance2.newInstance("batch2"); fail("cannot run any batch"); } catch (IOException e) { } lock.beginFlow("flow1", "exec1"); lock.beginFlow("flow2", "exec1"); try { lock.beginFlow("flow1", "exec1"); fail("cannot reentrant same flow"); } catch (IOException e) { } } }
@Override protected ExecutionLock newInstance(Scope lockScope, String batchId) throws IOException { if (lockScope == null) { throw new IllegalArgumentException("lockScope must not be null"); } if (batchId == null) { throw new IllegalArgumentException("batchId must not be null"); } return new FileExecutionLock(lockScope, batchId, directory); }
BasicLockProvider extends ExecutionLockProvider { @Override protected ExecutionLock newInstance(Scope lockScope, String batchId) throws IOException { if (lockScope == null) { throw new IllegalArgumentException("lockScope must not be null"); } if (batchId == null) { throw new IllegalArgumentException("batchId must not be null"); } return new FileExecutionLock(lockScope, batchId, directory); } }
BasicLockProvider extends ExecutionLockProvider { @Override protected ExecutionLock newInstance(Scope lockScope, String batchId) throws IOException { if (lockScope == null) { throw new IllegalArgumentException("lockScope must not be null"); } if (batchId == null) { throw new IllegalArgumentException("batchId must not be null"); } return new FileExecutionLock(lockScope, batchId, directory); }  }
BasicLockProvider extends ExecutionLockProvider { @Override protected ExecutionLock newInstance(Scope lockScope, String batchId) throws IOException { if (lockScope == null) { throw new IllegalArgumentException("lockScope must not be null"); } if (batchId == null) { throw new IllegalArgumentException("batchId must not be null"); } return new FileExecutionLock(lockScope, batchId, directory); }  @Override void doConfigure(ServiceProfile<?> profile); }
BasicLockProvider extends ExecutionLockProvider { @Override protected ExecutionLock newInstance(Scope lockScope, String batchId) throws IOException { if (lockScope == null) { throw new IllegalArgumentException("lockScope must not be null"); } if (batchId == null) { throw new IllegalArgumentException("batchId must not be null"); } return new FileExecutionLock(lockScope, batchId, directory); }  @Override void doConfigure(ServiceProfile<?> profile); static final String KEY_DIRECTORY; }