org.jboss.msc.service.StartContext Java Examples

The following examples show how to use org.jboss.msc.service.StartContext. 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: ServerInventoryService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public synchronized void start(StartContext context) throws StartException {
    ROOT_LOGGER.debug("Starting Host Controller Server Inventory");
    try {
        final ProcessControllerConnectionService processControllerConnectionService = client.getValue();
        URI managementURI = new URI(protocol, null, NetworkUtils.formatAddress(getNonWildCardManagementAddress()), port, null, null, null);
        serverInventory = new ServerInventoryImpl(domainController, environment, managementURI, processControllerConnectionService.getClient(), extensionRegistry);
        processControllerConnectionService.setServerInventory(serverInventory);
        serverCallback.getValue().setCallbackHandler(serverInventory.getServerCallbackHandler());
        if (domainServerCallback != null && domainServerCallback.getValue() != null) {
            domainServerCallback.getValue().setServerCallbackHandler(serverInventory.getServerCallbackHandler());
        }
        futureInventory.setInventory(serverInventory);
    } catch (Exception e) {
        futureInventory.setFailure(e);
        throw new StartException(e);
    }
}
 
Example #2
Source File: BlockerExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
        public void start(final StartContext context) throws StartException {
            if (blockStart) {
//                Runnable r = new Runnable() {
//                    @Override
//                    public void run() {
                        try {
                            synchronized (waitObject) {
                                log.info("BlockService blocking in start");
                                waitObject.wait(blockTime);
                            }
                            context.complete();
                        } catch (InterruptedException e) {
                            log.info("BlockService interrupted");
//                            context.failed(new StartException(e));
                            throw new StartException(e);
                        }
//                    }
//                };
//                Thread thread = new Thread(r);
//                thread.start();
//                context.asynchronous();
            }
        }
 
Example #3
Source File: MscManagedProcessEngine.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createProcessEngineJndiBinding(StartContext context) {
  
  final ProcessEngineManagedReferenceFactory managedReferenceFactory = new ProcessEngineManagedReferenceFactory(processEngine);
  
  final ServiceName processEngineServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME            
      .append(BpmPlatform.APP_JNDI_NAME)
      .append(BpmPlatform.MODULE_JNDI_NAME)
      .append(processEngine.getName());
  
  final String jndiName = BpmPlatform.JNDI_NAME_PREFIX 
      + "/" + BpmPlatform.APP_JNDI_NAME 
      + "/" + BpmPlatform.MODULE_JNDI_NAME 
      + "/" +processEngine.getName();

  // bind process engine service
  bindingService = BindingUtil.createJndiBindings(context.getChildTarget(), processEngineServiceBindingServiceName, jndiName, managedReferenceFactory);

  // log info message
  LOGG.info("jndi binding for process engine " + processEngine.getName() + " is " + jndiName);
}
 
Example #4
Source File: DaemonService.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    int port = Integer.getInteger(SwarmProperties.ARQUILLIAN_DAEMON_PORT, 12345);

    try {
        this.server = Server.create("localhost", port);
        this.server.start();
    } catch (Exception e) {
        // this shouldn't be possible per Java control flow rules, but there is a "sneaky throw" somewhere
        //noinspection ConstantConditions
        if (e instanceof BindException) {
            log.log(Level.SEVERE, "Couldn't bind Arquillian Daemon on localhost:" + port
                    + "; you can change the port using system property '"
                    + SwarmProperties.ARQUILLIAN_DAEMON_PORT + "'", e);
        }

        throw new StartException(e);
    }
}
 
Example #5
Source File: SecretIdentityService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void start(final StartContext startContext) throws StartException {
    final char[] thePassword;
    if (base64) {
        byte[] value = Base64.getDecoder().decode(password);
        String tempPassword = new String(value, StandardCharsets.ISO_8859_1);
        String trimmedPassword = tempPassword.trim();
        if (tempPassword.equals(trimmedPassword) == false) {
            ROOT_LOGGER.whitespaceTrimmed();
        }

        thePassword = trimmedPassword.toCharArray();
    } else {
        thePassword = password.toCharArray();
    }

    callbackHandlerFactoryConsumer.accept((String username) -> new SecretCallbackHandler(username, resolvePassword(thePassword)));
}
 
