@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); }
/** {@inheritDoc} */ public void start(final StartContext context) { super.start(context); if (SarLogger.ROOT_LOGGER.isTraceEnabled()) { SarLogger.ROOT_LOGGER.tracef("Starting Service: %s", context.getController().getName()); } final Runnable task = new Runnable() { @Override public void run() { try { invokeLifecycleMethod(startMethod, context); context.complete(); } catch (Throwable e) { context.failed(new StartException(SarLogger.ROOT_LOGGER.failedExecutingLegacyMethod("start()"), e)); } } }; try { executorSupplier.get().submit(task); } catch (RejectedExecutionException e) { task.run(); } finally { context.asynchronous(); } }
@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 { startContext(); startContext.complete(); } catch (Throwable e) { startContext.failed(new StartException(e)); } } });
/** * Creates the naming store if not provided by the constructor. * * @param context The start context * @throws StartException If any problems occur creating the context */ public void start(final StartContext context) throws StartException { if(store == null) { final ServiceRegistry serviceRegistry = context.getController().getServiceContainer(); final ServiceName serviceNameBase = context.getController().getName(); final ServiceTarget serviceTarget = context.getChildTarget(); store = readOnly ? new ServiceBasedNamingStore(serviceRegistry, serviceNameBase) : new WritableServiceBasedNamingStore(serviceRegistry, serviceNameBase, serviceTarget); } }
@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)); } } }); }
protected final void cleanupStartAsync(final StartContext context, final String deploymentName, final ServiceName serviceName, final Throwable cause) { ExecutorService executorService = getLifecycleExecutorService(); Runnable r = new Runnable() { @Override public void run() { try { // TODO -- one of the 3 previous synchronous calls to this method don't had the TCCL set, // but the other two don't. I (BES 2013/10/21) intepret from that that setting the TCCL // was not necessary and in caller that had it set it was an artifact of WritableServiceBasedNamingStore.pushOwner(serviceName); unregisterAll(deploymentName); } finally { WritableServiceBasedNamingStore.popOwner(); context.failed(ConnectorLogger.ROOT_LOGGER.failedToStartRaDeployment(cause, deploymentName)); } } }; try { executorService.execute(r); } catch (RejectedExecutionException e) { r.run(); } finally { context.asynchronous(); } }
@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.setInitialMode(ServiceController.Mode.ACTIVE).install(); } catch (Exception e) { throw new StartException(e);
public synchronized void start(final StartContext context) throws StartException { ServiceTarget target = context.getChildTarget(); final String deploymentName = context.getController().getName().getSimpleName(); final DeploymentServiceListener listener = new DeploymentServiceListener(deploymentName); this.listener = listener; // Create the first phase deployer target.addListener(ServiceListener.Inheritance.ALL, listener); deploymentUnit = createAndInitializeDeploymentUnit(context.getController().getServiceContainer()); deploymentUnit.putAttachment(Attachments.STATUS_LISTENER, listener); final String managementName = deploymentUnit.getAttachment(Attachments.MANAGEMENT_NAME); ServerLogger.DEPLOYMENT_LOGGER.startingDeployment(managementName, deploymentName); final ServiceName serviceName = deploymentUnit.getServiceName().append(FIRST_PHASE_NAME); final Phase firstPhase = Phase.values()[0]; final DeploymentUnitPhaseService<?> phaseService = DeploymentUnitPhaseService.create(deploymentUnit, firstPhase); final ServiceBuilder<?> phaseServiceBuilder = target.addService(serviceName, phaseService); phaseServiceBuilder.addDependency(Services.JBOSS_DEPLOYMENT_CHAINS, DeployerChains.class, phaseService.getDeployerChainsInjector()); phaseServiceBuilder.install(); }
ComponentView componentView = paComponentViewInjector.getOptionalValue(); if(componentView != null) { reference = componentView.createInstance(); processApplication = (ProcessApplicationInterface) reference.getInstance(); } else { processApplication = noViewProcessApplication.getValue(); referencedProcessEngines.add(value.getProcessEngineInjector().getValue()); context.getChildTarget().addService(serviceName, managedProcessApplication).install(); throw new StartException(e);
addCallbacks(false); ServiceRegistry registry = context.getController().getServiceContainer(); InstancesService.addInstance(registry, context.getChildTarget(), getLifecycleState(), getBean()); final BeanMetaDataConfig beanConfig = getBeanConfig(); final ServiceName name = BeanMetaDataConfig.toBeanName(beanConfig.getName(), next); final ServiceTarget serviceTarget = context.getChildTarget(); final ServiceBuilder serviceBuilder = serviceTarget.addService(name, nextPhase); registerAliases(serviceBuilder, next); final ConfigVisitor visitor = new DefaultConfigVisitor(serviceBuilder, state, getModule(), getIndex(), getBeanInfo()); nextPhase.setBeanInfo(getBeanInfo()); nextPhase.setBean(getBean()); serviceBuilder.install(); throw new StartException(t);
private void setupPolicyRegistration(final StartContext context) { ServiceTarget target = context.getChildTarget(); final BinderService binderService = new BinderService(POLICY_REGISTRATION); binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory( Values.immediateValue(new JBossPolicyRegistration()))); target.addService(ContextNames.buildServiceName(ContextNames.JAVA_CONTEXT_SERVICE_NAME, POLICY_REGISTRATION), binderService) .addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install(); }
@Override public void start(StartContext context) throws StartException { this.context = new ApplicationContext(this.app); ServiceTarget target = context.getChildTarget(); ServiceName name = context.getController().getName(); target.addService(name.append("bootstrap"), new ApplicationContextBootstrapService(this.app)) .install(); }
@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(); BinderService binderService = new BinderService(bindInfo.getBindName()); binderService.getManagedObjectInjector().inject(new ImmediateManagedReferenceFactory(agroalDataSource)); context.getChildTarget().addService(bindInfo.getBinderServiceName(), binderService) .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install();
@Override public void start(StartContext context) throws StartException { this.resource = new ApplicationSubscriptionsResource( this.subscriptionManagerInjector.getValue(), this.vertxInjector.getValue(), this.codecManagerInjector.getValue()); MountService<ApplicationSubscriptionsResource> mount = new MountService<>(); ServiceTarget target = context.getChildTarget(); String appId = this.app.id(); target.addService(context.getController().getName().append("mount"), mount) .addDependency(Services.applicationContext(appId), MountPointResource.class, mount.mountPointInjector()) .addInjectionValue(mount.resourceInjector(), this) .install(); }
public synchronized void start(StartContext startContext) throws StartException { try { final ServiceContainer container = startContext.getController().getServiceContainer(); deploymentMD = getDeployer().deploy(container); if (deploymentMD.getCfs().length != 1) { throw ConnectorLogger.ROOT_LOGGER.cannotStartDs(); } sqlDataSource = new WildFlyDataSource((javax.sql.DataSource) deploymentMD.getCfs()[0], jndiName.getAbsoluteJndiName()); DS_DEPLOYER_LOGGER.debugf("Adding datasource: %s", deploymentMD.getCfJndiNames()[0]); CommonDeploymentService cdService = new CommonDeploymentService(deploymentMD); final ServiceName cdServiceName = CommonDeploymentService.getServiceName(jndiName); final ServiceBuilder cdServiceSB = startContext.getChildTarget().addService(cdServiceName, cdService); // The dependency added must be the JNDI name which for subsystem resources is an alias. This service // is also used in deployments where the capability service name is not registered for the service. cdServiceSB.requires(getServiceName(jndiName)); cdServiceSB.setInitialMode(ServiceController.Mode.ACTIVE).install(); } catch (Throwable t) { throw ConnectorLogger.ROOT_LOGGER.deploymentError(t, dsName); } }
public synchronized void start(StartContext startContext) throws StartException { try { final ServiceContainer container = startContext.getController().getServiceContainer(); deploymentMD = getDeployer().deploy(container); if (deploymentMD.getCfs().length != 1) { throw ConnectorLogger.ROOT_LOGGER.cannotStartDs(); } sqlDataSource = new WildFlyDataSource((javax.sql.DataSource) deploymentMD.getCfs()[0], jndiName.getAbsoluteJndiName()); DS_DEPLOYER_LOGGER.debugf("Adding datasource: %s", deploymentMD.getCfJndiNames()[0]); CommonDeploymentService cdService = new CommonDeploymentService(deploymentMD); final ServiceName cdServiceName = CommonDeploymentService.getServiceName(jndiName); startContext.getChildTarget().addService(cdServiceName, cdService) // The dependency added must be the JNDI name which for subsystem resources is an alias. This service // is also used in deployments where the capability service name is not registered for the service. .addDependency(getServiceName(jndiName)) .setInitialMode(ServiceController.Mode.ACTIVE).install(); } catch (Throwable t) { throw ConnectorLogger.ROOT_LOGGER.deploymentError(t, dsName); } }
started = true; preStart(context); serverService.getValue().registerListener(this); try { openListener = createOpenListener(); HttpHandler handler = serverService.getValue().getRoot(); for(HandlerWrapper wrapper : listenerHandlerWrappers) { handler = wrapper.wrap(handler); final InetSocketAddress socketAddress = binding.getValue().getSocketAddress(); if (socketAddress != null) sb.append(" ").append(socketAddress); throw new StartException(sb.toString()); } else { throw UndertowLogger.ROOT_LOGGER.couldNotStartListener(name, e); }; getUndertowService().registerStatisticsListener(statisticsChangeListener); final ServiceContainer container = context.getController().getServiceContainer(); this.stoppingWrapper = new HandlerWrapper() { @Override
/** * Bind the entry into the injected context. * * @param context The start context * @throws StartException If the entity can not be bound */ public void start(StartContext context) throws StartException { final ServiceBasedNamingStore namingStore = namingStoreValue.getValue(); controller = context.getController(); namingStore.add(controller.getName()); ROOT_LOGGER.tracef("Bound resource %s into naming store %s (service name %s)", name, namingStore, controller.getName()); }