Search in sources :

Example 1 with ResourceDescriptor

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

the class RandomElectionPolicyResourceDefinition method register.

@Override
public void register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(ElectionPolicyResourceDefinition.Attribute.class).addCapabilities(ElectionPolicyResourceDefinition.Capability.class);
    ResourceServiceHandler handler = new SimpleResourceServiceHandler<>(address -> new RandomElectionPolicyBuilder(address.getParent()));
    new SimpleResourceRegistration(descriptor, handler).register(registration);
}
Also used : SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 2 with ResourceDescriptor

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

the class EvictionResourceDefinition method register.

@Override
public void register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    parentRegistration.registerAlias(LEGACY_PATH, new SimpleAliasEntry(registration));
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class);
    ResourceServiceHandler handler = new SimpleResourceServiceHandler<>(address -> new EvictionBuilder(address.getParent()));
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    if (this.allowRuntimeOnlyRegistration) {
        new MetricHandler<>(new EvictionMetricExecutor(), EvictionMetric.class).register(registration);
    }
}
Also used : SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) SimpleAliasEntry(org.jboss.as.clustering.controller.SimpleAliasEntry) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 3 with ResourceDescriptor

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

the class BinaryTableResourceDefinition method register.

@Override
public void register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(TableResourceDefinition.Attribute.class).addAttributes(TableResourceDefinition.ColumnAttribute.class);
    ResourceServiceHandler handler = new SimpleResourceServiceHandler<>(address -> new BinaryTableBuilder(address.getParent().getParent()));
    new SimpleResourceRegistration(descriptor, handler).register(registration);
}
Also used : SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) SimpleResourceServiceHandler(org.jboss.as.clustering.controller.SimpleResourceServiceHandler) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 4 with ResourceDescriptor

use of org.jboss.as.clustering.controller.ResourceDescriptor 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 5 with ResourceDescriptor

use of org.jboss.as.clustering.controller.ResourceDescriptor 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)

Aggregations

ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)61 SimpleResourceRegistration (org.jboss.as.clustering.controller.SimpleResourceRegistration)41 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)38 ManagementResourceRegistration (org.jboss.as.clustering.controller.ManagementResourceRegistration)31 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)27 SimpleResourceServiceHandler (org.jboss.as.clustering.controller.SimpleResourceServiceHandler)26 ReloadRequiredResourceRegistration (org.jboss.as.clustering.controller.ReloadRequiredResourceRegistration)10 SimpleAliasEntry (org.jboss.as.clustering.controller.SimpleAliasEntry)9 DeploymentChainContributingResourceRegistration (org.jboss.as.clustering.controller.DeploymentChainContributingResourceRegistration)5 ServiceValueExecutorRegistry (org.jboss.as.clustering.controller.ServiceValueExecutorRegistry)5 UnaryRequirementCapability (org.jboss.as.clustering.controller.UnaryRequirementCapability)5 OperationContext (org.jboss.as.controller.OperationContext)5 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)5 ModelNode (org.jboss.dmr.ModelNode)5 RestartParentResourceRegistration (org.jboss.as.clustering.controller.RestartParentResourceRegistration)4 OperationFailedException (org.jboss.as.controller.OperationFailedException)4 PathElement (org.jboss.as.controller.PathElement)4 EnumSet (java.util.EnumSet)3 Capability (org.jboss.as.clustering.controller.Capability)3 ListAttributeTranslation (org.jboss.as.clustering.controller.ListAttributeTranslation)3