Search in sources :

Example 1 with CapabilityServiceTarget

use of org.jboss.as.controller.CapabilityServiceTarget in project wildfly by wildfly.

the class TransactionSubsystemAdd method performObjectStoreBoottime.

private void performObjectStoreBoottime(OperationContext context, ModelNode model) throws OperationFailedException {
    boolean useJournalStore = model.hasDefined(USE_JOURNAL_STORE) && model.get(USE_JOURNAL_STORE).asBoolean();
    final boolean enableAsyncIO = TransactionSubsystemRootResourceDefinition.JOURNAL_STORE_ENABLE_ASYNC_IO.resolveModelAttribute(context, model).asBoolean();
    final String objectStorePathRef = TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.resolveModelAttribute(context, model).isDefined() ? TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.resolveModelAttribute(context, model).asString() : null;
    final String objectStorePath = TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.resolveModelAttribute(context, model).asString();
    final boolean useJdbcStore = model.hasDefined(USE_JDBC_STORE) && model.get(USE_JDBC_STORE).asBoolean();
    final String dataSourceJndiName = TransactionSubsystemRootResourceDefinition.JDBC_STORE_DATASOURCE.resolveModelAttribute(context, model).asString();
    ArjunaObjectStoreEnvironmentService.JdbcStoreConfigBulder confiBuilder = new ArjunaObjectStoreEnvironmentService.JdbcStoreConfigBulder();
    confiBuilder.setActionDropTable(TransactionSubsystemRootResourceDefinition.JDBC_ACTION_STORE_DROP_TABLE.resolveModelAttribute(context, model).asBoolean()).setStateDropTable(TransactionSubsystemRootResourceDefinition.JDBC_STATE_STORE_DROP_TABLE.resolveModelAttribute(context, model).asBoolean()).setCommunicationDropTable(TransactionSubsystemRootResourceDefinition.JDBC_COMMUNICATION_STORE_DROP_TABLE.resolveModelAttribute(context, model).asBoolean());
    if (model.hasDefined(TransactionSubsystemRootResourceDefinition.JDBC_ACTION_STORE_TABLE_PREFIX.getName()))
        confiBuilder.setActionTablePrefix(TransactionSubsystemRootResourceDefinition.JDBC_ACTION_STORE_TABLE_PREFIX.resolveModelAttribute(context, model).asString());
    if (model.hasDefined(TransactionSubsystemRootResourceDefinition.JDBC_STATE_STORE_TABLE_PREFIX.getName()))
        confiBuilder.setStateTablePrefix(TransactionSubsystemRootResourceDefinition.JDBC_STATE_STORE_TABLE_PREFIX.resolveModelAttribute(context, model).asString());
    if (model.hasDefined(TransactionSubsystemRootResourceDefinition.JDBC_COMMUNICATION_STORE_TABLE_PREFIX.getName()))
        confiBuilder.setCommunicationTablePrefix(TransactionSubsystemRootResourceDefinition.JDBC_COMMUNICATION_STORE_TABLE_PREFIX.resolveModelAttribute(context, model).asString());
    TransactionLogger.ROOT_LOGGER.debugf("objectStorePathRef=%s, objectStorePath=%s%n", objectStorePathRef, objectStorePath);
    CapabilityServiceTarget target = context.getCapabilityServiceTarget();
    // Configure the ObjectStoreEnvironmentBeans
    final ArjunaObjectStoreEnvironmentService objStoreEnvironmentService = new ArjunaObjectStoreEnvironmentService(useJournalStore, enableAsyncIO, objectStorePath, objectStorePathRef, useJdbcStore, dataSourceJndiName, confiBuilder.build());
    ServiceBuilder<Void> builder = target.addService(TxnServices.JBOSS_TXN_ARJUNA_OBJECTSTORE_ENVIRONMENT, objStoreEnvironmentService);
    builder.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, objStoreEnvironmentService.getPathManagerInjector());
    builder.requires(TxnServices.JBOSS_TXN_CORE_ENVIRONMENT);
    if (useJdbcStore) {
        final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(dataSourceJndiName);
        builder.requires(bindInfo.getBinderServiceName());
    }
    builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    TransactionManagerService.addService(target);
    UserTransactionService.addService(target);
    target.addService(TxnServices.JBOSS_TXN_USER_TRANSACTION_REGISTRY, new UserTransactionRegistryService()).setInitialMode(ServiceController.Mode.ACTIVE).install();
    TransactionSynchronizationRegistryService.addService(target);
}
Also used : UserTransactionRegistryService(org.jboss.as.txn.service.UserTransactionRegistryService) ArjunaObjectStoreEnvironmentService(org.jboss.as.txn.service.ArjunaObjectStoreEnvironmentService) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 2 with CapabilityServiceTarget

use of org.jboss.as.controller.CapabilityServiceTarget in project wildfly by wildfly.

the class DatabaseDataStoreAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    final String jndiName = DatabaseDataStoreResourceDefinition.DATASOURCE_JNDI_NAME.resolveModelAttribute(context, model).asString();
    final ModelNode dataBaseValue = DatabaseDataStoreResourceDefinition.DATABASE.resolveModelAttribute(context, model);
    final String database;
    if (dataBaseValue.isDefined()) {
        database = dataBaseValue.asString();
    } else {
        database = null;
    }
    final String partition = DatabaseDataStoreResourceDefinition.PARTITION.resolveModelAttribute(context, model).asString();
    int refreshInterval = DatabaseDataStoreResourceDefinition.REFRESH_INTERVAL.resolveModelAttribute(context, model).asInt();
    boolean allowExecution = DatabaseDataStoreResourceDefinition.ALLOW_EXECUTION.resolveModelAttribute(context, model).asBoolean();
    final String nodeName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null);
    final DatabaseTimerPersistence databaseTimerPersistence = new DatabaseTimerPersistence(database, partition, nodeName, refreshInterval, allowExecution);
    // add the TimerPersistence instance
    final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
    final CapabilityServiceBuilder<DatabaseTimerPersistence> builder = serviceTarget.addCapability(TimerServiceResourceDefinition.TIMER_PERSISTENCE_CAPABILITY, databaseTimerPersistence);
    builder.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ModuleLoader.class, databaseTimerPersistence.getModuleLoader());
    builder.addDependency(ContextNames.bindInfoFor(jndiName).getBinderServiceName(), ManagedReferenceFactory.class, databaseTimerPersistence.getDataSourceInjectedValue());
    builder.addCapabilityRequirement(TIMER_SERVICE_CAPABILITY_NAME, java.util.Timer.class, databaseTimerPersistence.getTimerInjectedValue());
    builder.install();
}
Also used : ModelNode(org.jboss.dmr.ModelNode) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget) DatabaseTimerPersistence(org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence)

Example 3 with CapabilityServiceTarget

use of org.jboss.as.controller.CapabilityServiceTarget in project wildfly by wildfly.

the class FileDataStoreAdd method performRuntime.

protected void performRuntime(final OperationContext context, ModelNode operation, final ModelNode model) throws OperationFailedException {
    final ModelNode pathNode = FileDataStoreResourceDefinition.PATH.resolveModelAttribute(context, model);
    final String path = pathNode.isDefined() ? pathNode.asString() : null;
    final ModelNode relativeToNode = FileDataStoreResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, model);
    final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null;
    final FileTimerPersistence fileTimerPersistence = new FileTimerPersistence(true, path, relativeTo);
    // add the TimerPersistence instance
    final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
    final CapabilityServiceBuilder<FileTimerPersistence> builder = serviceTarget.addCapability(TimerServiceResourceDefinition.TIMER_PERSISTENCE_CAPABILITY, fileTimerPersistence);
    builder.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ModuleLoader.class, fileTimerPersistence.getModuleLoader());
    builder.addCapabilityRequirement(PATH_MANAGER_CAPABILITY_NAME, PathManager.class, fileTimerPersistence.getPathManager());
    builder.addCapabilityRequirement(TRANSACTION_GLOBAL_DEFAULT_LOCAL_PROVIDER_CAPABILITY_NAME, Void.class);
    builder.addCapabilityRequirement(TRANSACTION_SYNCHRONIZATION_REGISTRY_CAPABILITY_NAME, TransactionSynchronizationRegistry.class, fileTimerPersistence.getTransactionSynchronizationRegistry());
    builder.install();
}
Also used : ModelNode(org.jboss.dmr.ModelNode) FileTimerPersistence(org.jboss.as.ejb3.timerservice.persistence.filestore.FileTimerPersistence) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget)

