Search in sources :

Example 1 with DatabaseTimerPersistence

use of org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence in project wildfly by wildfly.

the class DatabaseDataStoreAdd method installRuntimeServices.

public ServiceController<DatabaseTimerPersistence> installRuntimeServices(final OperationContext context, final ModelNode operation, final ModelNode model, final ServiceVerificationHandler verificationHandler) 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();
    final String name = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue();
    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);
    final ServiceName serviceName = TimerPersistence.SERVICE_NAME.append(name);
    final ServiceBuilder<DatabaseTimerPersistence> builder = context.getServiceTarget().addService(serviceName, databaseTimerPersistence);
    if (verificationHandler != null) {
        builder.addListener(verificationHandler);
    }
    return builder.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ModuleLoader.class, databaseTimerPersistence.getModuleLoader()).addDependency(ContextNames.bindInfoFor(jndiName).getBinderServiceName(), ManagedReferenceFactory.class, databaseTimerPersistence.getDataSourceInjectedValue()).addDependency(TimerServiceDeploymentProcessor.TIMER_SERVICE_NAME, java.util.Timer.class, databaseTimerPersistence.getTimerInjectedValue()).install();
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) ServiceName(org.jboss.msc.service.ServiceName) ModelNode(org.jboss.dmr.ModelNode) DatabaseTimerPersistence(org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence)

Aggregations

DatabaseTimerPersistence (org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence)1 ModelNode (org.jboss.dmr.ModelNode)1 ModuleLoader (org.jboss.modules.ModuleLoader)1 ServiceName (org.jboss.msc.service.ServiceName)1