use of org.jboss.as.clustering.controller.ResourceServiceHandler in project wildfly by wildfly.
the class StackResourceDefinition method register.
@SuppressWarnings("deprecation")
@Override
public void register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addExtraParameters(TRANSPORT, PROTOCOLS).addCapabilities(Capability.class).addOperationTranslator(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (operation.hasDefined(TRANSPORT.getName())) {
PathAddress address = context.getCurrentAddress();
ModelNode transport = operation.get(TRANSPORT.getName());
String type = AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.resolveModelAttribute(context, transport).asString();
PathElement transportPath = TransportResourceDefinition.pathElement(type);
PathAddress transportAddress = address.append(transportPath);
ModelNode transportOperation = Util.createAddOperation(transportAddress);
OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(TransportResourceDefinition.WILDCARD_PATH), ModelDescriptionConstants.ADD);
for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) {
String name = attribute.getName();
if (transport.hasDefined(name)) {
transportOperation.get(name).set(transport.get(name));
}
}
context.addStep(transportOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL);
}
}
}).addOperationTranslator(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
if (operation.hasDefined(PROTOCOLS.getName())) {
PathAddress address = context.getCurrentAddress();
for (ModelNode protocol : operation.get(PROTOCOLS.getName()).asList()) {
String type = AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.resolveModelAttribute(context, protocol).asString();
PathElement protocolPath = ProtocolResourceDefinition.pathElement(type);
PathAddress protocolAddress = address.append(protocolPath);
ModelNode protocolOperation = Util.createAddOperation(protocolAddress);
OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(ProtocolResourceDefinition.WILDCARD_PATH), ModelDescriptionConstants.ADD);
for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) {
String name = attribute.getName();
if (protocol.hasDefined(name)) {
protocolOperation.get(name).set(protocol.get(name));
}
}
context.addStep(protocolOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL);
}
}
}
});
ResourceServiceHandler handler = new StackServiceHandler(this.builderFactory);
new SimpleResourceRegistration(descriptor, handler).register(registration);
OperationDefinition legacyAddProtocolOperation = new SimpleOperationDefinitionBuilder("add-protocol", this.getResourceDescriptionResolver()).setParameters(SocketBindingProtocolResourceDefinition.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) {
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(ProtocolResourceDefinition.WILDCARD_PATH), 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);
}
};
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) {
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(ProtocolResourceDefinition.WILDCARD_PATH), ModelDescriptionConstants.REMOVE), context.getCurrentStage());
}
};
registration.registerOperationHandler(legacyRemoveProtocolOperation, legacyRemoveProtocolHandler);
if (this.allowRuntimeOnlyRegistration) {
new OperationHandler<>(new StackOperationExecutor(), StackOperation.class).register(registration);
}
new TransportRegistration(this.builderFactory).register(registration);
new ProtocolRegistration(this.builderFactory).register(registration);
new RelayResourceDefinition(this.builderFactory).register(registration);
}
use of org.jboss.as.clustering.controller.ResourceServiceHandler in project wildfly by wildfly.
the class ForkResourceDefinition method register.
@Override
public void register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addCapabilities(Capability.class).addCapabilities(CLUSTERING_CAPABILITIES.values());
ResourceServiceBuilderFactory<ChannelFactory> builderFactory = address -> new ForkChannelFactoryBuilder(Capability.FORK_CHANNEL_FACTORY.getServiceName(address), address.getParent().getLastElement().getValue());
ResourceServiceHandler handler = new ForkServiceHandler(builderFactory);
new SimpleResourceRegistration(descriptor, handler).register(registration);
new ProtocolRegistration(builderFactory, new ForkProtocolResourceRegistrationHandler()).register(registration);
}
use of org.jboss.as.clustering.controller.ResourceServiceHandler 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);
}
}
use of org.jboss.as.clustering.controller.ResourceServiceHandler in project wildfly by wildfly.
the class ExpirationResourceDefinition 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 ExpirationBuilder(address.getParent()));
new SimpleResourceRegistration(descriptor, handler).register(registration);
}
use of org.jboss.as.clustering.controller.ResourceServiceHandler in project wildfly by wildfly.
the class InfinispanSubsystemResourceDefinition method register.
@Override
public void register(SubsystemRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubsystemModel(this);
registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addCapabilities(LOCAL_CLUSTERING_CAPABILITIES.values()).addCapabilities(CLUSTERING_CAPABILITIES.values());
ResourceServiceHandler handler = new InfinispanSubsystemServiceHandler();
new DeploymentChainContributingResourceRegistration(descriptor, handler, target -> target.addDeploymentProcessor(InfinispanExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_CLUSTERING, new ClusteringDependencyProcessor())).register(registration);
new CacheContainerResourceDefinition(this.pathManager, this.allowRuntimeOnlyRegistration).register(registration);
}
Aggregations