Example #6
Source File: ServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public synchronized void start(final StartContext context) throws StartException {
    ServerEnvironment serverEnvironment = configuration.getServerEnvironment();
    Bootstrap.ConfigurationPersisterFactory configurationPersisterFactory = configuration.getConfigurationPersisterFactory();
    extensibleConfigurationPersister = configurationPersisterFactory.createConfigurationPersister(serverEnvironment, getExecutorService());
    setConfigurationPersister(extensibleConfigurationPersister);
    rootResourceDefinition.setDelegate(
            new ServerRootResourceDefinition(injectedContentRepository.getValue(),
                    extensibleConfigurationPersister, configuration.getServerEnvironment(), processState,
                    runningModeControl, vaultReader, configuration.getExtensionRegistry(),
                    getExecutorService() != null,
                    (PathManagerService)injectedPathManagerService.getValue(),
                    new DomainServerCommunicationServices.OperationIDUpdater() {
                        @Override
                        public void updateOperationID(final int operationID) {
                            DomainServerCommunicationServices.updateOperationID(operationID);
                        }
                    },
                    authorizer,
                    securityIdentitySupplier,
                    super.getAuditLogger(),
                    getMutableRootResourceRegistrationProvider(),
                    super.getBootErrorCollector(),
                    configuration.getCapabilityRegistry()));
    super.start(context);
}
 
Example #7
Source File: FilteringKeyStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    try {
        KeyStore keyStore = keyStoreInjector.getValue();
        AliasFilter filter = AliasFilter.fromString(aliasFilter);
        KeyStore unmodifiable = UnmodifiableKeyStore.unmodifiableKeyStore(keyStore);
        KeyStore modifiable = keyStore;

        ROOT_LOGGER.tracef(
                "starting:  aliasFilter = %s  filter = %s  unmodifiable = %s  modifiable = %s",
                aliasFilter, filter, unmodifiable, modifiable);

        filteringKeyStore = FilteringKeyStore.filteringKeyStore(unmodifiable, filter);
        if (modifiableFilteringKeyStore == null) {
            modifiableFilteringKeyStore = FilteringKeyStore.filteringKeyStore(modifiable, filter);
        }
    } catch (Exception e) {
        throw new StartException(e);
    }
}
 
Example #8
Source File: RegistrationAdvertiser.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    try {
        this.topologyConnectorInjector.getValue().advertise(this.name, this.socketBindingInjector.getValue(), this.tags);
    } catch (Exception e) {
        throw new StartException(e);
    }
}
 
Example #9
Source File: MscManagedProcessEngineController.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void startInternal(StartContext context) throws StartException {
  // setting the TCCL to the Classloader of this module.
  // this exploits a hack in MyBatis allowing it to use the TCCL to load the
  // mapping files from the process engine module
  Tccl.runUnderClassloader(new Operation<Void>() {
    public Void run() {
      startProcessEngine();
      return null;
    }

  }, ProcessEngine.class.getClassLoader());

  // invoke super start behavior.
  super.start(context);
}
 
Example #10
Source File: KeytabService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(final StartContext context) throws StartException {
    String file = path;
    if (relativeTo != null) {
        PathManager pm = pathManagerSupplier.get();

        file = pm.resolveRelativePathEntry(file, relativeTo);
        pathHandle = pm.registerCallback(relativeTo, new org.jboss.as.controller.services.path.PathManager.Callback() {

            @Override
            public void pathModelEvent(PathEventContext eventContext, String name) {
                if (eventContext.isResourceServiceRestartAllowed() == false) {
                    eventContext.reloadRequired();
                }
            }

            @Override
            public void pathEvent(Event event, PathEntry pathEntry) {
                // Service dependencies should trigger a stop and start.
            }
        }, Event.REMOVED, Event.UPDATED);
    }

    File keyTabFile = new File(file);
    if (keyTabFile.exists() == false) {
        throw SECURITY_LOGGER.keyTabFileNotFound(file);
    }

    try {
        clientConfiguration = createConfiguration(false, keyTabFile);
        serverConfiguration = createConfiguration(true, keyTabFile);
    } catch (MalformedURLException e) {
        throw SECURITY_LOGGER.invalidKeytab(e);
    }
    serviceConsumer.accept(this);
}
 
