org.jboss.msc.service.StopContext Java Examples

The following examples show how to use org.jboss.msc.service.StopContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteDomainConnectionService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public synchronized void stop(final StopContext context) {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            try {
                StreamUtils.safeClose(connection);
                responseAttachmentSupport.shutdown();
            } finally {
                context.complete();
            }
        }
    };
    try {
        executor.execute(r);
    } catch (RejectedExecutionException e) {
        r.run();
    } finally {
        context.asynchronous();
    }
}
 
Example #2
Source File: HostControllerConnectionService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public synchronized void stop(final StopContext stopContext) {
    final ExecutorService executorService = executorSupplier.get();
    final Runnable task = new Runnable() {
        @Override
        public void run() {
            try {
                responseAttachmentSupport.shutdown();
            } finally {
                StreamUtils.safeClose(client);
                client = null;
                stopContext.complete();
            }
        }
    };
    try {
        executorService.execute(task);
    } catch (RejectedExecutionException e) {
        task.run();
    } finally {
        stopContext.asynchronous();
    }
}
 
Example #3
Source File: WorkerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void stopDone() {
    synchronized (stopLock) {
        final StopContext stopContext = this.stopContext;
        this.stopContext = null;
        if (stopContext != null) {
            stopContext.complete();
        }
        stopLock.notifyAll();
    }
}
 
Example #4
Source File: UnboundedQueueThreadPoolService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void stop(final StopContext context) {
    final ManagedJBossThreadPoolExecutorService executor;
    synchronized (this) {
        executor = this.executor;
        this.executor = null;
    }
    context.asynchronous();
    executor.internalShutdown();
    executor.addShutdownListener(StopContextEventListener.getInstance(), context);
}
 
Example #5
Source File: CatalogWatcher.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(StopContext stopContext) {
    this.thread.interrupt();

    this.watchers.entrySet().forEach(e -> {
        try {
            e.getValue().stop();
        } catch (Exception ex) {
            ConsulTopologyMessages.MESSAGES.errorStoppingCatalogWatcher(e.getKey(), ex);
        }
    });
}
 
Example #6
Source File: DeploymentUnitPhaseService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public synchronized void stop(final StopContext context) {
    final DeploymentUnit deploymentUnitContext = deploymentUnit;
    final DeployerChains chains = deployerChainsInjector.getValue();
    final List<RegisteredDeploymentUnitProcessor> list = chains.getChain(phase);
    final ListIterator<RegisteredDeploymentUnitProcessor> iterator = list.listIterator(list.size());
    while (iterator.hasPrevious()) {
        final RegisteredDeploymentUnitProcessor prev = iterator.previous();
        safeUndeploy(deploymentUnitContext, phase, prev);
    }
}
 
Example #7
Source File: PlugInLoaderService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void stop(final StopContext context) {
    plugInLoaderServiceConsumer.accept(null);
    // Clear any cached data so it can be reloaded on next start.
    cachedProviders.clear();
    authenticationProviders.clear();
    authorizationProviders.clear();
}
 
Example #8
Source File: LdapConnectionManagerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(final StopContext context) {
    try {
        context.execute(new Runnable() {
            @Override
            public void run() {
                connectionManagerRegistry.removeLdapConnectionManagerService(name);
                ldapConnectionManagerConsumer.accept(null);
                context.complete();
            }
        });
    } finally {
        context.asynchronous();
    }
}
 
Example #9
Source File: ExternalModuleSpecService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void stop(StopContext context) {
    for (JarFile jarFile : jarFiles) {
        log.debugf("Closing %s jar file which was added as resource root for %s module identifier", jarFile.getName(), moduleIdentifier.getName());
        VFSUtils.safeClose(jarFile);
    }
    jarFiles.clear();
    jarFiles = null;
    moduleDefinition = null;
}
 
