@Override public void stop(final StopContext stopContext) { // The service stop can trigger the web app context destruction which involves blocking tasks like servlet context destruction, startup servlet // destruction lifecycles and such. Hence this needs to be done asynchronously to prevent the MSC threads from blocking stopContext.asynchronous(); serverExecutor.getValue().submit(new Runnable() { @Override public void run() { try { stopContext(); } finally { stopContext.complete(); } } }); }
@Override public void start(StartContext startContext) throws StartException { HttpHandler handler = remoteHttpInvokerServiceInjectedValue.getValue(); if(httpAuthenticationFactoryInjectedValue.getOptionalValue() != null) { handler = secureAccess(handler, httpAuthenticationFactoryInjectedValue.getOptionalValue()); } else if(realmService.getOptionalValue() != null) { handler = secureAccess(handler, realmService.getOptionalValue().getHttpAuthenticationFactory()); } handler = setupRoutes(handler); host.getValue().registerHandler(path, handler); host.getValue().registerLocation(path); }
@Override protected BasicService.ValueSupplier<SecurityRealm> getValueSupplier(ServiceBuilder<SecurityRealm> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final String legacyJAASConfig = asStringIfDefined(context, LEGACY_JAAS_CONFIG, model); final boolean applyRoleMappers = APPLY_ROLE_MAPPERS.resolveModelAttribute(context, model).asBoolean(); final InjectedValue<SecurityDomainContext> securityDomainContextInjector = new InjectedValue<>(); if (legacyJAASConfig != null) { serviceBuilder.addDependency(SecurityDomainService.SERVICE_NAME.append(legacyJAASConfig), SecurityDomainContext.class, securityDomainContextInjector); } return () -> { final SecurityDomainContext domainContext = securityDomainContextInjector.getValue(); return new SecurityDomainContextRealm(domainContext, applyRoleMappers); }; } };
private void createConnectionDefinition() throws IllegalStateException { ExceptionSupplier<ModifiableConnDef, Exception> connDefSupplier = connectionDefinitionSupplier.getValue(); try { if (connDefSupplier != null) value.inject(connDefSupplier.get()); } catch (Exception e) { throw new IllegalStateException(e); } }
@Override public void start(final StartContext startContext) throws StartException { if (autostart) { // The start can trigger the web app context initialization which involves blocking tasks like // servlet context initialization, startup servlet initialization lifecycles and such. Hence this needs to be done asynchronously // to prevent the MSC threads from blocking startContext.asynchronous(); serverExecutor.getValue().submit(new Runnable() { @Override public void run() { try { startContext(); startContext.complete(); } catch (Throwable e) { startContext.failed(new StartException(e)); } } }); } }
public void start(final StartContext context) throws StartException { context.asynchronous(); executorInjector.getValue().submit(new Runnable() { public void run() { try { performDeployment(); context.complete(); } catch (StartException e) { context.failed(e); } catch (Throwable e) { context.failed(new StartException(e)); } } }); }
@Override public void run() { final ExecutorService executor = executorServiceInjectedValue.getOptionalValue(); if (executor != null) { if(controlPoint == null) { executor.submit(delegate); } else if(!queued) { queued = true; controlPoint.queueTask(new Runnable() { @Override public void run() { queued = false; delegate.run(); } }, executor, -1, null, false); } else { EjbLogger.EJB3_INVOCATION_LOGGER.debug("Skipping timer invocation as existing request is already queued."); } } }
@Override public void startJobRepository(final StartContext context) throws StartException { final ExecutorService service = executor.getValue(); final Runnable task = () -> { try { // Currently in jBeret tables are created in the constructor which is why this is done asynchronously jobRepository = new JdbcRepository(dataSourceValue.getValue()); context.complete(); } catch (Exception e) { context.failed(BatchLogger.LOGGER.failedToCreateJobRepository(e, "JDBC")); } }; try { service.execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } }
@Override public void stop(final StopContext context) { // Remove the server activity suspendControllerInjector.getValue().unRegisterActivity(serverActivity); final ExecutorService service = executorInjector.getValue(); final Runnable task = () -> { // Should already be stopped, but just to be safe we'll make one more attempt serverActivity.stopRunningJobs(false); batchEnvironment = null; classLoader = null; context.complete(); }; try { service.execute(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } }
public void stop(final StopContext stopContext) { ExecutorService executorService = executor.getValue(); Runnable r = new Runnable() { @Override public void run() { try { stopService(); } finally { stopContext.complete(); } } }; try { executorService.execute(r); } catch (RejectedExecutionException e) { r.run(); } finally { stopContext.asynchronous(); } }
@Override public void stop(StopContext context) { if (IIOPLogger.ROOT_LOGGER.isDebugEnabled()) { IIOPLogger.ROOT_LOGGER.debugf("Stopping service %s", context.getController().getName().getCanonicalName()); } final SocketBinding socketBinding = iiopSocketBindingInjector.getOptionalValue(); final SocketBinding sslSocketBinding = iiopSSLSocketBindingInjector.getOptionalValue(); if (socketBinding != null) { socketBinding.getSocketBindings().getNamedRegistry().unregisterBinding(socketBinding.getName()); } if (sslSocketBinding != null) { sslSocketBinding.getSocketBindings().getNamedRegistry().unregisterBinding(sslSocketBinding.getName()); } // stop the ORB asynchronously. final ORBDestroyer destroyer = new ORBDestroyer(this.orb, context); try { executorInjector.getValue().execute(destroyer); } catch (RejectedExecutionException e) { destroyer.run(); } finally { context.asynchronous(); } }
private void bindBeanManager(ServiceTarget serviceTarget, ServiceName beanManagerServiceName, ServiceName contextServiceName, final Collection<ServiceName> dependencies, final ServiceRegistry serviceRegistry) { final ServiceName beanManagerBindingServiceName = contextServiceName.append("BeanManager"); dependencies.add(beanManagerBindingServiceName); BinderService beanManagerBindingService = new BinderService("BeanManager"); final BeanManagerManagedReferenceFactory referenceFactory = new BeanManagerManagedReferenceFactory(); beanManagerBindingService.getManagedObjectInjector().inject(referenceFactory); serviceTarget.addService(beanManagerBindingServiceName, beanManagerBindingService) .addDependency(contextServiceName, ServiceBasedNamingStore.class, beanManagerBindingService.getNamingStoreInjector()) .addDependency(beanManagerServiceName, BeanManager.class, referenceFactory.beanManager) .install(); }
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("started DirectConnectionFactoryActivatorService %s", context.getController().getName()); String aoClass = null; Connector cmd = mdr.getValue().getResourceAdapter(raId); if (cmd.getVersion() == Connector.Version.V_10) { throw ConnectorLogger.ROOT_LOGGER.adminObjectForJCA10(resourceAdapter, jndiName); activator.setCreateBinderService(false); activator.setBindInfo(bindInfo); ServiceTarget serviceTarget = context.getChildTarget(); .addService(ConnectorServices.RESOURCE_ADAPTER_ACTIVATOR_SERVICE.append(serviceName), activator) .addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, activator.getMdrInjector()) .addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, activator.getRaRepositoryInjector()) .addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, activator.getManagementRepositoryInjector()) .addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE, adminObjectServiceBuilder.requires(NamingService.SERVICE_NAME); adminObjectServiceBuilder.requires(ConnectorServices.getLocalTransactionProviderServiceName()); adminObjectServiceBuilder.requires(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append("default")); adminObjectServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install(); } catch (Exception e) { throw new StartException(e);
ComponentView componentView = paComponentViewInjector.getOptionalValue(); if(componentView != null) { reference = componentView.createInstance(); processApplication = (ProcessApplicationInterface) reference.getInstance(); } else { processApplication = noViewProcessApplication.getValue(); referencedProcessEngines.add(value.getProcessEngineInjector().getValue()); notifyBpmPlatformPlugins(platformPluginsInjector.getValue(), processApplication); context.getChildTarget().addService(serviceName, managedProcessApplication).install(); throw new StartException(e);
final File root = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getRoot(); DEPLOYMENT_CONNECTOR_LOGGER.debugf("DEPLOYMENT name = %s", deploymentName); final boolean fromModule = duServiceName.getParent().equals(RaOperationUtil.RAR_MODULE); final WildFLyRaDeployer raDeployer = new WildFLyRaDeployer(context.getChildTarget(), url, deploymentName, root, classLoader, cmd, activation, deploymentServiceName, fromModule); raDeployer.setConfiguration(config.getValue()); ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(deploymentName); value = new ResourceAdapterDeployment(raDeployment, deploymentName, raServiceName); managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector()); registry.getValue().registerResourceAdapterDeployment(value); ServiceTarget serviceTarget = context.getChildTarget(); serviceTarget .addService(raServiceName, new ResourceAdapterService(raServiceName, value.getDeployment().getResourceAdapter())).setInitialMode(Mode.ACTIVE) .install(); final ServiceName deployerServiceName = ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName()); serviceTarget.addService(deployerServiceName.append(ConnectorServices.IRONJACAMAR_RESOURCE), ijResourceService) .addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, ijResourceService.getMdrInjector()) .addDependency(deployerServiceName, ResourceAdapterDeployment.class, ijResourceService.getResourceAdapterDeploymentInjector()) .setInitialMode(Mode.PASSIVE)
ResourceAdapterActivator activator = new ResourceAdapterActivator(context.getChildTarget(), new URL(pathname), deploymentName, new File(pathname), cl, cmd, activation); activator.setConfiguration(getConfig().getValue()); ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(raName); value = new ResourceAdapterDeployment(deploymentMD, raName, raServiceName); registry.getValue().registerResourceAdapterDeployment(value); managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector()); context.getChildTarget() .addService(raServiceName, new ResourceAdapterService(raServiceName, value.getDeployment().getResourceAdapter())).setInitialMode(Mode.ACTIVE) .install(); DEPLOYMENT_CONNECTOR_LOGGER.debugf("Started service %s", ConnectorServices.RESOURCE_ADAPTER_ACTIVATOR_SERVICE); } catch (Throwable t) {
.createUndertowDeploymentInfoService(); final InjectedValue<Executor> executor = new InjectedValue<Executor>(); infoBuilder.addDependency(IOServices.WORKER.append(metaData.getExecutorName()), Executor.class, executor); undertowDeploymentInfoService.addInjectedExecutor(metaData.getExecutorName(), executor); for (JBossServletMetaData servlet : metaData.getServlets()) { if (servlet.getExecutorName() != null && !seenExecutors.contains(servlet.getExecutorName())) { final InjectedValue<Executor> executor = new InjectedValue<Executor>(); infoBuilder.addDependency(IOServices.WORKER.append(servlet.getExecutorName()), Executor.class, executor); undertowDeploymentInfoService.addInjectedExecutor(servlet.getExecutorName(), executor); infoBuilder.addDependency(ComponentRegistry.serviceName(deploymentUnit), ComponentRegistry.class, undertowDeploymentInfoService.getComponentRegistryInjectedValue()); } else { undertowDeploymentInfoService.getComponentRegistryInjectedValue().setValue(new ImmediateValue<>(componentRegistry)); final ServiceBuilder<UndertowDeploymentService> builder = serviceTarget.addService(deploymentServiceName, service) .addAliases(legacyDeploymentServiceName) .addDependency(UndertowService.SERVLET_CONTAINER.append(defaultContainer), ServletContainerService.class, service.getContainer()) if (jaccService != null) { final ServiceName jaccServiceName = deploymentUnit.getServiceName().append(JaccService.SERVICE_NAME); ServiceBuilder<?> jaccBuilder = serviceTarget.addService(jaccServiceName, jaccService); if (deploymentUnit.getParent() != null) {
@Override public void start(StartContext context) throws StartException { Class<?> providerClass = driverInjector.getOptionalValue(); if (xa) { if (!XADataSource.class.isAssignableFrom(providerClass)) { TransactionSynchronizationRegistry transactionSynchronizationRegistry = transactionSynchronizationRegistryInjector.getValue(); AuthenticationContext authenticationContext = authenticationContextInjector.getOptionalValue(); ExceptionSupplier<CredentialSource, Exception> credentialSourceExceptionExceptionSupplier = credentialSourceSupplierInjector.getOptionalValue(); binderService.getManagedObjectInjector().inject(new ImmediateManagedReferenceFactory(agroalDataSource)); context.getChildTarget().addService(bindInfo.getBinderServiceName(), binderService) .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install();
@Override protected void preStart(final StartContext context) { //adds the HTTP upgrade service //TODO: have a bit more of a think about how we handle this context.getChildTarget().addService(HTTP_UPGRADE_REGISTRY.append(getName()), new ValueService<Object>(new ImmediateValue<Object>(httpUpgradeHandler))) .install(); ListenerRegistry.Listener listener = new ListenerRegistry.Listener(getProtocol(), getName(), serverName, getBinding().getValue().getSocketAddress()); listener.setContextInformation("socket-binding", getBinding().getValue()); httpListenerRegistry.getValue().addListener(listener); }