Example #11
Source File: CamelContextRegistryService.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    ContextCreateHandlerRegistry handlerRegistry = injectedHandlerRegistry.getValue();
    contextRegistry = new CamelContextRegistryImpl(handlerRegistry, startContext.getChildTarget());
    ((CamelContextTracker) contextRegistry).open();

    for (final String name : subsystemState.getContextDefinitionNames()) {
        createCamelContext(name, subsystemState.getContextDefinition(name));
    }
}
 
Example #12
Source File: TestModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    if (initializer != null) {
        initializer.setDelegate();
    }
    super.start(context);
    latch.countDown();
}
 
Example #13
Source File: SocketBindingService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(final StartContext context) {
    binding = new SocketBinding(name, port, isFixedPort,
       multicastAddress, multicastPort,
       interfaceBindingSupplier != null ? interfaceBindingSupplier.get() : null,
       socketBindingsSupplier.get(), clientMappings);
    socketBindingConsumer.accept(binding);
}
 
Example #14
Source File: LdapConnectionManagerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(final StartContext context) throws StartException {
    try {
        context.execute(new Runnable() {
            @Override
            public void run() {
                connectionManagerRegistry.addLdapConnectionManagerService(name, LdapConnectionManagerService.this);
                ldapConnectionManagerConsumer.accept(LdapConnectionManagerService.this);
                context.complete();
            }
        });
    } finally {
        context.asynchronous();
    }
}
 
Example #15
Source File: MonitorService.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    executorService = Executors.newSingleThreadExecutor();
    serverEnvironment = serverEnvironmentValue.getValue();
    controllerClient = modelControllerValue.getValue().createClient(executorService);

    if (!securityRealm.isPresent()) {
        LOG.info("The monitoring endpoints have no security realm configuration");
    }
}
 
Example #16
Source File: TopologyProxyService.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    try {
        Topology topology = Topology.lookup();
        topology.addListener(this);
    } catch (NamingException ex) {
        throw new StartException(ex);
    }
}
 
Example #17
Source File: ConsulTopologyConnector.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    ServiceTarget target = startContext.getChildTarget();

    CatalogWatcher watcher = new CatalogWatcher();
    target.addService(CatalogWatcher.SERVICE_NAME, watcher)
            .addDependency(CatalogClientService.SERVICE_NAME, CatalogClient.class, watcher.getCatalogClientInjector())
            .addDependency(HealthClientService.SERIVCE_NAME, HealthClient.class, watcher.getHealthClientInjector())
            .addDependency(TopologyManagerActivator.SERVICE_NAME, TopologyManager.class, watcher.getTopologyManagerInjector())
            .install();


}
 
Example #18
Source File: ScheduledThreadPoolService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void start(final StartContext context) throws StartException {
    ScheduledThreadPoolExecutor scheduledExecutor = new ExecutorImpl(0, threadFactoryValue.getValue());
    scheduledExecutor.setCorePoolSize(maxThreads);
    if (keepAlive != null) scheduledExecutor.setKeepAliveTime(keepAlive.getDuration(), keepAlive.getUnit());
    final ManagedScheduledExecutorService executorService = new ManagedScheduledExecutorService(scheduledExecutor);
    synchronized (this) {
        executor = executorService;
    }
}
 
Example #19
Source File: MscRuntimeContainerDelegate.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void start(StartContext context) throws StartException {
  serviceContainer = context.getController().getServiceContainer();
  childTarget = context.getChildTarget();

  startTrackingServices();
  createJndiBindings();

  // set this implementation as Runtime Container
  RuntimeContainerDelegate.INSTANCE.set(this);
}
 
Example #20
Source File: SecurityPropertyService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(StartContext context) throws StartException {
    doPrivileged((PrivilegedAction<Void>) () -> {
        toSet.forEach((String name, String value) -> setPropertyImmediate(name, value));
        return null;
    });
    toSet.clear();
    started = true;
}
 
