@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); } }
final AtomicBoolean async = new AtomicBoolean(false); async.set(false); puService.start(new StartContext() { @Override public void asynchronous() {
@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); } }
@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 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 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); } } };