Java Code Examples for org.jboss.msc.service.ServiceBuilder#addAliases()

The following examples show how to use org.jboss.msc.service.ServiceBuilder#addAliases() . 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: CustomComponentDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {
    ServiceTarget serviceTarget = context.getServiceTarget();

    String address = context.getCurrentAddressValue();
    RuntimeCapability<?> primaryCapability = runtimeCapabilities[0];
    ServiceName primaryServiceName = toServiceName(primaryCapability, address);

    final String module = MODULE.resolveModelAttribute(context, model).asStringOrNull();
    final String className = CLASS_NAME.resolveModelAttribute(context, model).asString();

    final Map<String, String> configurationMap;
    configurationMap = CONFIGURATION.unwrap(context, model);

    ServiceBuilder<?> serviceBuilder = serviceTarget.addService(primaryServiceName);
    for (int i = 1; i < runtimeCapabilities.length; i++) {
        serviceBuilder.addAliases(toServiceName(runtimeCapabilities[i], address));
    }

    commonRequirements(serviceBuilder)
        .setInstance(new TrivialService<>(() -> createValue(module, className, configurationMap)))
        .setInitialMode(Mode.ACTIVE)
        .install();
}
 
Example 2
Source File: MscManagedProcessEngineController.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static void initializeServiceBuilder(ManagedProcessEngineMetadata processEngineConfiguration, MscManagedProcessEngineController service,
        ServiceBuilder<ProcessEngine> serviceBuilder, String jobExecutorName) {

  ContextNames.BindInfo datasourceBindInfo = ContextNames.bindInfoFor(processEngineConfiguration.getDatasourceJndiName());
  serviceBuilder.addDependency(ServiceName.JBOSS.append("txn").append("TransactionManager"), TransactionManager.class, service.getTransactionManagerInjector())
    .addDependency(datasourceBindInfo.getBinderServiceName(), DataSourceReferenceFactoryService.class, service.getDatasourceBinderServiceInjector())
    .addDependency(ServiceNames.forMscRuntimeContainerDelegate(), MscRuntimeContainerDelegate.class, service.getRuntimeContainerDelegateInjector())
    .addDependency(ServiceNames.forMscRuntimeContainerJobExecutorService(jobExecutorName), MscRuntimeContainerJobExecutor.class, service.getMscRuntimeContainerJobExecutorInjector())
    .addDependency(ServiceNames.forMscExecutorService())
    .setInitialMode(Mode.ACTIVE);

  if(processEngineConfiguration.isDefault()) {
    serviceBuilder.addAliases(ServiceNames.forDefaultProcessEngine());
  }

  JBossCompatibilityExtension.addServerExecutorDependency(serviceBuilder, service.getExecutorInjector(), false);

}
 
Example 3
Source File: MscManagedProcessEngineController.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static void initializeServiceBuilder(ManagedProcessEngineMetadata processEngineConfiguration, MscManagedProcessEngineController service,
        ServiceBuilder<ProcessEngine> serviceBuilder, String jobExecutorName) {

  ContextNames.BindInfo datasourceBindInfo = ContextNames.bindInfoFor(processEngineConfiguration.getDatasourceJndiName());
  serviceBuilder.addDependency(ServiceName.JBOSS.append("txn").append("TransactionManager"), TransactionManager.class, service.getTransactionManagerInjector())
    .addDependency(datasourceBindInfo.getBinderServiceName(), DataSourceReferenceFactoryService.class, service.getDatasourceBinderServiceInjector())
    .addDependency(ServiceNames.forMscRuntimeContainerDelegate(), MscRuntimeContainerDelegate.class, service.getRuntimeContainerDelegateInjector())
    .addDependency(ServiceNames.forMscRuntimeContainerJobExecutorService(jobExecutorName), MscRuntimeContainerJobExecutor.class, service.getMscRuntimeContainerJobExecutorInjector())
    .addDependency(ServiceNames.forMscExecutorService())
    .setInitialMode(Mode.ACTIVE);

  if(processEngineConfiguration.isDefault()) {
    serviceBuilder.addAliases(ServiceNames.forDefaultProcessEngine());
  }

  JBossCompatibilityExtension.addServerExecutorDependency(serviceBuilder, service.getExecutorInjector(), false);

}
 
Example 4
Source File: ThreadPoolManagementUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static <T> void installThreadPoolService(final Service<T> threadPoolService,
                                         final String threadPoolName,
                                         final RuntimeCapability<Void> cap,
                                         final PathAddress address,
                                         final ServiceName serviceNameBase,
                                         final String threadFactoryName,
                                         final ThreadFactoryResolver threadFactoryResolver,
                                         final Injector<ThreadFactory> threadFactoryInjector,
                                         final String handoffExecutorName,
                                         final HandoffExecutorResolver handoffExecutorResolver,
                                         final Injector<Executor> handoffExecutorInjector,
                                         final ServiceTarget target) {
    final ServiceName threadPoolServiceName;
    final ServiceName aliasServiceName;
    if(cap != null) {
        threadPoolServiceName = cap.getCapabilityServiceName(address);
        if(serviceNameBase != null) {
            aliasServiceName = serviceNameBase.append(threadPoolName);
        } else {
            aliasServiceName = null;
        }
    } else {
        threadPoolServiceName = serviceNameBase.append(threadPoolName);
        aliasServiceName = null;
    }
    final ServiceBuilder<?> serviceBuilder = target.addService(threadPoolServiceName, threadPoolService);
    if(aliasServiceName != null) {
        serviceBuilder.addAliases(aliasServiceName);
    }
    final ServiceName threadFactoryServiceName = threadFactoryResolver.resolveThreadFactory(threadFactoryName,
            threadPoolName, threadPoolServiceName, target);
    serviceBuilder.addDependency(threadFactoryServiceName, ThreadFactory.class, threadFactoryInjector);

    if (handoffExecutorInjector != null) {
        ServiceName handoffServiceName = handoffExecutorResolver.resolveHandoffExecutor(handoffExecutorName,
                threadPoolName, threadPoolServiceName, target);
        if (handoffServiceName != null) {
            serviceBuilder.addDependency(handoffServiceName, Executor.class, handoffExecutorInjector);
        }
    }

    serviceBuilder.install();

}