Search in sources :

Example 16 with TransportConfiguration

use of org.apache.activemq.artemis.api.core.TransportConfiguration in project wildfly by wildfly.

the class TransportConfigOperationHandlers method processAcceptors.

/**
     * Process the acceptor 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 processAcceptors(final OperationContext context, final Configuration configuration, final ModelNode params, final Set<String> bindings) throws OperationFailedException {
    final Map<String, TransportConfiguration> acceptors = new HashMap<String, TransportConfiguration>();
    if (params.hasDefined(ACCEPTOR)) {
        for (final Property property : params.get(ACCEPTOR).asPropertyList()) {
            final String acceptorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
            final String clazz = config.get(FACTORY_CLASS.getName()).asString();
            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());
            }
            acceptors.put(acceptorName, new TransportConfiguration(clazz, parameters, acceptorName));
        }
    }
    if (params.hasDefined(REMOTE_ACCEPTOR)) {
        for (final Property property : params.get(REMOTE_ACCEPTOR).asPropertyList()) {
            final String acceptorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_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);
            acceptors.put(acceptorName, new TransportConfiguration(NettyAcceptorFactory.class.getName(), parameters, acceptorName));
        }
    }
    if (params.hasDefined(IN_VM_ACCEPTOR)) {
        for (final Property property : params.get(IN_VM_ACCEPTOR).asPropertyList()) {
            final String acceptorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
            parameters.put(SERVER_ID_PROP_NAME, InVMTransportDefinition.SERVER_ID.resolveModelAttribute(context, config).asInt());
            acceptors.put(acceptorName, new TransportConfiguration(InVMAcceptorFactory.class.getName(), parameters, acceptorName));
        }
    }
    if (params.hasDefined(HTTP_ACCEPTOR)) {
        for (final Property property : params.get(HTTP_ACCEPTOR).asPropertyList()) {
            final String acceptorName = property.getName();
            final ModelNode config = property.getValue();
            final Map<String, Object> parameters = getParameters(context, config, ACCEPTOR_KEYS_MAP);
            parameters.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, true);
            acceptors.put(acceptorName, new TransportConfiguration(NettyAcceptorFactory.class.getName(), parameters, acceptorName));
        }
    }
    configuration.setAcceptorConfigurations(new HashSet<TransportConfiguration>(acceptors.values()));
}
Also used : HashMap(java.util.HashMap) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Aggregations

TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)16 HashMap (java.util.HashMap)9 NettyConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory)5 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)3 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)3 ModelNode (org.jboss.dmr.ModelNode)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)2 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)2 ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)2 Property (org.jboss.dmr.Property)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InetSocketAddress (java.net.InetSocketAddress)1 DataSource (javax.sql.DataSource)1 BroadcastEndpointFactory (org.apache.activemq.artemis.api.core.BroadcastEndpointFactory)1 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)1 ChannelBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory)1