Example #10
Source File: SecurityRealmService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(final StopContext context) {
    ROOT_LOGGER.debugf("Stopping '%s' Security Realm Service", name);
    if (securityRealmConsumer != null) {
        // TODO: eliminate above null check when WildFly code base is migrated to new MSC API
        securityRealmConsumer.accept(null);
    }
    registeredServices.clear();
    saslAuthenticationFactory = null;
    httpAuthenticationFactory.shutdownAuthenticationMechanismFactory();
    httpAuthenticationFactory = null;
}
 
Example #11
Source File: KeyStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(StopContext stopContext) {
    ROOT_LOGGER.tracef(
            "stopping:  keyStore = %s  unmodifiableKeyStore = %s  trackingKeyStore = %s  pathResolver = %s",
            keyStore, unmodifiableKeyStore, trackingKeyStore, pathResolver
    );
    keyStore = null;
    unmodifiableKeyStore = null;
    trackingKeyStore = null;
    if (pathResolver != null) {
        pathResolver.clear();
        pathResolver = null;
    }
}
 
Example #12
Source File: FilteringKeyStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(StopContext stopContext) {

    ROOT_LOGGER.tracef(
            "stopping:  filteringKeyStore = %s  modifiableFilteringKeyStore = %s",
            filteringKeyStore, modifiableFilteringKeyStore
    );

    filteringKeyStore = null;
    modifiableFilteringKeyStore = null;
}
 
Example #13
Source File: AbstractControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void stop(final StopContext context) {
    capabilityRegistry.clear();
    capabilityRegistry.publish();
    ServiceNameFactory.clearCache();
    controller = null;
    stabilityMonitor = null;
    processState.setStopping();
    Runnable r = new Runnable() {
        @Override
        public void run() {
            try {
                stopAsynchronous(context);
            } finally {
                try {
                    authorizer.shutdown();
                } finally {
                    context.complete();
                }
            }
        }
    };
    final ExecutorService executorService = this.executorService != null ? this.executorService.get() : null;
    try {
        if (executorService != null) {
            try {
                executorService.execute(r);
            } catch (RejectedExecutionException e) {
                r.run();
            }
        } else {
            Thread executorShutdown = new Thread(r, getClass().getSimpleName() + " Shutdown Thread");
            executorShutdown.start();
        }
    } finally {
        processState.setStopped();
        context.asynchronous();
    }
}
 
Example #14
Source File: RemotingHttpUpgradeService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void stop(final StopContext context) {
    serviceConsumer.accept(null);
    listenerRegistrySupplier.get().getListener(httpConnectorName).removeHttpUpgradeMetadata(httpUpgradeMetadata);
    httpUpgradeMetadata = null;
    upgradeRegistrySupplier.get().removeProtocol(JBOSS_REMOTING);
}
 
Example #15
Source File: ManagementWorkerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(StopContext context) {
    this.stopContext = context;
    context.asynchronous();
    worker.shutdown();
    worker = null;
}
 
Example #16
Source File: DaemonService.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(StopContext context) {
    try {
        this.server.stop();
    } catch (ServerLifecycleException | InterruptedException e) {
        throw new RuntimeException(e);
    }
}
 
Example #17
Source File: DomainModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(final StopContext context) {
    synchronized (serverInventoryLock) {
        try {
            serverInventory = null;
            serverInventoryLock.set(false);
        } finally {
            serverInventoryLock.notifyAll();
        }
    }
    extensionRegistry.clear();
    domainConfigAvailable.set(false);
    super.stop(context);
}
 
Example #18
Source File: CamelContextActivationService.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(StopContext context) {
    Collections.reverse(bootstraps);
    for (SpringCamelContextBootstrap bootstrap: bootstraps) {
        List<SpringCamelContext> camelctxList = bootstrap.getSpringCamelContexts();
        for (CamelContext camelctx : camelctxList) {
            try {
                camelctx.close();
            } catch (Exception ex) {
                LOGGER.warn("Cannot stop camel context: " + camelctx.getName(), ex);
            }
        }
    }
}
 
Example #19
Source File: CamelEndpointDeployerService.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(StopContext context) {
    synchronized (deployments) {
        for (DeploymentManager deploymentManager : deployments.values()) {
            undeploy(deploymentManager);
        }
        deployments.clear();
    }
}
 
