Search in sources :

Example 1 with ManagementResourceRegistration

use of org.jboss.as.clustering.controller.ManagementResourceRegistration in project wildfly by wildfly.

the class StackResourceDefinition method register.

@SuppressWarnings("deprecation")
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addExtraParameters(TRANSPORT, PROTOCOLS).addCapabilities(Capability.class).setAddOperationTransformation(new AddOperationTransformation());
    ResourceServiceHandler handler = new StackServiceHandler(this.serviceConfiguratorFactory);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    OperationDefinition legacyAddProtocolOperation = new SimpleOperationDefinitionBuilder("add-protocol", this.getResourceDescriptionResolver()).setParameters(MulticastProtocolResourceDefinition.Attribute.SOCKET_BINDING.getDefinition()).addParameter(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getDefinition()).addParameter(AbstractProtocolResourceDefinition.Attribute.PROPERTIES.getDefinition()).setDeprecated(JGroupsModel.VERSION_3_0_0.getVersion()).build();
    // Transform legacy /subsystem=jgroups/stack=*:add-protocol() operation -> /subsystem=jgroups/stack=*/protocol=*:add()
    OperationStepHandler legacyAddProtocolHandler = new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) {
            operationDeprecated(context, operation);
            PathAddress address = context.getCurrentAddress();
            String protocol = operation.require(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).asString();
            PathElement protocolPath = ProtocolResourceDefinition.pathElement(protocol);
            PathAddress protocolAddress = address.append(protocolPath);
            ModelNode protocolOperation = Util.createAddOperation(protocolAddress);
            OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(protocolPath), ModelDescriptionConstants.ADD);
            for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) {
                String name = attribute.getName();
                if (operation.hasDefined(name)) {
                    protocolOperation.get(name).set(operation.get(name));
                }
            }
            context.addStep(protocolOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true);
        }
    };
    registration.registerOperationHandler(legacyAddProtocolOperation, legacyAddProtocolHandler);
    OperationDefinition legacyRemoveProtocolOperation = new SimpleOperationDefinitionBuilder("remove-protocol", this.getResourceDescriptionResolver()).setParameters(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getDefinition()).setDeprecated(JGroupsModel.VERSION_3_0_0.getVersion()).build();
    // Transform legacy /subsystem=jgroups/stack=*:remove-protocol() operation -> /subsystem=jgroups/stack=*/protocol=*:remove()
    OperationStepHandler legacyRemoveProtocolHandler = new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) {
            operationDeprecated(context, operation);
            PathAddress address = context.getCurrentAddress();
            String protocol = operation.require(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).asString();
            PathElement protocolPath = ProtocolResourceDefinition.pathElement(protocol);
            PathAddress protocolAddress = address.append(protocolPath);
            ModelNode removeOperation = Util.createRemoveOperation(protocolAddress);
            context.addStep(removeOperation, context.getResourceRegistration().getOperationHandler(PathAddress.pathAddress(protocolPath), ModelDescriptionConstants.REMOVE), context.getCurrentStage());
        }
    };
    registration.registerOperationHandler(legacyRemoveProtocolOperation, legacyRemoveProtocolHandler);
    if (registration.isRuntimeOnlyRegistrationValid()) {
        new StackOperationHandler().register(registration);
    }
    new TransportRegistration(this.serviceConfiguratorFactory).register(registration);
    new ProtocolRegistration(this.serviceConfiguratorFactory).register(registration);
    new RelayResourceDefinition(this.serviceConfiguratorFactory).register(registration);
    return registration;
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) SimpleOperationDefinitionBuilder(org.jboss.as.controller.SimpleOperationDefinitionBuilder) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationEntry(org.jboss.as.controller.registry.OperationEntry) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ObjectListAttributeDefinition(org.jboss.as.controller.ObjectListAttributeDefinition) ObjectTypeAttributeDefinition(org.jboss.as.controller.ObjectTypeAttributeDefinition) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) OperationDefinition(org.jboss.as.controller.OperationDefinition) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 2 with ManagementResourceRegistration

use of org.jboss.as.clustering.controller.ManagementResourceRegistration in project wildfly by wildfly.

