use of org.jboss.msc.service.ServiceController 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);
phaseContext.getServiceTarget().addService(serviceName, service).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, service.getMdrInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(deployerServiceName)).setInitialMode(ServiceController.Mode.ACTIVE).install();
serviceBuilder.addDependency(AdminObjectReferenceFactoryService.SERVICE_NAME_BASE.append(bindInfo.getBinderServiceName()), ManagedReferenceFactory.class, injector);
serviceBuilder.addListener(new AbstractServiceListener<Object>() {
public void transition(final ServiceController<? extends Object> controller, final ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
DEPLOYMENT_CONNECTOR_LOGGER.adminObjectAnnotation(jndiName);
break;
}
case STOPPING_to_DOWN:
{
DEPLOYMENT_CONNECTOR_LOGGER.unboundJca("AdminObject", jndiName);
break;
}
case REMOVING_to_REMOVED:
{
DEPLOYMENT_CONNECTOR_LOGGER.debugf("Removed JCA AdminObject [%s]", jndiName);
}
}
}
});
}
use of org.jboss.msc.service.ServiceController 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);
ServiceName serviceName = DirectConnectionFactoryActivatorService.SERVICE_NAME_BASE.append(jndiName);
phaseContext.getServiceTarget().addService(serviceName, service).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, service.getMdrInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(deployerServiceName)).setInitialMode(ServiceController.Mode.ACTIVE).install();
serviceBuilder.addDependency(ConnectionFactoryReferenceFactoryService.SERVICE_NAME_BASE.append(bindInfo.getBinderServiceName()), ManagedReferenceFactory.class, injector);
serviceBuilder.addListener(new AbstractServiceListener<Object>() {
public void transition(final ServiceController<? extends Object> controller, final ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
DEPLOYMENT_CONNECTOR_LOGGER.connectionFactoryAnnotation(jndiName);
break;
}
case STOPPING_to_DOWN:
{
break;
}
case REMOVING_to_REMOVED:
{
DEPLOYMENT_CONNECTOR_LOGGER.debugf("Removed JCA ConnectionFactory [%s]", jndiName);
}
}
}
});
}
use of org.jboss.msc.service.ServiceController 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.msc.service.ServiceController in project wildfly by wildfly.
the class PoolOperations method execute.
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String jndiName;
ModelNode model;
if (!address.getElement(0).getKey().equals(ModelDescriptionConstants.DEPLOYMENT) && (model = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel()).isDefined()) {
jndiName = Util.getJndiName(context, model);
} else {
jndiName = address.getLastElement().getValue();
}
final Object[] parameters = getParameters(context, operation);
if (context.isNormalServer()) {
context.addStep(new OperationStepHandler() {
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final ServiceController<?> managementRepoService = context.getServiceRegistry(disallowMonitor).getService(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE);
if (managementRepoService != null) {
ModelNode operationResult = null;
try {
final ManagementRepository repository = (ManagementRepository) managementRepoService.getValue();
final List<Pool> pools = matcher.match(jndiName, repository);
if (pools.isEmpty()) {
throw ConnectorLogger.ROOT_LOGGER.failedToMatchPool(jndiName);
}
for (Pool pool : pools) {
operationResult = invokeCommandOn(pool, parameters);
}
} catch (Exception e) {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToInvokeOperation(e.getLocalizedMessage()));
}
if (operationResult != null) {
context.getResult().set(operationResult);
}
}
context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
}, OperationContext.Stage.RUNTIME);
}
context.stepCompleted();
}
use of org.jboss.msc.service.ServiceController 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);
}
Aggregations