All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.as.clustering.jgroups.subsystem.SocketProtocolResourceDefinition Maven / Gradle / Ivy

The newest version!
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.jboss.as.clustering.jgroups.subsystem;

import java.util.function.UnaryOperator;

import org.jboss.as.clustering.controller.ResourceDescriptor;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.network.SocketBinding;
import org.jboss.dmr.ModelType;
import org.jgroups.stack.Protocol;
import org.wildfly.subsystem.resource.capability.CapabilityReferenceRecorder;
import org.wildfly.subsystem.service.ResourceServiceConfigurator;

/**
 * Resource definition override for protocols that have an optional socket-binding.
 * @author Paul Ferraro
 */
public class SocketProtocolResourceDefinition

extends ProtocolResourceDefinition

{ enum Attribute implements org.jboss.as.clustering.controller.Attribute, UnaryOperator { SOCKET_BINDING(ModelDescriptionConstants.SOCKET_BINDING, ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF) .setCapabilityReference(CapabilityReferenceRecorder.builder(CAPABILITY, SocketBinding.SERVICE_DESCRIPTOR).build()) ; } }, CLIENT_SOCKET_BINDING("client-socket-binding", ModelType.STRING) { @Override public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) { return builder.setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF) .setCapabilityReference(CapabilityReferenceRecorder.builder(CAPABILITY, SocketBinding.SERVICE_DESCRIPTOR).build()) ; } }, ; private final AttributeDefinition definition; Attribute(String name, ModelType type) { this.definition = this.apply(new SimpleAttributeDefinitionBuilder(name, type) .setRequired(false) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) ).build(); } @Override public AttributeDefinition getDefinition() { return this.definition; } } private static class ResourceDescriptorConfigurator implements UnaryOperator { private final UnaryOperator configurator; ResourceDescriptorConfigurator(UnaryOperator configurator) { this.configurator = configurator; } @Override public ResourceDescriptor apply(ResourceDescriptor descriptor) { return this.configurator.apply(descriptor).addAttributes(Attribute.class); } } SocketProtocolResourceDefinition(String name, UnaryOperator configurator, ResourceServiceConfigurator parentServiceConfigurator) { super(pathElement(name), new ResourceDescriptorConfigurator(configurator), parentServiceConfigurator); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy