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

org.restcomm.ss7.extension.SS7MbeanAdd Maven / Gradle / Ivy

The newest version!
package org.restcomm.ss7.extension;

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;

import java.util.List;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.restcomm.ss7.extension.SS7MbeanDefinition.MBEAN_ATTRIBUTES;

class SS7MbeanAdd extends AbstractAddStepHandler {

    static final SS7MbeanAdd INSTANCE = new SS7MbeanAdd();

    private SS7MbeanAdd() {
    }

    @Override
    protected void populateModel(final ModelNode operation, final ModelNode model) throws OperationFailedException {
        PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        String name = SS7MbeanDefinition.NAME_ATTR.getName();
        model.get(name).set(address.getLastElement().getValue());

        //SS7MbeanDefinition.NAME_ATTR.validateAndSet(operation, model);
        for (SimpleAttributeDefinition def : MBEAN_ATTRIBUTES) {
            def.validateAndSet(operation, model);
        }
    }

    @Override
    protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model,
                                  ServiceVerificationHandler verificationHandler, List> newControllers)
            throws OperationFailedException {

        final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
        final String mbeanName = address.getLastElement().getValue();

        // here we can add mbeans with reflection usage
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy