private void installJNDIAliases(final ContextNames.BindInfo bindInfo, final ServiceTarget serviceTarget) { for (String alias : getJndiAliases()) { final ContextNames.BindInfo aliasBindInfo = ContextNames.bindInfoFor(alias); final BinderService aliasBinderService = new BinderService(alias); aliasBinderService.getManagedObjectInjector().inject(new AliasManagedReferenceFactory(bindInfo.getAbsoluteJndiName())); final ServiceBuilder sb = serviceTarget.addService(aliasBindInfo.getBinderServiceName(), aliasBinderService); sb.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, aliasBinderService.getNamingStoreInjector()); sb.requires(bindInfo.getBinderServiceName()); sb.addListener(new LifecycleListener() { @Override public void handleEvent(ServiceController<?> controller, LifecycleEvent event) { switch (event) { case UP: { DEPLOYMENT_CONNECTOR_LOGGER.bindingAlias(bindInfo.getAbsoluteJndiName(), alias); break; } case DOWN: { DEPLOYMENT_CONNECTOR_LOGGER.unbindingAlias(bindInfo.getAbsoluteJndiName(), alias); break; } case REMOVED: { DEPLOYMENT_CONNECTOR_LOGGER.debugf("Removed messaging object [%s]", alias); break; } } } }); sb.install(); } }
final ServiceTarget serviceTarget = phaseContext.getServiceTarget(); final ServiceName appContextServiceName = ContextNames.contextServiceNameOfApplication(moduleDescription.getApplicationName()); final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName()); final NamingStoreService contextService = new NamingStoreService(true); serviceTarget.addService(moduleContextServiceName, contextService).install(); final ServiceName moduleNameServiceName = moduleContextServiceName.append("ModuleName"); final BinderService moduleNameBinder = new BinderService("ModuleName"); moduleNameBinder.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(Values.immediateValue(moduleDescription.getModuleName()))); serviceTarget.addService(moduleNameServiceName, moduleNameBinder) .addDependency(moduleContextServiceName, ServiceBasedNamingStore.class, moduleNameBinder.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES, moduleNameServiceName);
if (bindingConfiguration.getName().startsWith("java:comp") || !bindingConfiguration.getName().startsWith("java:")) { final String bindingName = bindingConfiguration.getName().startsWith("java:comp") ? bindingConfiguration.getName() : "java:comp/env/" + bindingConfiguration.getName(); final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(configuration.getApplicationName(), configuration.getModuleName(), configuration.getComponentName(), configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE, bindingName); if (bound.contains(bindInfo.getBinderServiceName())) { continue; bound.add(bindInfo.getBinderServiceName()); try { final BinderService service = new BinderService(bindInfo.getBindName(), bindingConfiguration.getSource()); jndiDepServiceBuilder.requires(bindInfo.getBinderServiceName()); ServiceBuilder<ManagedReferenceFactory> serviceBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), service); bindingConfiguration.getSource().getResourceValue(resolutionContext, serviceBuilder, phaseContext, service.getManagedObjectInjector()); serviceBuilder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector()); serviceBuilder.install(); } catch (DuplicateServiceException e) { ServiceController<ManagedReferenceFactory> registered = (ServiceController<ManagedReferenceFactory>) CurrentServiceContainer.getServiceContainer().getService(bindInfo.getBinderServiceName());
} else if (i == 5) { return new BindInfo(JAVA_CONTEXT_SERVICE_NAME, context.substring(6)); } else { namespace = context.substring(5, i); sanitazeNameSpace(namespace,context); if (namespace.equals("global")) { return new BindInfo(GLOBAL_CONTEXT_SERVICE_NAME, context.substring(12)); } else if (namespace.equals("jboss")) { String rest = context.substring(i); if(rest.startsWith("/exported/")) { return new BindInfo(EXPORTED_CONTEXT_SERVICE_NAME, context.substring(20)); } else { return new BindInfo(JBOSS_CONTEXT_SERVICE_NAME, context.substring(11)); return new BindInfo(contextServiceNameOfApplication(app), context.substring(9)); } else if (namespace.equals("module")) { return new BindInfo(contextServiceNameOfModule(app, module), context.substring(12)); } else if (namespace.equals("comp")) { return new BindInfo(contextServiceNameOfComponent(app, module, comp), context.substring(10)); } else { return new BindInfo(JBOSS_CONTEXT_SERVICE_NAME, context);
@Override public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException { final ContextManagedReferenceFactory managedReferenceFactory = new ContextManagedReferenceFactory(name); final ServiceName contextServiceName; if(fullName.startsWith("java:app")) { contextServiceName = ContextNames.contextServiceNameOfApplication(resolutionContext.getApplicationName()); } else if (fullName.startsWith("java:module") || (fullName.startsWith("java:comp") && resolutionContext.isCompUsesModule())) { contextServiceName = ContextNames.contextServiceNameOfModule(resolutionContext.getApplicationName(), resolutionContext.getModuleName()); } else if(fullName.startsWith("java:comp")) { contextServiceName = ContextNames.contextServiceNameOfComponent(resolutionContext.getApplicationName(), resolutionContext.getModuleName(), resolutionContext.getComponentName()); } else { throw NamingLogger.ROOT_LOGGER.invalidNameForContextBinding(fullName); } serviceBuilder.addDependency(contextServiceName, NamingStore.class, managedReferenceFactory.getNamingStoreInjectedValue()); injector.inject(managedReferenceFactory); } }
/** * Get the context service name. * * @return the context service name */ public ServiceName getContextServiceName() { if (contextServiceName != null) return contextServiceName; if (getNamingMode() == ComponentNamingMode.CREATE) { return ContextNames.contextServiceNameOfComponent(getApplicationName(), getModuleName(), getComponentName()); } else if (getNamingMode() == ComponentNamingMode.USE_MODULE) { return ContextNames.contextServiceNameOfModule(getApplicationName(), getModuleName()); } else { throw new IllegalStateException(); } }
@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(); }
private void bindValueToJndi(final StartContext context) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName); final BinderService binderService = new BinderService(bindInfo.getBindName()); binderService.getManagedObjectInjector().inject(new ImmediateManagedReferenceFactory(getValue())); context.getChildTarget().addService(bindInfo.getBinderServiceName(),binderService) .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install(); }
final ServiceName mailSessionServiceName = MailSessionDefinition.SESSION_CAPABILITY.getCapabilityServiceName().append("MailSessionDefinition", moduleDescription.getApplicationName(), moduleDescription.getModuleName(), jndiName); final ServiceBuilder<?> mailSessionServiceBuilder = serviceTarget .addService(mailSessionServiceName, mailSessionService); final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), jndiName); final BinderService binderService = new BinderService(bindInfo.getBindName(), this); binderService.getManagedObjectInjector().inject(new MailSessionManagedReferenceFactory(mailSessionService)); final ServiceBuilder<ManagedReferenceFactory> binderBuilder = serviceTarget .addService(bindInfo.getBinderServiceName(), binderService) .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new LifecycleListener() { @Override public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) { mailSessionServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install(); binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
private static void entityManagerFactoryBind(EEModuleDescription eeModuleDescription, ServiceTarget serviceTarget, PersistenceUnitMetadata pu, ServiceName puServiceName) { if (pu.getProperties().containsKey(ENTITYMANAGERFACTORY_JNDI_PROPERTY)) { String jndiName = pu.getProperties().get(ENTITYMANAGERFACTORY_JNDI_PROPERTY).toString(); final ContextNames.BindInfo bindingInfo; if (jndiName.startsWith("java:")) { bindingInfo = ContextNames.bindInfoForEnvEntry(eeModuleDescription.getApplicationName(), eeModuleDescription.getModuleName(), eeModuleDescription.getModuleName(), false, jndiName); } else { bindingInfo = ContextNames.bindInfoFor(jndiName); } ROOT_LOGGER.tracef("binding the entity manager factory to jndi name '%s'", bindingInfo.getAbsoluteJndiName()); final BinderService binderService = new BinderService(bindingInfo.getBindName()); serviceTarget.addService(bindingInfo.getBinderServiceName(), binderService) .addDependency(bindingInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addDependency(puServiceName, PersistenceUnitServiceImpl.class, new Injector<PersistenceUnitServiceImpl>() { @Override public void inject(final PersistenceUnitServiceImpl value) throws InjectionException { binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value.getEntityManagerFactory()))); } @Override public void uninject() { binderService.getNamingStoreInjector().uninject(); } }).install(); } }
ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), jndiName); ServiceName serviceName = DirectAdminObjectActivatorService.SERVICE_NAME_BASE.append(jndiName); final ServiceBuilder sb = phaseContext.getServiceTarget().addService(serviceName, service); sb.addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, service.getMdrInjector()); sb.requires(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(deployerServiceName)); sb.setInitialMode(ServiceController.Mode.ACTIVE).install(); serviceBuilder.addDependency(AdminObjectReferenceFactoryService.SERVICE_NAME_BASE.append(bindInfo.getBinderServiceName()), ManagedReferenceFactory.class, injector); serviceBuilder.addListener(new LifecycleListener() { public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
/** * <p> * Adds a {@code BinderService} to the specified target. The service binds the specified value to JNDI under the * {@code java:/jboss/contextName} context. * </p> * * @param target the {@code ServiceTarget} where the service will be added. * @param contextName the JNDI context name where the value will be bound. * @param value the value to be bound. */ public static void bindObject(final ServiceTarget target, final String contextName, final Object value) { final BinderService binderService = new BinderService(contextName); binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(Values.immediateValue(value))); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, contextName), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install(); } }
dataSourceConfiguration.connectionPoolConfiguration(connectionPoolConfiguration); ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), jndiName); ServiceName dataSourceServiceName = DATASOURCE_DEFINITION_SERVICE_PREFIX.append(bindInfo.getBinderServiceName().getCanonicalName()); BinderService binderService = new BinderService(bindInfo.getBindName(), this); phaseContext.getServiceTarget().addService(bindInfo.getBinderServiceName(), binderService) .addDependency(dataSourceServiceName, ManagedReferenceFactory.class, binderService.getManagedObjectInjector()) .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install(); ServiceBuilder svcBuilder = phaseContext.getServiceTarget().addService(dataSourceServiceName); Supplier<TransactionSynchronizationRegistry> tsrSupplier = null; if (transactional) {
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); }
void firstRuntimeStep(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String jndiName = JNDI_NAME.resolveModelAttribute(context, model).asString(); final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName); final boolean jta = JTA.resolveModelAttribute(context, operation).asBoolean(); final String dsName = context.getCurrentAddressValue();// The STATISTICS_ENABLED.resolveModelAttribute(context, model) call should remain as it serves to validate that any final ServiceName driverServiceName = ServiceName.JBOSS.append("jdbc-driver", driverName.replaceAll("\\.", "_")); final ServiceName driverDemanderServiceName = ServiceName.JBOSS.append("driver-demander").append(jndiName); final ServiceBuilder<?> driverDemanderBuilder = serviceTarget .addService(driverDemanderServiceName, driverDemanderService) .addDependency(driverServiceName, Driver.class, driverDemanderService.getInjector()); driverDemanderBuilder.setInitialMode(ServiceController.Mode.ACTIVE); final ServiceBuilder<?> dataSourceServiceBuilder = Services.addServerExecutorDependency( serviceTarget.addService(dataSourceServiceName, dataSourceService), dataSourceService.getExecutorServiceInjector()) .addAliases(dataSourceServiceNameAlias) .addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, dataSourceService.getManagementRepositoryInjector())
@SuppressWarnings("rawtypes") ServiceController<?> installJndiService(ServiceTarget target, String containerName, String cacheName, String jndiName) { final ServiceName cacheServiceName = CacheServiceName.CACHE.getServiceName(containerName, cacheName); final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName); final BinderService binder = new BinderService(bindInfo.getBindName()); return target.addService(bindInfo.getBinderServiceName(), binder) .addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(jndiName)) .addDependency(cacheServiceName, Cache.class, new ManagedReferenceInjector<>(binder.getManagedObjectInjector())) .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binder.getNamingStoreInjector()) .setInitialMode(ServiceController.Mode.PASSIVE) .install() ; }
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final String jndiName = DatabaseDataStoreResourceDefinition.DATASOURCE_JNDI_NAME.resolveModelAttribute(context, model).asString(); final ModelNode dataBaseValue = DatabaseDataStoreResourceDefinition.DATABASE.resolveModelAttribute(context, model); final String database; if(dataBaseValue.isDefined()) { database = dataBaseValue.asString(); } else { database = null; } final String partition = DatabaseDataStoreResourceDefinition.PARTITION.resolveModelAttribute(context, model).asString(); final String name = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue(); int refreshInterval = DatabaseDataStoreResourceDefinition.REFRESH_INTERVAL.resolveModelAttribute(context, model).asInt(); boolean allowExecution = DatabaseDataStoreResourceDefinition.ALLOW_EXECUTION.resolveModelAttribute(context, model).asBoolean(); final String nodeName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null); final DatabaseTimerPersistence databaseTimerPersistence = new DatabaseTimerPersistence(database, partition, nodeName, refreshInterval, allowExecution); final ServiceName serviceName = TimerPersistence.SERVICE_NAME.append(name); context.getServiceTarget().addService(serviceName, databaseTimerPersistence) .addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ModuleLoader.class, databaseTimerPersistence.getModuleLoader()) .addDependency(ContextNames.bindInfoFor(jndiName).getBinderServiceName(), ManagedReferenceFactory.class, databaseTimerPersistence.getDataSourceInjectedValue()) .addDependency(TimerServiceDeploymentProcessor.TIMER_SERVICE_NAME, java.util.Timer.class, databaseTimerPersistence.getTimerInjectedValue()) .install(); }
final ServiceName weldServiceName = topLevelDeployment.getServiceName().append(WeldBootstrapService.SERVICE_NAME); final ServiceBuilder<?> builder = serviceTarget.addService(beanManagerServiceName); final Consumer<BeanManager> beanManagerConsumer = builder.provides(beanManagerServiceName); final Supplier<WeldBootstrapService> weldContainerSupplier = builder.requires(weldServiceName); builder.setInstance(new BeanManagerService(rootBda.getId(), beanManagerConsumer, weldContainerSupplier)); builder.install(); final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName()); bindBeanManager(serviceTarget, beanManagerServiceName, moduleContextServiceName, dependencies, phaseContext.getServiceRegistry()); final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getApplicationName(), moduleDescription.getModuleName(), component.getComponentName()); bindBeanManager(serviceTarget, beanManagerServiceName, compContextServiceName, dependencies, phaseContext.getServiceRegistry());
builder.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, objStoreEnvironmentService.getPathManagerInjector()); builder.requires(TxnServices.JBOSS_TXN_CORE_ENVIRONMENT); if (useJdbcStore) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(dataSourceJndiName); builder.requires(bindInfo.getBinderServiceName()); builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
final ServiceName dataSourceCongServiceName = DataSourceConfigService.SERVICE_NAME_BASE.append(dsName); final ServiceName xaDataSourceConfigServiceName = XADataSourceConfigService.SERVICE_NAME_BASE.append(dsName); final ServiceName driverDemanderServiceName = ServiceName.JBOSS.append("driver-demander").append(jndiName); final ServiceName referenceFactoryServiceName = DataSourceReferenceFactoryService.SERVICE_NAME_BASE .append(dsName); final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName); context.removeService(bindInfo.getBinderServiceName());