Search in sources :

Example 91 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler method updateOptimisticLocking.

void updateOptimisticLocking(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final ModelNode enabled = EJB3SubsystemRootResourceDefinition.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING.resolveModelAttribute(context, model);
    final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
    ServiceController<?> existingService = serviceRegistry.getService(SERVICE_NAME);
    // if a default optimistic locking config is installed, remove it
    if (existingService != null) {
        context.removeService(existingService);
    }
    if (enabled.isDefined()) {
        final Service<Boolean> newDefaultPoolConfigService = new ValueService<Boolean>(new ImmediateValue<Boolean>(enabled.asBoolean()));
        ServiceController<?> newController = context.getServiceTarget().addService(SERVICE_NAME, newDefaultPoolConfigService).install();
    }
}
Also used : ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode) ValueService(org.jboss.msc.service.ValueService)

Example 92 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler method revertUpdateToRuntime.

@Override
protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException {
    final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone();
    restored.get(attributeName).set(valueToRestore);
    updateOptimisticLocking(context, restored);
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Example 93 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class EJB3SubsystemDefaultPoolWriteHandler method updatePoolService.

void updatePoolService(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final ModelNode poolName = poolAttribute.resolveModelAttribute(context, model);
    final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
    ServiceController<?> existingDefaultPoolConfigService = serviceRegistry.getService(poolConfigServiceName);
    // if a default MDB pool is already installed, then remove it first
    if (existingDefaultPoolConfigService != null) {
        context.removeService(existingDefaultPoolConfigService);
    }
    if (poolName.isDefined()) {
        // now install default pool config service which points to an existing pool config service
        final ValueInjectionService<PoolConfig> newDefaultPoolConfigService = new ValueInjectionService<PoolConfig>();
        ServiceController<?> newController = context.getServiceTarget().addService(poolConfigServiceName, newDefaultPoolConfigService).addDependency(StrictMaxPoolConfigService.EJB_POOL_CONFIG_BASE_SERVICE_NAME.append(poolName.asString()), PoolConfig.class, newDefaultPoolConfigService.getInjector()).install();
    }
}
Also used : ValueInjectionService(org.jboss.msc.service.ValueInjectionService) PoolConfig(org.jboss.as.ejb3.component.pool.PoolConfig) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 94 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class PassivationStoreResourceDefinition method registerTransformers_1_2_1_and_1_3_0.

/*
     * This transformer does the following:
     * - maps <passivation-store/> to <cluster-passivation-store/>
     * - sets appropriate defaults for IDLE_TIMEOUT, IDLE_TIMEOUT_UNIT, PASSIVATE_EVENTS_ON_REPLICATE, and CLIENT_MAPPINGS_CACHE
     */
@SuppressWarnings("deprecation")
static void registerTransformers_1_2_1_and_1_3_0(ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder child = parent.addChildRedirection(INSTANCE.getPathElement(), PathElement.pathElement(EJB3SubsystemModel.CLUSTER_PASSIVATION_STORE));
    child.getAttributeBuilder().setValueConverter(AttributeConverter.Factory.createHardCoded(new ModelNode(true), true), EJB3SubsystemModel.PASSIVATE_EVENTS_ON_REPLICATE).setValueConverter(AttributeConverter.Factory.createHardCoded(new ModelNode("default"), true), EJB3SubsystemModel.CLIENT_MAPPINGS_CACHE).setValueConverter(AttributeConverter.Factory.createHardCoded(new ModelNode().set(Long.valueOf(Integer.MAX_VALUE)), true), EJB3SubsystemModel.IDLE_TIMEOUT).setValueConverter(AttributeConverter.Factory.createHardCoded(new ModelNode().set(TimeUnit.SECONDS.name()), true), EJB3SubsystemModel.IDLE_TIMEOUT_UNIT);
}
Also used : ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelNode(org.jboss.dmr.ModelNode)

Example 95 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class PassivationStoreWriteHandler method applyUpdateToRuntime.

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException {
    ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
    this.applyModelToRuntime(context, operation, attributeName, model);
    return false;
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ModelNode (org.jboss.dmr.ModelNode)1634 PathAddress (org.jboss.as.controller.PathAddress)351 Test (org.junit.Test)344 KernelServices (org.jboss.as.subsystem.test.KernelServices)102 Property (org.jboss.dmr.Property)92 OperationFailedException (org.jboss.as.controller.OperationFailedException)89 OperationContext (org.jboss.as.controller.OperationContext)68 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)68 ArrayList (java.util.ArrayList)58 Resource (org.jboss.as.controller.registry.Resource)54 PathElement (org.jboss.as.controller.PathElement)53 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)52 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)50 IOException (java.io.IOException)49 ServiceName (org.jboss.msc.service.ServiceName)49 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)47 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)44 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)42 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)42 Map (java.util.Map)38