Example 4 with CapabilityServiceTarget

use of org.jboss.as.controller.CapabilityServiceTarget in project wildfly by wildfly.

the class MdbDeliveryGroupAdd method installServices.

protected void installServices(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    final boolean active = MdbDeliveryGroupResourceDefinition.ACTIVE.resolveModelAttribute(context, model).asBoolean();
    CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
    serviceTarget.addCapability(MdbDeliveryGroupResourceDefinition.MDB_DELIVERY_GROUP_CAPABILITY, Service.NULL).setInitialMode(active ? ServiceController.Mode.ACTIVE : ServiceController.Mode.NEVER).install();
}
Also used : CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget)

Example 5 with CapabilityServiceTarget

use of org.jboss.as.controller.CapabilityServiceTarget in project wildfly by wildfly.

the class StrictMaxPoolAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode strictMaxPoolModel) throws OperationFailedException {
    final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();
    final int maxPoolSize = StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.resolveModelAttribute(context, strictMaxPoolModel).asInt();
    final Derive derive = StrictMaxPoolResourceDefinition.parseDeriveSize(context, strictMaxPoolModel);
    final long timeout = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.resolveModelAttribute(context, strictMaxPoolModel).asLong();
    final String unit = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.resolveModelAttribute(context, strictMaxPoolModel).asString();
    // create and install the service
    final StrictMaxPoolConfigService poolConfigService = new StrictMaxPoolConfigService(poolName, maxPoolSize, derive, timeout, TimeUnit.valueOf(unit));
    CapabilityServiceTarget capabilityServiceTarget = context.getCapabilityServiceTarget();
    CapabilityServiceBuilder<StrictMaxPoolConfig> capabilityServiceBuilder = capabilityServiceTarget.addCapability(StrictMaxPoolResourceDefinition.STRICT_MAX_POOL_CONFIG_CAPABILITY, poolConfigService);
    if (context.hasOptionalCapability(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, null, null)) {
        capabilityServiceBuilder.addCapabilityRequirement(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, Integer.class, poolConfigService.getMaxThreadsInjector());
    }
    capabilityServiceBuilder.install();
}
Also used : StrictMaxPoolConfig(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfig) Derive(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService.Derive) StrictMaxPoolConfigService(org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService) CapabilityServiceTarget(org.jboss.as.controller.CapabilityServiceTarget)

Aggregations

CapabilityServiceTarget (org.jboss.as.controller.CapabilityServiceTarget)8 ContextNames (org.jboss.as.naming.deployment.ContextNames)2 ModelNode (org.jboss.dmr.ModelNode)2 PathHandler (io.undertow.server.handlers.PathHandler)1 TransactionSynchronizationRegistry (javax.transaction.TransactionSynchronizationRegistry)1 RaDeploymentActivator (org.jboss.as.connector.deployers.ra.RaDeploymentActivator)1 DriverRegistryService (org.jboss.as.connector.services.driver.registry.DriverRegistryService)1 TransactionIntegrationService (org.jboss.as.connector.services.transactionintegration.TransactionIntegrationService)1 CapabilityServiceBuilder (org.jboss.as.controller.CapabilityServiceBuilder)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 StrictMaxPoolConfig (org.jboss.as.ejb3.component.pool.StrictMaxPoolConfig)1 StrictMaxPoolConfigService (org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService)1 Derive (org.jboss.as.ejb3.component.pool.StrictMaxPoolConfigService.Derive)1 DatabaseTimerPersistence (org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence)1 FileTimerPersistence (org.jboss.as.ejb3.timerservice.persistence.filestore.FileTimerPersistence)1 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)1 ServiceBasedNamingStore (org.jboss.as.naming.ServiceBasedNamingStore)1 BinderService (org.jboss.as.naming.service.BinderService)1 SocketBinding (org.jboss.as.network.SocketBinding)1 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)1