Example #20
Source File: CredentialStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(StopContext stopContext) {
    if (ROOT_LOGGER.isTraceEnabled()) {
        ROOT_LOGGER.tracef("stopping CredentialStore:  name = %s  credentialStore = %s", name, credentialStore.get());
    }
    if (callbackHandle != null) {
        callbackHandle.remove();
    }
    credentialStore.set(null);
}
 
Example #21
Source File: CatalogWatcher.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public void stop(StopContext stopContext) {
    this.thread.interrupt();

    this.watchers.values().forEach(e -> {
        try {
            e.stop();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    });
}
 
Example #22
Source File: HostControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(StopContext context) {
    String prettyVersion = environment.getProductConfig().getPrettyVersionString();
    //Moved to AbstractControllerService.stop()
    //processState.setStopping();
    ServerLogger.AS_ROOT_LOGGER.serverStopped(prettyVersion, Integer.valueOf((int) (context.getElapsedTime() / 1000000L)));
    BootstrapListener.deleteStartupMarker(environment.getDomainTempDir());
}
 
Example #23
Source File: ProcessApplicationDeploymentService.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void stop(final StopContext context) {
  context.asynchronous();
  executorInjector.getValue().submit(new Runnable() {
    public void run() {
      try {
        performUndeployment();
      } finally {
        context.complete();
      }
    }
  });
}
 
Example #24
Source File: ServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void stop(final StopContext context) {

    if (executorService != null) {
        context.asynchronous();
        Thread executorShutdown = new Thread(new Runnable() {
            @Override
            public void run() {
                boolean interrupted = false;
                try {
                    executorService.shutdown();
                    // Hack. Give in progress tasks a brief period to complete before we
                    // interrupt threads via shutdownNow
                    executorService.awaitTermination(100, TimeUnit.MILLISECONDS);
                } catch (InterruptedException e) {
                    interrupted = true;
                } finally {
                    try {
                        List<Runnable> tasks = executorService.shutdownNow();
                        executorService = null;
                        if (!interrupted) {
                            for (Runnable task : tasks) {
                                ServerLogger.AS_ROOT_LOGGER.debugf("%s -- Discarding unexecuted task %s", getClass().getSimpleName(), task);
                            }
                        }
                    } finally {
                        context.complete();
                    }
                }
            }
        }, "ServerExecutorService Shutdown Thread");
        executorShutdown.start();
    }
}
 
Example #25
Source File: AbstractStreamServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(final StopContext context) {
    streamServerConsumer.accept(null);
    IoUtils.safeClose(streamServer);
    SocketBindingManager sbm = socketBindingManagerSupplier != null ? socketBindingManagerSupplier.get() : null;
    if (sbm != null && managedBinding != null) {
        unregisterSocketBinding(managedBinding, sbm);
    }
}
 
Example #26
Source File: EnhancedQueueExecutorService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void stop(final StopContext context) {
    final ManagedEnhancedQueueExecutor executor;
    synchronized (this) {
        executor = this.executor;
        this.executor = null;
    }
    context.asynchronous();
    executor.internalShutdown();
    executor.addShutdownListener(StopContextEventListener.getInstance(), context);
}
 
Example #27
Source File: ProviderRegistrationService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void stop(StopContext context) {
    Iterator<String> namesIterator = registeredProviderNames.iterator();
    SecurityActions.doPrivileged((PrivilegedAction<Void>) () -> {
        while (namesIterator.hasNext()) {
            Security.removeProvider(namesIterator.next());
            namesIterator.remove();
        }
        return null;
    });
}
 
Example #28
Source File: PropertiesFileLoader.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void stop(StopContext context) {
    properties.clear();
    properties = null;
    propertiesFile = null;
}
 
Example #29
Source File: UndertowSSLService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public synchronized void stop(final StopContext context) {
    undertow.stop();
    undertow = null;
}
 
Example #30
Source File: DomainModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void stopAsynchronous(StopContext context)  {
    pingScheduler.shutdownNow();
}