Search in sources :

Example 96 with ServiceTarget

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);
        }
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) ServiceTarget(org.jboss.msc.service.ServiceTarget) Driver(java.sql.Driver) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModuleLoadException(org.jboss.modules.ModuleLoadException)

Example 97 with ServiceTarget

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();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Example 98 with ServiceTarget

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();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ModelNode(org.jboss.dmr.ModelNode)

Example 99 with ServiceTarget

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);
}
Also used : JBossContextXATerminator(org.jboss.as.txn.integration.JBossContextXATerminator) DriverRegistryService(org.jboss.as.connector.services.driver.registry.DriverRegistryService) RaDeploymentActivator(org.jboss.as.connector.deployers.ra.RaDeploymentActivator) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) TransactionIntegrationService(org.jboss.as.connector.services.transactionintegration.TransactionIntegrationService)

Example 100 with 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();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Aggregations

ServiceTarget (org.jboss.msc.service.ServiceTarget)108 ServiceName (org.jboss.msc.service.ServiceName)57 PathAddress (org.jboss.as.controller.PathAddress)30 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)26 ModelNode (org.jboss.dmr.ModelNode)26 Module (org.jboss.modules.Module)18 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)12 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)11 ContextNames (org.jboss.as.naming.deployment.ContextNames)11 Resource (org.jboss.as.controller.registry.Resource)10 BinderService (org.jboss.as.naming.service.BinderService)10 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)10 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)10 PathElement (org.jboss.as.controller.PathElement)9 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)9 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)9 ServiceController (org.jboss.msc.service.ServiceController)8 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5