use of org.jboss.msc.service.LifecycleListener in project wildfly by wildfly.
the class JMSDestinationDefinitionInjectionSource method inject.
private <D extends Destination> void inject(ServiceBuilder<?> serviceBuilder, Injector<ManagedReferenceFactory> injector, Service<D> destinationService) {
final ContextListAndJndiViewManagedReferenceFactory referenceFactoryService = new MessagingJMSDestinationManagedReferenceFactory(destinationService);
injector.inject(referenceFactoryService);
serviceBuilder.addListener(new LifecycleListener() {
private volatile boolean bound;
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
switch(event) {
case UP:
{
ROOT_LOGGER.boundJndiName(jndiName);
bound = true;
break;
}
case DOWN:
{
if (bound) {
ROOT_LOGGER.unboundJndiName(jndiName);
}
break;
}
case REMOVED:
{
ROOT_LOGGER.debugf("Removed messaging object [%s]", jndiName);
break;
}
}
}
});
}
use of org.jboss.msc.service.LifecycleListener in project wildfly by wildfly.
the class WildFlyBindingRegistry method unbind.
/**
* Unbind the resource and wait until the corresponding binding service is effectively removed.
*/
@Override
public void unbind(String name) {
if (name == null || name.isEmpty()) {
throw MessagingLogger.ROOT_LOGGER.cannotUnbindJndiName();
}
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
ServiceController<?> bindingService = container.getService(bindInfo.getBinderServiceName());
if (bindingService == null) {
ROOT_LOGGER.debugf("Cannot unbind %s since no binding exists with that name", name);
return;
}
// remove the binding service
final CountDownLatch latch = new CountDownLatch(1);
bindingService.addListener(new LifecycleListener() {
@Override
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
if (event == LifecycleEvent.REMOVED) {
ROOT_LOGGER.unboundJndiName(bindInfo.getAbsoluteJndiName());
latch.countDown();
}
}
});
try {
bindingService.setMode(ServiceController.Mode.REMOVE);
} finally {
try {
latch.await();
} catch (InterruptedException ie) {
ROOT_LOGGER.failedToUnbindJndiName(name, 5, SECONDS.toString().toLowerCase(Locale.US));
}
}
}
use of org.jboss.msc.service.LifecycleListener in project wildfly by wildfly.
the class AdministeredObjectDefinitionInjectionSource method getResourceValue.
public void getResourceValue(final ResolutionContext context, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
String raId = resourceAdapter;
if (resourceAdapter.startsWith("#")) {
raId = deploymentUnit.getParent().getName() + raId;
}
String deployerServiceName = raId;
if (!raId.endsWith(".rar")) {
deployerServiceName = deployerServiceName + ".rar";
raId = deployerServiceName;
}
SUBSYSTEM_RA_LOGGER.debugf("@AdministeredObjectDefinition: %s for %s binding to %s ", className, resourceAdapter, jndiName);
ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), jndiName);
DirectAdminObjectActivatorService service = new DirectAdminObjectActivatorService(jndiName, className, resourceAdapter, raId, properties, module, bindInfo);
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() {
private volatile boolean bound;
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
switch(event) {
case UP:
{
DEPLOYMENT_CONNECTOR_LOGGER.adminObjectAnnotation(jndiName);
bound = true;
break;
}
case DOWN:
{
if (bound) {
DEPLOYMENT_CONNECTOR_LOGGER.unboundJca("AdminObject", jndiName);
}
break;
}
case REMOVED:
{
DEPLOYMENT_CONNECTOR_LOGGER.debugf("Removed JCA AdminObject [%s]", jndiName);
}
}
}
});
}
use of org.jboss.msc.service.LifecycleListener 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 CapabilityServiceSupport support) {
final ServiceName dataSourceServiceName = AbstractDataSourceService.getServiceName(bindInfo);
final ServiceBuilder<?> dataSourceServiceBuilder = Services.addServerExecutorDependency(serviceTarget.addService(dataSourceServiceName, dataSourceService), dataSourceService.getExecutorServiceInjector()).addDependency(ConnectorServices.IRONJACAMAR_MDR, MetadataRepository.class, dataSourceService.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, dataSourceService.getRaRepositoryInjector()).addDependency(support.getCapabilityServiceName(ConnectorServices.TRANSACTION_INTEGRATION_CAPABILITY_NAME), 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());
dataSourceServiceBuilder.requires(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(DEFAULT_NAME));
dataSourceServiceBuilder.requires(support.getCapabilityServiceName(NamingService.CAPABILITY_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 LifecycleListener() {
private volatile boolean bound;
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
switch(event) {
case UP:
{
if (isTransactional()) {
SUBSYSTEM_DATASOURCES_LOGGER.boundDataSource(jndiName);
} else {
SUBSYSTEM_DATASOURCES_LOGGER.boundNonJTADataSource(jndiName);
}
bound = true;
break;
}
case DOWN:
{
if (bound) {
if (isTransactional()) {
SUBSYSTEM_DATASOURCES_LOGGER.unboundDataSource(jndiName);
} else {
SUBSYSTEM_DATASOURCES_LOGGER.unBoundNonJTADataSource(jndiName);
}
}
break;
}
case 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.msc.service.LifecycleListener in project wildfly by wildfly.
the class ConnectionFactoryDefinitionInjectionSource method getResourceValue.
public void getResourceValue(final ResolutionContext context, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
String raId = resourceAdapter;
if (resourceAdapter.startsWith("#")) {
raId = deploymentUnit.getParent().getName() + raId;
}
String deployerServiceName = raId;
if (!raId.endsWith(".rar")) {
deployerServiceName = deployerServiceName + ".rar";
raId = deployerServiceName;
}
SUBSYSTEM_RA_LOGGER.debugf("@ConnectionFactoryDefinition: %s for %s binding to %s ", interfaceName, resourceAdapter, jndiName);
ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), jndiName);
DirectConnectionFactoryActivatorService service = new DirectConnectionFactoryActivatorService(jndiName, interfaceName, resourceAdapter, raId, maxPoolSize, minPoolSize, properties, transactionSupport, module, bindInfo, legacySecurityAvailable);
ServiceName serviceName = DirectConnectionFactoryActivatorService.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(ConnectionFactoryReferenceFactoryService.SERVICE_NAME_BASE.append(bindInfo.getBinderServiceName()), ManagedReferenceFactory.class, injector);
serviceBuilder.addListener(new LifecycleListener() {
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
switch(event) {
case UP:
{
DEPLOYMENT_CONNECTOR_LOGGER.connectionFactoryAnnotation(jndiName);
break;
}
case DOWN:
{
break;
}
case REMOVED:
{
DEPLOYMENT_CONNECTOR_LOGGER.debugf("Removed JCA ConnectionFactory [%s]", jndiName);
}
}
}
});
}
Aggregations