Example #21
Source File: EndpointService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** {@inheritDoc} */
public void start(final StartContext context) throws StartException {
    final Endpoint endpoint;
    final EndpointBuilder builder = Endpoint.builder();
    builder.setEndpointName(endpointName);
    builder.setXnioWorker(workerSupplier.get());
    try {
        endpoint = builder.build();
    } catch (IOException e) {
        throw RemotingLogger.ROOT_LOGGER.couldNotStart(e);
    }
    // Reuse the options for the remote connection factory for now
    this.endpoint = endpoint;
    endpointConsumer.accept(endpoint);
}
 
Example #22
Source File: InterfaceManagementUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    rootResourceDefinition.setDelegate(new ServerRootResourceDefinition(MockRepository.INSTANCE,
            persister, environment, processState, null, null, extensionRegistry, false, MOCK_PATH_MANAGER, null,
            authorizer, securityIdentitySupplier, AuditLogger.NO_OP_LOGGER, getMutableRootResourceRegistrationProvider(), getBootErrorCollector(), capabilityRegistry));
    super.start(context);
}
 
Example #23
Source File: ServiceModuleLoader.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(StartContext context) throws StartException {
    if (serviceContainer != null) {
        throw ServerLogger.ROOT_LOGGER.serviceModuleLoaderAlreadyStarted();
    }
    serviceContainer = context.getController().getServiceContainer();
}
 
Example #24
Source File: JGroupsTopologyConnector.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    this.commandDispatcherFactoryInjector.getValue().getGroup().addListener(this);
    this.dispatcher = this.commandDispatcherFactoryInjector.getValue().createCommandDispatcher("netflix.runtime.manager", this);
    this.node = this.commandDispatcherFactoryInjector.getValue().getGroup().getLocalNode();
    try {
        requestAdvertisements();
    } catch (Exception e) {
        throw new StartException(e);
    }
}
 
Example #25
Source File: DefaultSSLContextService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    final SSLContext sslContext = defaultSSLContextSupplier.get();
    doPrivileged((PrivilegedAction<Void>) () -> {
        SSLContext.setDefault(sslContext);
        return null;
    });
    valueConsumer.accept(sslContext);
}
 
Example #26
Source File: RemotingConnectorService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(final StartContext context) throws StartException {
    MBeanServer forwarder = AuthorizingMBeanServer.wrap(new BlockingNotificationMBeanServer(mBeanServer.getValue(), resolvedDomain, expressionsDomain));
    server = new RemotingConnectorServer(forwarder, endpoint.getValue(), new ServerInterceptorFactory());
    try {
        server.start();
    } catch (IOException e) {
        throw new StartException(e);
    }
}
 
Example #27
Source File: HttpShutdownService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(final StartContext context) throws StartException {
    // Register the http request processor on the mgmt request tracker
    final ManagementHttpRequestProcessor processor = processorSupplier.get();
    trackerService = registrySupplier.get().getTrackerService();
    trackerService.registerTracker(processor);
    processor.addShutdownListener(new ManagementHttpRequestProcessor.ShutdownListener() {
        @Override
        public void handleCompleted() {
            trackerService.unregisterTracker(processor);
        }
    });
}
 
Example #28
Source File: ErrorExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(final StartContext context) throws StartException {
    if (errorInStart) {
        if (induceOOME) {  // this will only be true if ErroringHandler is edited to make it possible
            while (System.currentTimeMillis() > 1) {
                oomeSB.append("more and more and more");
            }
            log.info(oomeSB.toString());
        } else {
            error();
        }
    }
}
 
Example #29
Source File: TestHostCapableExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    if (hasSocketBinding) {
        SocketBinding binding = socketBindingInjector.getValue();
        try {
            serverSocket = binding.createServerSocket();
        } catch (IOException e) {
            throw new StartException(e);
        }
    }
}
 
Example #30
Source File: ServiceActivatorDeployment.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(StartContext context) throws StartException {
    Boolean fail = Boolean.getBoolean(FAIL_SYS_PROP);
    if (fail) {
        throw new StartException(FAILURE_MESSAGE);
    }
}