Search in sources :

Example 86 with Property

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

the class ServerAdd method processSecuritySettings.

/**
     * Process the security settings.
     *
     * @param configuration the ActiveMQ configuration
     * @param params        the detyped operation parameters
     */
static void processSecuritySettings(final OperationContext context, final Configuration configuration, final ModelNode params) throws OperationFailedException {
    if (params.get(SECURITY_SETTING).isDefined()) {
        for (final Property property : params.get(SECURITY_SETTING).asPropertyList()) {
            final String match = property.getName();
            final ModelNode config = property.getValue();
            if (config.hasDefined(CommonAttributes.ROLE)) {
                final Set<Role> roles = new HashSet<Role>();
                for (final Property role : config.get(CommonAttributes.ROLE).asPropertyList()) {
                    roles.add(SecurityRoleDefinition.transform(context, role.getName(), role.getValue()));
                }
                configuration.getSecurityRoles().put(match, roles);
            }
        }
    }
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) HashSet(java.util.HashSet)

Example 87 with Property

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

the class TransportConfigOperationHandlers method processConnectors.

/**
     * Process the connector information.
     *
     * @param context       the operation context
     * @param configuration the ActiveMQ configuration
     * @param params        the detyped operation parameters
     * @param bindings      the referenced socket bindings
     * @throws OperationFailedException
     */
static void processConnectors(final OperationContext context, final Configuration configuration, final ModelNode params, final Set<String> bindings) throws OperationFailedException {
    final Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
    if (params.hasDefined(CONNECTOR)) {
        for (final Property property : params.get(CONNECTOR).asPropertyList()) {
            final String connectorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
            ModelNode socketBinding = GenericTransportDefinition.SOCKET_BINDING.resolveModelAttribute(context, config);
            if (socketBinding.isDefined()) {
                bindings.add(socketBinding.asString());
                // uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
                parameters.put(GenericTransportDefinition.SOCKET_BINDING.getName(), socketBinding.asString());
            }
            final String clazz = FACTORY_CLASS.resolveModelAttribute(context, config).asString();
            connectors.put(connectorName, new TransportConfiguration(clazz, parameters, connectorName));
        }
    }
    if (params.hasDefined(REMOTE_CONNECTOR)) {
        for (final Property property : params.get(REMOTE_CONNECTOR).asPropertyList()) {
            final String connectorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
            final String binding = config.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).asString();
            bindings.add(binding);
            // uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
            parameters.put(RemoteTransportDefinition.SOCKET_BINDING.getName(), binding);
            connectors.put(connectorName, new TransportConfiguration(NettyConnectorFactory.class.getName(), parameters, connectorName));
        }
    }
    if (params.hasDefined(IN_VM_CONNECTOR)) {
        for (final Property property : params.get(IN_VM_CONNECTOR).asPropertyList()) {
            final String connectorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
            parameters.put(CONNECTORS_KEYS_MAP.get(InVMTransportDefinition.SERVER_ID.getName()), InVMTransportDefinition.SERVER_ID.resolveModelAttribute(context, config).asInt());
            connectors.put(connectorName, new TransportConfiguration(InVMConnectorFactory.class.getName(), parameters, connectorName));
        }
    }
    if (params.hasDefined(HTTP_CONNECTOR)) {
        for (final Property property : params.get(HTTP_CONNECTOR).asPropertyList()) {
            final String connectorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, CONNECTORS_KEYS_MAP);
            final String binding = HTTPConnectorDefinition.SOCKET_BINDING.resolveModelAttribute(context, config).asString();
            bindings.add(binding);
            // ARTEMIS-803 Artemis knows that is must not offset the HTTP port when it is used by colocated backups
            parameters.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
            parameters.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, HTTPConnectorDefinition.ENDPOINT.resolveModelAttribute(context, config).asString());
            // uses the parameters to pass the socket binding name that will be read in ActiveMQServerService.start()
            parameters.put(HTTPConnectorDefinition.SOCKET_BINDING.getName(), binding);
            ModelNode serverNameModelNode = HTTPConnectorDefinition.SERVER_NAME.resolveModelAttribute(context, config);
            // use the name of this server if the server-name attribute is undefined
            String serverName = serverNameModelNode.isDefined() ? serverNameModelNode.asString() : configuration.getName();
            parameters.put(ACTIVEMQ_SERVER_NAME, serverName);
            connectors.put(connectorName, new TransportConfiguration(NettyConnectorFactory.class.getName(), parameters, connectorName));
        }
    }
    configuration.setConnectorConfigurations(connectors);
}
Also used : HashMap(java.util.HashMap) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 88 with Property

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

the class GroupingHandlerAdd method addGroupingHandlerConfig.

static void addGroupingHandlerConfig(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
    if (model.hasDefined(CommonAttributes.GROUPING_HANDLER)) {
        final Property prop = model.get(CommonAttributes.GROUPING_HANDLER).asProperty();
        final String name = prop.getName();
        final ModelNode node = prop.getValue();
        final GroupingHandlerConfiguration.TYPE type = GroupingHandlerConfiguration.TYPE.valueOf(GroupingHandlerDefinition.TYPE.resolveModelAttribute(context, node).asString());
        final String address = GROUPING_HANDLER_ADDRESS.resolveModelAttribute(context, node).asString();
        final int timeout = TIMEOUT.resolveModelAttribute(context, node).asInt();
        final long groupTimeout = GROUP_TIMEOUT.resolveModelAttribute(context, node).asLong();
        final long reaperPeriod = REAPER_PERIOD.resolveModelAttribute(context, node).asLong();
        final GroupingHandlerConfiguration conf = new GroupingHandlerConfiguration().setName(SimpleString.toSimpleString(name)).setType(type).setAddress(SimpleString.toSimpleString(address)).setTimeout(timeout).setGroupTimeout(groupTimeout).setReaperPeriod(reaperPeriod);
        configuration.setGroupingHandlerConfiguration(conf);
    }
}
Also used : GroupingHandlerConfiguration(org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 89 with Property

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

the class BroadcastGroupAdd method addBroadcastGroupConfigs.

static void addBroadcastGroupConfigs(final OperationContext context, final Configuration configuration, final ModelNode model) throws OperationFailedException {
    if (model.hasDefined(CommonAttributes.BROADCAST_GROUP)) {
        final List<BroadcastGroupConfiguration> configs = configuration.getBroadcastGroupConfigurations();
        final Set<String> connectors = configuration.getConnectorConfigurations().keySet();
        for (Property prop : model.get(CommonAttributes.BROADCAST_GROUP).asPropertyList()) {
            configs.add(createBroadcastGroupConfiguration(context, connectors, prop.getName(), prop.getValue()));
        }
    }
}
Also used : BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) Property(org.jboss.dmr.Property)

Example 90 with Property

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

the class IdentityProviderAddHandler method restartTrustDomains.

private static void restartTrustDomains(String identityProviderName, ModelNode modelNode, OperationContext context) {
    if (modelNode.hasDefined(ModelElement.IDENTITY_PROVIDER_TRUST_DOMAIN.getName())) {
        for (Property handlerProperty : modelNode.get(ModelElement.IDENTITY_PROVIDER_TRUST_DOMAIN.getName()).asPropertyList()) {
            String domainName = handlerProperty.getName();
            TrustDomainAddHandler.restartServices(context, identityProviderName, domainName);
        }
    }
}
Also used : Property(org.jboss.dmr.Property)

Aggregations

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