org.jboss.as.naming.deployment.ContextNames Java Examples

The following examples show how to use org.jboss.as.naming.deployment.ContextNames. 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: TopologyManagerActivator.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
    ServiceTarget target = context.getServiceTarget();

    TopologyManager.INSTANCE.setServiceTarget(target);

    target.addService(SERVICE_NAME, new ValueService<>(new ImmediateValue<>(TopologyManager.INSTANCE)))
            .install();

    BinderService binderService = new BinderService(Topology.JNDI_NAME, null, true);

    target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Topology.JNDI_NAME), binderService)
            .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
            .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(TopologyManager.INSTANCE))
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

}
 
Example #2
Source File: MscRuntimeContainerDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createJndiBindings() {

    final PlatformServiceReferenceFactory managedReferenceFactory = new PlatformServiceReferenceFactory(this);

    final ServiceName processEngineServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME
      .append(BpmPlatform.APP_JNDI_NAME)
      .append(BpmPlatform.MODULE_JNDI_NAME)
      .append(BpmPlatform.PROCESS_ENGINE_SERVICE_NAME);

    // bind process engine service
    BindingUtil.createJndiBindings(childTarget, processEngineServiceBindingServiceName, BpmPlatform.PROCESS_ENGINE_SERVICE_JNDI_NAME, managedReferenceFactory);

    final ServiceName processApplicationServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME
        .append(BpmPlatform.APP_JNDI_NAME)
        .append(BpmPlatform.MODULE_JNDI_NAME)
        .append(BpmPlatform.PROCESS_APPLICATION_SERVICE_NAME);

    // bind process application service
    BindingUtil.createJndiBindings(childTarget, processApplicationServiceBindingServiceName, BpmPlatform.PROCESS_APPLICATION_SERVICE_JNDI_NAME, managedReferenceFactory);

  }
 
Example #3
Source File: MetricsServiceActivator.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {

    ServiceTarget target = serviceActivatorContext.getServiceTarget();

    MetricsService service = new MetricsService();
    ServiceBuilder<MetricsService> metricsServiceBuilder = target.addService(MetricsService.SERVICE_NAME, service);

    ServiceBuilder<MetricsService> serviceBuilder = metricsServiceBuilder
            .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector())
            .addDependency(ServiceName.parse("jboss.eclipse.microprofile.config.marker"))
            .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector());

    serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

    BinderService binderService = new BinderService(SWARM_MP_METRICS, null, true);

    target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, SWARM_MP_METRICS), binderService)
            .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();
}
 
Example #4
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 #5
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 #6
Source File: TopologyManagerActivator.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
    ServiceTarget target = context.getServiceTarget();

    target.addService(TopologyManager.SERVICE_NAME, new ValueService<>(new ImmediateValue<>(TopologyManager.INSTANCE)))
            .install();

    BinderService binderService = new BinderService(Topology.JNDI_NAME, null, true);

    target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Topology.JNDI_NAME), binderService)
            .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
            .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(TopologyManager.INSTANCE))
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

}
 
Example #7
Source File: MscRuntimeContainerDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void createJndiBindings() {

    final PlatformServiceReferenceFactory managedReferenceFactory = new PlatformServiceReferenceFactory(this);

    final ServiceName processEngineServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME
      .append(BpmPlatform.APP_JNDI_NAME)
      .append(BpmPlatform.MODULE_JNDI_NAME)
      .append(BpmPlatform.PROCESS_ENGINE_SERVICE_NAME);

    // bind process engine service
    BindingUtil.createJndiBindings(childTarget, processEngineServiceBindingServiceName, BpmPlatform.PROCESS_ENGINE_SERVICE_JNDI_NAME, managedReferenceFactory);

    final ServiceName processApplicationServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME
        .append(BpmPlatform.APP_JNDI_NAME)
        .append(BpmPlatform.MODULE_JNDI_NAME)
        .append(BpmPlatform.PROCESS_APPLICATION_SERVICE_NAME);

    // bind process application service
    BindingUtil.createJndiBindings(childTarget, processApplicationServiceBindingServiceName, BpmPlatform.PROCESS_APPLICATION_SERVICE_JNDI_NAME, managedReferenceFactory);

  }
 
Example #8
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 #9
Source File: SpringContextBindingDependenciesTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Test
public void testCamelSpringDeploymentWaitsForJndiBindings() {
    CamelContext camelctx = contextRegistry.getCamelContext("jndi-binding-spring-context");
    Assert.assertNotNull("Expected jndi-binding-spring-context to not be null", camelctx);
    Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus());

    ContextNames.BindInfo bindInfo = bindInfoFor("java:/spring/binding/test");
    ServiceName serviceName = bindInfo.getBinderServiceName();
    ServiceController<?> controller = serviceContainer.getService(serviceName);

    Assert.assertNotNull("Expected controller to not be null", controller);
    ManagedReferenceFactory referenceFactory = (ManagedReferenceFactory) controller.getValue();
    DelayedBinderService binderService = (DelayedBinderService) referenceFactory.getReference().getInstance();

    // Make sure the DelayedBinderService did sleep
    Assert.assertTrue("Expected DelayedBinderService.getSleepStart() to be > 0", binderService.getSleepStart() > 0);

    // Verify that the camel context waited for the binding service to finish starting
    CamelContextStartupEventNotifier notifier = (CamelContextStartupEventNotifier) camelctx.getRegistry().lookupByName("contextStartupEventNotifier");
    long startupDelay = notifier.getStartupTime() - binderService.getSleepStart();
    Assert.assertTrue(startupDelay >= binderService.getSleepDelay());
}
 
