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

org.mobicents.ss7.extension.SS7MbeanPropertyDefinition Maven / Gradle / Ivy

There is a newer version: 8.0.112
Show newest version
package org.mobicents.ss7.extension;

import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelType;

import java.util.HashMap;
import java.util.Map;

public class SS7MbeanPropertyDefinition extends SimpleResourceDefinition {

    public enum Element {
        UNKNOWN(null),
        NAME("name"),
        TYPE("type"),
        VALUE("value");

        private final String name;

        Element(final String name) {
            this.name = name;
        }

        public String localName() {
            return name;
        }

        private static final Map MAP;

        static {
            final Map map = new HashMap();
            for (Element element : values()) {
                final String name = element.localName();
                if (name != null) map.put(name, element);
            }
            MAP = map;
        }

        public static Element of(final String localName) {
            final Element element = MAP.get(localName);
            return element == null ? UNKNOWN : element;
        }

    }

    public static final SimpleAttributeDefinition NAME_ATTR = new SimpleAttributeDefinition(
            Element.NAME.localName(), ModelType.STRING, true);
    public static final SimpleAttributeDefinition TYPE_ATTR = new SimpleAttributeDefinition(
            Element.TYPE.localName(), ModelType.STRING, true);
    public static final SimpleAttributeDefinition VALUE_ATTR = new SimpleAttributeDefinition(
            Element.VALUE.localName(), ModelType.STRING, true);

    public static final String PROPERTY = "property";
    public static final PathElement PROPERTY_PATH = PathElement.pathElement(PROPERTY);
    public static final SS7MbeanPropertyDefinition INSTANCE = new SS7MbeanPropertyDefinition();

    protected static final SimpleAttributeDefinition[] PROPERTY_ATTRIBUTES = {
            //NAME_ATTR, // name is read-only
            TYPE_ATTR,
            VALUE_ATTR
    };

    private SS7MbeanPropertyDefinition() {
        super(PROPERTY_PATH,
                SS7Extension.getResourceDescriptionResolver(SS7MbeanDefinition.MBEAN + "." + PROPERTY),
                SS7MbeanPropertyAdd.INSTANCE,
                SS7MbeanPropertyRemove.INSTANCE);
    }

    @Override
    public void registerChildren(ManagementResourceRegistration resourceRegistration) {
        super.registerChildren(resourceRegistration);
        resourceRegistration.registerSubModel(SS7MbeanPropertyEntryDefinition.INSTANCE);
    }

    @Override
    public void registerAttributes(final ManagementResourceRegistration properties) {
        //super.registerAttributes(resourceRegistration);
        properties.registerReadOnlyAttribute(NAME_ATTR, null);
        for (SimpleAttributeDefinition def : PROPERTY_ATTRIBUTES) {
            properties.registerReadWriteAttribute(def, null, new ReloadRequiredWriteAttributeHandler(def));
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy