use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class JdbcDriverRemove method recoverServices.
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) {
final String driverName = model.require(DRIVER_NAME.getName()).asString();
final String moduleName = model.require(DRIVER_MODULE_NAME.getName()).asString();
final Integer majorVersion = model.hasDefined(DRIVER_MAJOR_VERSION.getName()) ? model.get(DRIVER_MAJOR_VERSION.getName()).asInt() : null;
final Integer minorVersion = model.hasDefined(DRIVER_MINOR_VERSION.getName()) ? model.get(DRIVER_MINOR_VERSION.getName()).asInt() : null;
final String driverClassName = model.hasDefined(DRIVER_CLASS_NAME.getName()) ? model.get(DRIVER_CLASS_NAME.getName()).asString() : null;
final String dataSourceClassName = model.hasDefined(DRIVER_DATASOURCE_CLASS_NAME.getName()) ? model.get(DRIVER_DATASOURCE_CLASS_NAME.getName()).asString() : null;
final String xaDataSourceClassName = model.hasDefined(DRIVER_XA_DATASOURCE_CLASS_NAME.getName()) ? model.get(DRIVER_XA_DATASOURCE_CLASS_NAME.getName()).asString() : null;
final ServiceTarget target = context.getServiceTarget();
final ModuleIdentifier moduleId;
final Module module;
try {
moduleId = ModuleIdentifier.fromString(moduleName);
module = Module.getCallerModuleLoader().loadModule(moduleId);
} catch (ModuleLoadException e) {
context.getFailureDescription().set(ConnectorLogger.ROOT_LOGGER.failedToLoadModuleDriver(moduleName));
return;
}
if (driverClassName == null) {
final ServiceLoader<Driver> serviceLoader = module.loadService(Driver.class);
if (serviceLoader != null)
for (Driver driver : serviceLoader) {
startDriverServices(target, moduleId, driver, driverName, majorVersion, minorVersion, dataSourceClassName, xaDataSourceClassName);
}
} else {
try {
final Class<? extends Driver> driverClass = module.getClassLoader().loadClass(driverClassName).asSubclass(Driver.class);
final Constructor<? extends Driver> constructor = driverClass.getConstructor();
final Driver driver = constructor.newInstance();
startDriverServices(target, moduleId, driver, driverName, majorVersion, minorVersion, dataSourceClassName, xaDataSourceClassName);
} catch (Exception e) {
SUBSYSTEM_DATASOURCES_LOGGER.cannotInstantiateDriverClass(driverClassName, e);
}
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class TracerAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
final boolean enabled = TracerDefinition.TracerParameters.TRACER_ENABLED.getAttribute().resolveModelAttribute(context, model).asBoolean();
ServiceName serviceName = ConnectorServices.TRACER_CONFIG_SERVICE;
ServiceName jcaConfigServiceName = ConnectorServices.CONNECTOR_CONFIG_SERVICE;
final ServiceTarget serviceTarget = context.getServiceTarget();
final TracerService.Tracer config = new TracerService.Tracer(enabled);
final TracerService service = new TracerService(config);
serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(jcaConfigServiceName, JcaSubsystemConfiguration.class, service.getJcaConfigInjector()).install();
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class CDConfigPropertyAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException {
final String configPropertyValue = CONFIG_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString();
final ModelNode address = operation.require(OP_ADDR);
PathAddress path = PathAddress.pathAddress(address);
final String archiveName = path.getElement(path.size() - 3).getValue();
final String cfName = path.getElement(path.size() - 2).getValue();
final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue();
ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, archiveName, cfName, configPropertyName);
ServiceName cfServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, archiveName, cfName);
final ServiceTarget serviceTarget = context.getServiceTarget();
final CDConfigPropertiesService service = new CDConfigPropertiesService(configPropertyName, configPropertyValue);
serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(cfServiceName, ModifiableConnDef.class, service.getRaInjector()).install();
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class JcaSubsystemAdd method performBoottime.
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) {
final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
final RaDeploymentActivator raDeploymentActivator = new RaDeploymentActivator(appclient);
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(DeploymentProcessorTarget processorTarget) {
raDeploymentActivator.activateProcessors(processorTarget);
}
}, OperationContext.Stage.RUNTIME);
ServiceTarget serviceTarget = context.getServiceTarget();
TransactionIntegrationService tiService = new TransactionIntegrationService();
serviceTarget.addService(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, tiService).addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER, TransactionManager.class, tiService.getTmInjector()).addDependency(TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY, TransactionSynchronizationRegistry.class, tiService.getTsrInjector()).addDependency(TxnServices.JBOSS_TXN_USER_TRANSACTION_REGISTRY, org.jboss.tm.usertx.UserTransactionRegistry.class, tiService.getUtrInjector()).addDependency(TxnServices.JBOSS_TXN_CONTEXT_XA_TERMINATOR, JBossContextXATerminator.class, tiService.getTerminatorInjector()).addDependency(TxnServices.JBOSS_TXN_ARJUNA_RECOVERY_MANAGER, XAResourceRecoveryRegistry.class, tiService.getRrInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
final JcaSubsystemConfiguration config = new JcaSubsystemConfiguration();
final JcaConfigService connectorConfigService = new JcaConfigService(config);
serviceTarget.addService(ConnectorServices.CONNECTOR_CONFIG_SERVICE, connectorConfigService).setInitialMode(Mode.ACTIVE).install();
final IdleRemoverService idleRemoverService = new IdleRemoverService();
serviceTarget.addService(ConnectorServices.IDLE_REMOVER_SERVICE, idleRemoverService).setInitialMode(Mode.ACTIVE).install();
final ConnectionValidatorService connectionValidatorService = new ConnectionValidatorService();
serviceTarget.addService(ConnectorServices.CONNECTION_VALIDATOR_SERVICE, connectionValidatorService).setInitialMode(Mode.ACTIVE).install();
// TODO does the install of this and the DriverProcessor
// belong in DataSourcesSubsystemAdd?
final DriverRegistryService driverRegistryService = new DriverRegistryService();
serviceTarget.addService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE, driverRegistryService).install();
raDeploymentActivator.activateServices(serviceTarget);
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class ArchiveValidationAdd method performBoottime.
@Override
protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
final boolean enabled = JcaArchiveValidationDefinition.ArchiveValidationParameters.ARCHIVE_VALIDATION_ENABLED.getAttribute().resolveModelAttribute(context, model).asBoolean();
final boolean failOnError = JcaArchiveValidationDefinition.ArchiveValidationParameters.ARCHIVE_VALIDATION_FAIL_ON_ERROR.getAttribute().resolveModelAttribute(context, model).asBoolean();
final boolean failOnWarn = JcaArchiveValidationDefinition.ArchiveValidationParameters.ARCHIVE_VALIDATION_FAIL_ON_WARN.getAttribute().resolveModelAttribute(context, model).asBoolean();
ServiceName serviceName = ConnectorServices.ARCHIVE_VALIDATION_CONFIG_SERVICE;
ServiceName jcaConfigServiceName = ConnectorServices.CONNECTOR_CONFIG_SERVICE;
final ServiceTarget serviceTarget = context.getServiceTarget();
final ArchiveValidationService.ArchiveValidation config = new ArchiveValidationService.ArchiveValidation(enabled, failOnError, failOnWarn);
final ArchiveValidationService service = new ArchiveValidationService(config);
ServiceController<?> controller = serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(jcaConfigServiceName, JcaSubsystemConfiguration.class, service.getJcaConfigInjector()).install();
}
Aggregations