the class RemoteClusterResourceDefinition method register.

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addCapabilities(Capability.class);
    new RestartParentResourceRegistration(this.serviceConfiguratorFactory, descriptor).register(registration);
    if (registration.isRuntimeOnlyRegistrationValid()) {
        new OperationHandler<>(new RemoteClusterOperationExecutor(this.executors), RemoteClusterOperation.class).register(registration);
    }
    return registration;
}
Also used : ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) RestartParentResourceRegistration(org.jboss.as.clustering.controller.RestartParentResourceRegistration) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 3 with ManagementResourceRegistration

use of org.jboss.as.clustering.controller.ManagementResourceRegistration in project wildfly by wildfly.

the class RemoteTransactionResourceDefinition method register.

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(new RemoteTransactionResourceDefinition());
    Capability dependentCapability = new UnaryRequirementCapability(InfinispanClientRequirement.REMOTE_CONTAINER_CONFIGURATION, UnaryCapabilityNameResolver.PARENT);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(EnumSet.complementOf(EnumSet.of(Attribute.TIMEOUT))).addAttributeTranslation(Attribute.TIMEOUT, new AttributeTranslation() {

        @Override
        public org.jboss.as.clustering.controller.Attribute getTargetAttribute() {
            return RemoteCacheContainerResourceDefinition.Attribute.TRANSACTION_TIMEOUT;
        }

        @Override
        public UnaryOperator<PathAddress> getPathAddressTransformation() {
            return PathAddress::getParent;
        }
    }).addResourceCapabilityReference(new TransactionResourceCapabilityReference(dependentCapability, CommonRequirement.LOCAL_TRANSACTION_PROVIDER, Attribute.MODE, EnumSet.of(TransactionMode.NONE, TransactionMode.BATCH)));
    ResourceServiceHandler handler = new SimpleResourceServiceHandler(this);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    return registration;
}
Also used : Capability(org.jboss.as.clustering.controller.Capability) UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) UnaryRequirementCapability(org.jboss.as.clustering.controller.UnaryRequirementCapability) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) AttributeTranslation(org.jboss.as.clustering.controller.AttributeTranslation) PathAddress(org.jboss.as.controller.PathAddress) TransactionResourceCapabilityReference(org.jboss.as.clustering.infinispan.subsystem.TransactionResourceCapabilityReference) SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 4 with ManagementResourceRegistration

use of org.jboss.as.clustering.controller.ManagementResourceRegistration in project wildfly by wildfly.

the class InvalidationNearCacheResourceDefinition method register.

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addIgnoredAttributes(InvalidationNearCacheResourceDefinition.Attribute.class);
    new SimpleResourceRegistration(descriptor, null).register(registration);
    return registration;
}
Also used : SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 5 with ManagementResourceRegistration

use of org.jboss.as.clustering.controller.ManagementResourceRegistration in project wildfly by wildfly.

the class ConnectionPoolResourceDefinition method register.

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class);
    ResourceServiceHandler handler = new SimpleResourceServiceHandler(this);
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    return registration;
}
Also used : SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ManagementResourceRegistration(org.jboss.as.clustering.controller.ManagementResourceRegistration) SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Aggregations

ManagementResourceRegistration (org.jboss.as.clustering.controller.ManagementResourceRegistration)41 ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)31 SimpleResourceRegistration (org.jboss.as.clustering.controller.SimpleResourceRegistration)25 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)23 SimpleResourceServiceHandler (org.jboss.as.clustering.controller.SimpleResourceServiceHandler)13 SimpleAliasEntry (org.jboss.as.clustering.controller.SimpleAliasEntry)10 ServiceValueExecutorRegistry (org.jboss.as.clustering.controller.ServiceValueExecutorRegistry)5 OperationContext (org.jboss.as.controller.OperationContext)5 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)5 PathAddress (org.jboss.as.controller.PathAddress)5 ModelNode (org.jboss.dmr.ModelNode)5 UnaryRequirementCapability (org.jboss.as.clustering.controller.UnaryRequirementCapability)4 PathElement (org.jboss.as.controller.PathElement)4 EnumSet (java.util.EnumSet)3 Capability (org.jboss.as.clustering.controller.Capability)3 DeploymentChainContributingResourceRegistration (org.jboss.as.clustering.controller.DeploymentChainContributingResourceRegistration)3 ListAttributeTranslation (org.jboss.as.clustering.controller.ListAttributeTranslation)3 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)3 OperationFailedException (org.jboss.as.controller.OperationFailedException)3 EnumMap (java.util.EnumMap)2