Example #10
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 #11
Source File: BindingUtil.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static ServiceController<ManagedReferenceFactory> createJndiBindings(ServiceTarget target, ServiceName serviceName, String binderServiceName,  ManagedReferenceFactory managedReferenceFactory) {

    BinderService binderService = new BinderService(binderServiceName);
    ServiceBuilder<ManagedReferenceFactory> serviceBuilder = target
            .addService(serviceName, binderService)
            .addDependency(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
    binderService.getManagedObjectInjector().inject(managedReferenceFactory);
            
    return serviceBuilder.install();
  }
 
Example #12
Source File: BindingUtil.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static ServiceController<ManagedReferenceFactory> createJndiBindings(ServiceTarget target, ServiceName serviceName, String binderServiceName,  ManagedReferenceFactory managedReferenceFactory) {

    BinderService binderService = new BinderService(binderServiceName);
    ServiceBuilder<ManagedReferenceFactory> serviceBuilder = target
            .addService(serviceName, binderService)
            .addDependency(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
    binderService.getManagedObjectInjector().inject(managedReferenceFactory);
            
    return serviceBuilder.install();
  }
 
Example #13
Source File: DelayedBinderServiceActivator.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
    BindInfo bindInfo = ContextNames.bindInfoFor("java:/spring/binding/test");
    DelayedBinderService service = new DelayedBinderService(bindInfo.getBindName());
    ManagedReferenceFactory managedReferenceFactory = new ImmediateManagedReferenceFactory(service);

    ServiceTarget serviceTarget = context.getServiceTarget();
    serviceTarget.addService(bindInfo.getBinderServiceName(), service)
        .addInjection(service.getManagedObjectInjector(), managedReferenceFactory)
        .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector())
        .install();
}
 
Example #14
Source File: NamingContextAssociationHandler.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
private ServiceController<?> removeBinderService(String name) {
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
    ServiceController<?> controller = serviceRegistry.getService(bindInfo.getBinderServiceName());
    if (controller != null) {
        controller.setMode(Mode.REMOVE);
    }
    return controller;
}
 
Example #15
Source File: MonitorServiceActivator.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
    Optional<String> securityRealm = Optional.empty();

    if (!monitorFractionInstance.isUnsatisfied()) {
        securityRealm = monitorFractionInstance.get().securityRealm();
    }

    ServiceTarget target = context.getServiceTarget();

    MonitorService service = new MonitorService(securityRealm);

    ServiceBuilder<MonitorService> monitorServiceServiceBuilder = target.addService(MonitorService.SERVICE_NAME, service);

    ServiceBuilder<MonitorService> serviceBuilder = monitorServiceServiceBuilder
            .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector())
            .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector());

    if (securityRealm.isPresent()) { // configured through the fraction interface
        serviceBuilder.addDependency(
                createRealmName(securityRealm.get()),
                SecurityRealm.class,
                service.getSecurityRealmInjector()
        );
    }

    serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

    BinderService binderService = new BinderService(Monitor.JNDI_NAME, null, true);

    target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Monitor.JNDI_NAME), binderService)
            .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
            .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service))
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

}
 
Example #16
Source File: MonitorServiceActivator.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
    Optional<String> securityRealm = Optional.empty();

    if (!healthFractionInstance.isUnsatisfied()) {
        securityRealm = healthFractionInstance.get().securityRealm();
    }

    ServiceTarget target = context.getServiceTarget();

    MonitorService service = new MonitorService(securityRealm);

    ServiceBuilder<MonitorService> monitorServiceServiceBuilder = target.addService(MonitorService.SERVICE_NAME, service);

    ServiceBuilder<MonitorService> serviceBuilder = monitorServiceServiceBuilder
            .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector())
            .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector());

    if (securityRealm.isPresent()) { // configured through the fraction interface
        serviceBuilder.addDependency(
                createRealmName(securityRealm.get()),
                SecurityRealm.class,
                service.getSecurityRealmInjector()
        );
    }

    serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

    BinderService binderService = new BinderService(Monitor.JNDI_NAME, null, true);

    target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Monitor.JNDI_NAME), binderService)
            .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
            .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service))
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

}
 
Example #17
Source File: CamelContextActivationProcessor.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
private void installBindingDependency(ServiceBuilder builder, String jndiName) {
    if (jndiName != null) {
        ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
        builder.addDependency(bindInfo.getBinderServiceName());
    }
}
 
Example #18
Source File: BraveServiceActivator.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {

    ServiceTarget target = context.getServiceTarget();

    BraveService service = new BraveService(zipKinFractionInstance.get().getBraveInstance());

    ServiceBuilder<BraveService> serviceBuilder = target.addService(BraveService.SERVICE_NAME, service);

    serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();

    BinderService binderService = new BinderService(BraveLookup.JNDI_NAME, null, true);

    target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, BraveLookup.JNDI_NAME), binderService)
            .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
            .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service))
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

}
 
Example #19
Source File: JoseServiceActivator.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {

    ServiceTarget target = context.getServiceTarget();

    JoseService service = new JoseService(joseFractionInstance.get());

    ServiceBuilder<JoseService> serviceBuilder = target.addService(JoseService.SERVICE_NAME, service);

    serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();

    BinderService binderService = new BinderService(JoseLookup.JNDI_NAME, null, true);

    target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, JoseLookup.JNDI_NAME), binderService)
            .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
            .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(service))
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

}