use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class WeldBeanManagerServiceProcessor method bindBeanManager.
private void bindBeanManager(ServiceTarget serviceTarget, ServiceName beanManagerServiceName, ServiceName contextServiceName, final Collection<ServiceName> dependencies, final ServiceRegistry serviceRegistry) {
final ServiceName beanManagerBindingServiceName = contextServiceName.append("BeanManager");
dependencies.add(beanManagerBindingServiceName);
BinderService beanManagerBindingService = new BinderService("BeanManager");
final BeanManagerManagedReferenceFactory referenceFactory = new BeanManagerManagedReferenceFactory();
serviceTarget.addService(beanManagerBindingServiceName, beanManagerBindingService).addInjection(beanManagerBindingService.getManagedObjectInjector(), referenceFactory).addDependency(contextServiceName, ServiceBasedNamingStore.class, beanManagerBindingService.getNamingStoreInjector()).addDependency(beanManagerServiceName, BeanManager.class, referenceFactory.beanManager).install();
}
use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class DsXmlDeploymentInstallProcessor method startDataSource.
private void startDataSource(final AbstractDataSourceService dataSourceService, final String jndiName, final String driverName, final ServiceTarget serviceTarget, final ManagementResourceRegistration registration, final Resource resource, final String managementName, boolean requireLegacySecurity, final boolean isTransactional) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
final ServiceName dataSourceServiceName = AbstractDataSourceService.getServiceName(bindInfo);
final ServiceBuilder<?> dataSourceServiceBuilder = Services.addServerExecutorDependency(serviceTarget.addService(dataSourceServiceName, dataSourceService), dataSourceService.getExecutorServiceInjector(), false).addDependency(ConnectorServices.IRONJACAMAR_MDR, MetadataRepository.class, dataSourceService.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, dataSourceService.getRaRepositoryInjector()).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(DEFAULT_NAME)).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, dataSourceService.getTransactionIntegrationInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, dataSourceService.getManagementRepositoryInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, dataSourceService.getCcmInjector()).addDependency(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE, DriverRegistry.class, dataSourceService.getDriverRegistryInjector()).addDependency(NamingService.SERVICE_NAME);
if (requireLegacySecurity) {
dataSourceServiceBuilder.addDependency(SimpleSecurityManagerService.SERVICE_NAME, ServerSecurityManager.class, dataSourceService.getServerSecurityManager());
dataSourceServiceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class, dataSourceService.getSubjectFactoryInjector());
}
//Register an empty override model regardless of we're enabled or not - the statistics listener will add the relevant childresources
if (registration.isAllowsOverride()) {
ManagementResourceRegistration overrideRegistration = registration.getOverrideModel(managementName);
if (overrideRegistration == null || overrideRegistration.isAllowsOverride()) {
overrideRegistration = registration.registerOverrideModel(managementName, DataSourcesSubsystemProviders.OVERRIDE_DS_DESC);
}
DataSourceStatisticsService statsService = new DataSourceStatisticsService(registration, false);
serviceTarget.addService(dataSourceServiceName.append(Constants.STATISTICS), statsService).addDependency(dataSourceServiceName).addDependency(CommonDeploymentService.getServiceName(bindInfo), CommonDeployment.class, statsService.getCommonDeploymentInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
DataSourceStatisticsService.registerStatisticsResources(resource);
}
// else should probably throw an ISE or something
final ServiceName driverServiceName = ServiceName.JBOSS.append("jdbc-driver", driverName.replaceAll("\\.", "_"));
if (driverServiceName != null) {
dataSourceServiceBuilder.addDependency(driverServiceName, Driver.class, dataSourceService.getDriverInjector());
}
final DataSourceReferenceFactoryService referenceFactoryService = new DataSourceReferenceFactoryService();
final ServiceName referenceFactoryServiceName = DataSourceReferenceFactoryService.SERVICE_NAME_BASE.append(jndiName);
final ServiceBuilder<?> referenceBuilder = serviceTarget.addService(referenceFactoryServiceName, referenceFactoryService).addDependency(dataSourceServiceName, javax.sql.DataSource.class, referenceFactoryService.getDataSourceInjector());
final BinderService binderService = new BinderService(bindInfo.getBindName());
final ServiceBuilder<?> binderBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(referenceFactoryServiceName, ManagedReferenceFactory.class, binderService.getManagedObjectInjector()).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new AbstractServiceListener<Object>() {
public void transition(final ServiceController<?> controller, final ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
if (isTransactional) {
SUBSYSTEM_DATASOURCES_LOGGER.boundDataSource(jndiName);
} else {
SUBSYSTEM_DATASOURCES_LOGGER.boundNonJTADataSource(jndiName);
}
break;
}
case START_REQUESTED_to_DOWN:
{
if (isTransactional) {
SUBSYSTEM_DATASOURCES_LOGGER.unboundDataSource(jndiName);
} else {
SUBSYSTEM_DATASOURCES_LOGGER.unBoundNonJTADataSource(jndiName);
}
break;
}
case REMOVING_to_REMOVED:
{
SUBSYSTEM_DATASOURCES_LOGGER.debugf("Removed JDBC Data-source [%s]", jndiName);
break;
}
}
}
});
dataSourceServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
referenceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class DataSourceDefinitionInjectionSource method startDataSource.
private void startDataSource(final AbstractDataSourceService dataSourceService, final ContextNames.BindInfo bindInfo, final EEModuleDescription moduleDescription, final ResolutionContext context, final ServiceTarget serviceTarget, final ServiceBuilder valueSourceServiceBuilder, final Injector<ManagedReferenceFactory> injector) {
final ServiceName dataSourceServiceName = AbstractDataSourceService.getServiceName(bindInfo);
final ServiceBuilder<?> dataSourceServiceBuilder = Services.addServerExecutorDependency(serviceTarget.addService(dataSourceServiceName, dataSourceService), dataSourceService.getExecutorServiceInjector(), false).addDependency(ConnectorServices.IRONJACAMAR_MDR, MetadataRepository.class, dataSourceService.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, dataSourceService.getRaRepositoryInjector()).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(DEFAULT_NAME)).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, dataSourceService.getTransactionIntegrationInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, dataSourceService.getManagementRepositoryInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, dataSourceService.getCcmInjector()).addDependency(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE, DriverRegistry.class, dataSourceService.getDriverRegistryInjector()).addDependency(NamingService.SERVICE_NAME);
// We don't need to inject legacy security subsystem services. They are only used with a configured legacy
// security domain, and the annotation does not support configuring that
// if(securityEnabled) {
// dataSourceServiceBuilder.addDependency(SimpleSecurityManagerService.SERVICE_NAME, ServerSecurityManager.class,
// dataSourceService.getServerSecurityManager());
// dataSourceServiceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
// dataSourceService.getSubjectFactoryInjector());
// }
final DataSourceReferenceFactoryService referenceFactoryService = new DataSourceReferenceFactoryService();
final ServiceName referenceFactoryServiceName = DataSourceReferenceFactoryService.SERVICE_NAME_BASE.append(bindInfo.getBinderServiceName());
final ServiceBuilder<?> referenceBuilder = serviceTarget.addService(referenceFactoryServiceName, referenceFactoryService).addDependency(dataSourceServiceName, javax.sql.DataSource.class, referenceFactoryService.getDataSourceInjector());
final BinderService binderService = new BinderService(bindInfo.getBindName(), this);
final ServiceBuilder<?> binderBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(referenceFactoryServiceName, ManagedReferenceFactory.class, binderService.getManagedObjectInjector()).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new AbstractServiceListener<Object>() {
public void transition(final ServiceController<? extends Object> controller, final ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
if (isTransactional()) {
SUBSYSTEM_DATASOURCES_LOGGER.boundDataSource(jndiName);
} else {
SUBSYSTEM_DATASOURCES_LOGGER.boundNonJTADataSource(jndiName);
}
break;
}
case START_REQUESTED_to_DOWN:
{
if (isTransactional()) {
SUBSYSTEM_DATASOURCES_LOGGER.unboundDataSource(jndiName);
} else {
SUBSYSTEM_DATASOURCES_LOGGER.unBoundNonJTADataSource(jndiName);
}
break;
}
case REMOVING_to_REMOVED:
{
SUBSYSTEM_DATASOURCES_LOGGER.debugf("Removed JDBC Data-source [%s]", jndiName);
break;
}
}
}
});
dataSourceServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
referenceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
valueSourceServiceBuilder.addDependency(bindInfo.getBinderServiceName(), ManagedReferenceFactory.class, injector);
}
use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class PersistenceUnitServiceHandler method entityManagerBind.
private static void entityManagerBind(EEModuleDescription eeModuleDescription, ServiceTarget serviceTarget, final PersistenceUnitMetadata pu, ServiceName puServiceName, TransactionManager transactionManager, TransactionSynchronizationRegistry transactionSynchronizationRegistry) {
if (pu.getProperties().containsKey(ENTITYMANAGER_JNDI_PROPERTY)) {
String jndiName = pu.getProperties().get(ENTITYMANAGER_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 transaction scoped entity manager 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>(new TransactionScopedEntityManager(pu.getScopedPersistenceUnitName(), Collections.emptyMap(), value.getEntityManagerFactory(), SynchronizationType.SYNCHRONIZED, transactionSynchronizationRegistry, transactionManager))));
}
@Override
public void uninject() {
binderService.getNamingStoreInjector().uninject();
}
}).install();
}
}
use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class PersistenceUnitServiceHandler method entityManagerFactoryBind.
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();
}
}
Aggregations