Search in sources :

Example 41 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class MigrateOperation method migrateConnectorAttribute.

private void migrateConnectorAttribute(ModelNode addOperation) {
    ModelNode connector = addOperation.get(CONNECTOR);
    if (connector.isDefined()) {
        // legacy connector is a property list where the name is the connector and the value is undefined
        List<Property> connectorProps = connector.asPropertyList();
        for (Property connectorProp : connectorProps) {
            addOperation.get("connectors").add(connectorProp.getName());
        }
        addOperation.remove(CONNECTOR);
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 42 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class MigrateOperation method migrateBroadcastGroup.

private void migrateBroadcastGroup(ModelNode newAddOp, List<String> warnings) {
    // These attributes are not present in the messaging-activemq subsystem.
    // Instead a socket-binding must be used to configure the broadcast-group.
    final Collection<String> unmigratedProperties = asList(LOCAL_BIND_ADDRESS.getName(), LOCAL_BIND_PORT.getName(), GROUP_ADDRESS.getName(), GROUP_PORT.getName());
    for (Property property : newAddOp.asPropertyList()) {
        if (unmigratedProperties.contains(property.getName())) {
            warnings.add(ROOT_LOGGER.couldNotMigrateBroadcastGroupAttribute(property.getName(), pathAddress(newAddOp.get(OP_ADDR))));
        }
    }
    boolean clearOp = false;
    if (!newAddOp.hasDefined(CONNECTORS)) {
        warnings.add(ROOT_LOGGER.couldNotMigrateBroadcastGroupWithoutConnectors(pathAddress(newAddOp.get(OP_ADDR))));
        clearOp = true;
    }
    // These attributes no longer accept expressions in the messaging-activemq subsystem.
    removePropertiesWithExpression(newAddOp, warnings, JGROUPS_CHANNEL.getName(), JGROUPS_STACK.getName());
    if (!newAddOp.hasDefined(SOCKET_BINDING.getName())) {
        if (!newAddOp.hasDefined(JGROUPS_CHANNEL.getName())) {
            warnings.add(ROOT_LOGGER.couldNotMigrateBroadcastGroup(pathAddress(newAddOp.get(OP_ADDR))));
            clearOp = true;
        } else {
            newAddOp.get("jgroups-cluster").set(newAddOp.get(JGROUPS_CHANNEL.getName()));
        }
    }
    if (clearOp) {
        newAddOp.clear();
    }
}
Also used : Property(org.jboss.dmr.Property)

Example 43 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class MigrateOperation method connectionFactoryIsUsingInVMConnectors.

private boolean connectionFactoryIsUsingInVMConnectors(OperationContext context, ModelNode connectionFactoryAddOp) {
    ModelNode connector = connectionFactoryAddOp.get(CONNECTOR);
    if (connector.isDefined()) {
        PathAddress connectionFactoryAddress = pathAddress(connectionFactoryAddOp.get(OP_ADDR));
        PathElement relativeLegacyServerAddress = connectionFactoryAddress.getParent().getLastElement();
        // read the server resource related to the context current address (which is the messaging subsystem address).
        Resource serverResource = context.readResource(pathAddress(relativeLegacyServerAddress), false);
        Set<String> definedInVMConnectors = serverResource.getChildrenNames("in-vm-connector");
        // legacy connector is a property list where the name is the connector and the value is undefined
        List<Property> connectorProps = connector.asPropertyList();
        for (Property connectorProp : connectorProps) {
            String connectorName = connectorProp.getName();
            if (definedInVMConnectors.contains(connectorName)) {
                return true;
            }
        }
    }
    return false;
}
Also used : PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 44 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class JacORBSubsystemAdd method getConfigurationProperties.

@Override
protected Properties getConfigurationProperties(OperationContext context, ModelNode model) throws OperationFailedException {
    Properties props = new Properties();
    // get the configuration properties from the attribute definitions.
    for (AttributeDefinition attrDefinition : JacORBSubsystemDefinitions.SUBSYSTEM_ATTRIBUTES) {
        if (JacORBSubsystemDefinitions.ON_OFF_ATTRIBUTES_TO_REJECT.contains(attrDefinition) || JacORBSubsystemDefinitions.ATTRIBUTES_TO_REJECT.contains(attrDefinition)) {
            continue;
        }
        ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
        if (resolvedModelAttribute.isDefined()) {
            String name = attrDefinition.getName();
            String value = resolvedModelAttribute.asString();
            String openjdkProperty = PropertiesMap.PROPS_MAP.get(name);
            if (openjdkProperty != null) {
                name = openjdkProperty;
            }
            props.setProperty(name, value);
        }
    }
    // check if the node contains a list of generic properties.
    if (model.hasDefined(JacORBSubsystemConstants.PROPERTIES)) {
        ModelNode propertiesNode = model.get(JacORBSubsystemConstants.PROPERTIES);
        for (Property property : propertiesNode.asPropertyList()) {
            String name = property.getName();
            ModelNode value = property.getValue();
            props.setProperty(name, value.asString());
        }
    }
    return props;
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) Properties(java.util.Properties) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 45 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class MessagingXMLWriter method writeConnectorServices.

private static void writeConnectorServices(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
        writer.writeStartElement(Element.CONNECTOR_SERVICES.getLocalName());
        for (final Property property : node.asPropertyList()) {
            writer.writeStartElement(Element.CONNECTOR_SERVICE.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
            final ModelNode service = property.getValue();
            for (AttributeDefinition attribute : ConnectorServiceDefinition.ATTRIBUTES) {
                attribute.marshallAsElement(property.getValue(), writer);
            }
            // TODO use a custom attribute marshaller
            if (service.hasDefined(CommonAttributes.PARAM)) {
                for (Property param : service.get(CommonAttributes.PARAM).asPropertyList()) {
                    writer.writeEmptyElement(Element.PARAM.getLocalName());
                    writer.writeAttribute(Attribute.KEY.getLocalName(), param.getName());
                    writer.writeAttribute(Attribute.VALUE.getLocalName(), param.getValue().get(ConnectorServiceParamDefinition.VALUE.getName()).asString());
                }
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
        writeNewLine(writer);
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Aggregations

Property (org.jboss.dmr.Property)203 ModelNode (org.jboss.dmr.ModelNode)163 HashMap (java.util.HashMap)22 Test (org.junit.Test)19 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)16 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)16 PathAddress (org.jboss.as.controller.PathAddress)12 ArrayList (java.util.ArrayList)11 Map (java.util.Map)11 ValueExpression (org.jboss.dmr.ValueExpression)10 ModelType (org.jboss.dmr.ModelType)9 OperationFailedException (org.jboss.as.controller.OperationFailedException)8 HashSet (java.util.HashSet)7 ArrayDeque (java.util.ArrayDeque)6 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)6 Properties (java.util.Properties)5 LinkedHashMap (java.util.LinkedHashMap)4 LoginModuleControlFlag (javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 HttpResponse (org.apache.http.HttpResponse)3