@Override public T getValue() { return this.service.getValue(); } }
@Override public void stop(final StopContext context) { if (this.stopAsynchronously) { Runnable task = () -> { try { this.service.stop(context); } finally { context.complete(); } }; try { this.executor.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } } else { this.service.stop(context); } } }
@Override public void start(final StartContext context) throws StartException { if (this.startAsynchronously) { Runnable task = () -> { try { this.service.start(context); context.complete(); } catch (StartException e) { context.failed(e); } catch (Throwable e) { context.failed(new StartException(e)); } }; try { this.executor.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } } else { this.service.start(context); } }
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { try { ServiceName serviceName = managerUtil.serviceName(operation); ServiceController<?> serviceContainer = null; if(serviceName.getParent().getCanonicalName().equals(KEY_MANAGER_CAPABILITY)){ serviceContainer = getRequiredService(context.getServiceRegistry(false), serviceName, KeyManager.class); } else if (serviceName.getParent().getCanonicalName().equals(TRUST_MANAGER_CAPABILITY)) { serviceContainer = getRequiredService(context.getServiceRegistry(false), serviceName, TrustManager.class); } serviceContainer.getService().stop(null); serviceContainer.getService().start(null); } catch (Exception e) { throw new OperationFailedException(e); } } };
@Override public T getValue() { return this.service.getValue(); }
@Override public void run() { try { AsynchronousServiceBuilder.this.service.stop(context); } finally { context.complete(); } } };
final AtomicBoolean async = new AtomicBoolean(false); async.set(false); puService.start(new StartContext() { @Override public void asynchronous() {
@Override public T getValue() { return this.service.getValue(); } }
private void doServiceStop(Service puService) throws InterruptedException { final CountDownLatch stopLatch = new CountDownLatch(1); final AtomicBoolean async = new AtomicBoolean(false); puService.stop(new StopContext() { @Override public void asynchronous() throws IllegalStateException { async.set(true); } @Override public void complete() throws IllegalStateException { stopLatch.countDown(); } @Override public long getElapsedTime() { return 0; } @Override public ServiceController<?> getController() { return null; } @Override public void execute(Runnable command) { command.run(); } }); if (async.get()) { stopLatch.await(); } }
@Override public void start(final StartContext context) throws StartException { if (this.startAsynchronously) { Runnable task = new Runnable() { @Override public void run() { try { AsynchronousServiceBuilder.this.service.start(context); context.complete(); } catch (StartException e) { context.failed(e); } catch (Throwable e) { context.failed(new StartException(e)); } } }; try { this.executor.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } } else { this.service.start(context); } }
public class ServiceCaller { private String url; private Service service; public A { url = System.getProperty("url); Hashtable env = ...; Context ctx = new InitialContext(...) service = ctx.lookup(...) } public String getValue() { return service.getValue(); } ...
@Override public void stop(final StopContext context) { if (this.stopAsynchronously) { Runnable task = () -> { try { this.service.stop(context); } finally { context.complete(); } }; try { this.executor.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } } else { this.service.stop(context); } } }
@Override public void start(final StartContext context) throws StartException { if (this.startAsynchronously) { Runnable task = () -> { try { this.service.start(context); context.complete(); } catch (StartException e) { context.failed(e); } catch (Throwable e) { context.failed(new StartException(e)); } }; try { this.executor.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } } else { this.service.start(context); } }
@Override public T getValue() { return this.service.getValue(); }
@Override public void stop(final StopContext context) { if (this.stopAsynchronously) { Runnable task = new Runnable() { @Override public void run() { try { AsynchronousServiceBuilder.this.service.stop(context); } finally { context.complete(); } } }; try { this.executor.getValue().execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } } else { this.service.stop(context); } } }
@Override public void run() { try { AsynchronousServiceBuilder.this.service.start(context); context.complete(); } catch (StartException e) { context.failed(e); } catch (Throwable e) { context.failed(new StartException(e)); } } };
@Override public T getValue() { return this.service.getValue(); }
@Override public void stop( StopContext stopContext ) { //stop all the services which correspond to the inner stores ServiceContainer serviceContainer = stopContext.getController().getServiceContainer(); for (String storeName : nestedStoresValues.keySet()) { ServiceName serviceName = ModeShapeServiceNames.binaryStorageNestedServiceName(repositoryName, storeName); Service<?> service = serviceContainer.getService(serviceName).getService(); service.stop(stopContext); } } }
public S getValue() throws IllegalStateException { if (!(service instanceof Service)) { throw new UnsupportedOperationException(); } return ((Service<S>) service).getValue(); }
public S getValue() throws IllegalStateException { if (!(service instanceof Service)) { throw new UnsupportedOperationException(); } return ((Service<S>) service).getValue(); }