Search in sources :

Example 1 with ArjunaObjectStoreEnvironmentService

use of org.jboss.as.txn.service.ArjunaObjectStoreEnvironmentService 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);
    ServiceTarget target = context.getServiceTarget();
    // 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).addDependency(PathManagerService.SERVICE_NAME, PathManager.class, objStoreEnvironmentService.getPathManagerInjector()).addDependency(TxnServices.JBOSS_TXN_CORE_ENVIRONMENT);
    if (useJdbcStore) {
        final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(dataSourceJndiName);
        builder.addDependency(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 : PathManager(org.jboss.as.controller.services.path.PathManager) UserTransactionRegistryService(org.jboss.as.txn.service.UserTransactionRegistryService) ArjunaObjectStoreEnvironmentService(org.jboss.as.txn.service.ArjunaObjectStoreEnvironmentService) ServiceTarget(org.jboss.msc.service.ServiceTarget) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Aggregations

PathManager (org.jboss.as.controller.services.path.PathManager)1 ContextNames (org.jboss.as.naming.deployment.ContextNames)1 ArjunaObjectStoreEnvironmentService (org.jboss.as.txn.service.ArjunaObjectStoreEnvironmentService)1 UserTransactionRegistryService (org.jboss.as.txn.service.UserTransactionRegistryService)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1