activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [03/39] activemq-artemis git commit: AcceptorConfig: Refactor out BeanSupport
Date Wed, 17 Feb 2016 02:03:38 GMT
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
index 2af8a16..ee7d7e3 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnection.java
@@ -31,6 +31,7 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.core.security.ActiveMQPrincipal;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
+import org.apache.activemq.artemis.spi.core.remoting.BaseConnectionLifeCycleListener;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
@@ -43,7 +44,7 @@ public class InVMConnection implements Connection {
 
    private final BufferHandler handler;
 
-   private final ConnectionLifeCycleListener listener;
+   private final BaseConnectionLifeCycleListener listener;
 
    private final String id;
 
@@ -64,7 +65,7 @@ public class InVMConnection implements Connection {
 
    public InVMConnection(final int serverID,
                          final BufferHandler handler,
-                         final ConnectionLifeCycleListener listener,
+                         final BaseConnectionLifeCycleListener listener,
                          final Executor executor) {
       this(serverID, UUIDGenerator.getInstance().generateSimpleStringUUID().toString(), handler,
listener, executor);
    }
@@ -72,7 +73,7 @@ public class InVMConnection implements Connection {
    public InVMConnection(final int serverID,
                          final String id,
                          final BufferHandler handler,
-                         final ConnectionLifeCycleListener listener,
+                         final BaseConnectionLifeCycleListener listener,
                          final Executor executor) {
       this(serverID, id, handler, listener, executor, null);
    }
@@ -80,7 +81,7 @@ public class InVMConnection implements Connection {
    public InVMConnection(final int serverID,
                          final String id,
                          final BufferHandler handler,
-                         final ConnectionLifeCycleListener listener,
+                         final BaseConnectionLifeCycleListener listener,
                          final Executor executor,
                          final ActiveMQPrincipal defaultActiveMQPrincipal) {
       this.serverID = serverID;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
index 33a3147..c1fab77 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java
@@ -29,7 +29,9 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.spi.core.remoting.AbstractConnector;
 import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
+import org.apache.activemq.artemis.spi.core.remoting.BaseConnectionLifeCycleListener;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
+import org.apache.activemq.artemis.spi.core.remoting.ClientConnectionLifeCycleListener;
 import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManager;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
@@ -72,7 +74,7 @@ public class InVMConnector extends AbstractConnector {
 
    private final BufferHandler handler;
 
-   private final ConnectionLifeCycleListener listener;
+   private final BaseConnectionLifeCycleListener listener;
 
    private final InVMAcceptor acceptor;
 
@@ -86,7 +88,7 @@ public class InVMConnector extends AbstractConnector {
 
    public InVMConnector(final Map<String, Object> configuration,
                         final BufferHandler handler,
-                        final ConnectionLifeCycleListener listener,
+                        final ClientConnectionLifeCycleListener listener,
                         final Executor closeExecutor,
                         final Executor threadPool,
                         ClientProtocolManager protocolManager) {
@@ -181,11 +183,11 @@ public class InVMConnector extends AbstractConnector {
 
    // This may be an injection point for mocks on tests
    protected Connection internalCreateConnection(final BufferHandler handler,
-                                                 final ConnectionLifeCycleListener listener,
+                                                 final ClientConnectionLifeCycleListener
listener,
                                                  final Executor serverExecutor) {
       // No acceptor on a client connection
       InVMConnection inVMConnection = new InVMConnection(id, handler, listener, serverExecutor);
-      listener.connectionCreated(null, inVMConnection, protocolManager.getName());
+      listener.connectionCreated(null, inVMConnection, protocolManager);
       return inVMConnection;
    }
 
@@ -195,17 +197,23 @@ public class InVMConnector extends AbstractConnector {
       return id == serverId;
    }
 
-   private class Listener implements ConnectionLifeCycleListener {
+   private class Listener implements ClientConnectionLifeCycleListener {
 
       @Override
       public void connectionCreated(final ActiveMQComponent component,
                                     final Connection connection,
-                                    final String protocol) {
+                                    final ClientProtocolManager protocol) {
          if (connections.putIfAbsent((String) connection.getID(), connection) != null) {
             throw ActiveMQMessageBundle.BUNDLE.connectionExists(connection.getID());
          }
 
-         listener.connectionCreated(component, connection, protocol);
+         if (listener instanceof ConnectionLifeCycleListener) {
+            listener.connectionCreated(component, connection, protocol.getName());
+         }
+         else {
+            listener.connectionCreated(component, connection, protocol);
+         }
+
       }
 
       @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnectorFactory.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnectorFactory.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnectorFactory.java
index 77ca86b..112e3f4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnectorFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnectorFactory.java
@@ -21,8 +21,8 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.ScheduledExecutorService;
 
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
+import org.apache.activemq.artemis.spi.core.remoting.ClientConnectionLifeCycleListener;
 import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManager;
-import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
 import org.apache.activemq.artemis.spi.core.remoting.Connector;
 import org.apache.activemq.artemis.spi.core.remoting.ConnectorFactory;
 
@@ -31,7 +31,7 @@ public class InVMConnectorFactory implements ConnectorFactory {
    @Override
    public Connector createConnector(final Map<String, Object> configuration,
                                     final BufferHandler handler,
-                                    final ConnectionLifeCycleListener listener,
+                                    final ClientConnectionLifeCycleListener listener,
                                     final Executor closeExecutor,
                                     final Executor threadPool,
                                     final ScheduledExecutorService scheduledThreadPool,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index 38f3544..40e8fad 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -75,6 +75,7 @@ import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
+import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener;
 import org.apache.activemq.artemis.utils.ConfigurationHelper;
 import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
 import org.apache.activemq.artemis.utils.TypedProperties;
@@ -107,7 +108,7 @@ public class NettyAcceptor implements Acceptor {
 
    private final BufferHandler handler;
 
-   private final ConnectionLifeCycleListener listener;
+   private final ServerConnectionLifeCycleListener listener;
 
    private final boolean sslEnabled;
 
@@ -175,7 +176,7 @@ public class NettyAcceptor implements Acceptor {
                         final ClusterConnection clusterConnection,
                         final Map<String, Object> configuration,
                         final BufferHandler handler,
-                        final ConnectionLifeCycleListener listener,
+                        final ServerConnectionLifeCycleListener listener,
                         final ScheduledExecutorService scheduledThreadPool,
                         final Map<String, ProtocolManager> protocolMap) {
       this.name = name;
@@ -606,7 +607,7 @@ public class NettyAcceptor implements Acceptor {
 
       ActiveMQServerChannelHandler(final ChannelGroup group,
                                    final BufferHandler handler,
-                                   final ConnectionLifeCycleListener listener) {
+                                   final ServerConnectionLifeCycleListener listener) {
          super(group, handler, listener);
       }
 
@@ -620,7 +621,7 @@ public class NettyAcceptor implements Acceptor {
 
             NettyServerConnection nc = new NettyServerConnection(configuration, ctx.channel(),
connectionListener, !httpEnabled && batchDelay > 0, directDeliver);
 
-            connectionListener.connectionCreated(NettyAcceptor.this, nc, protocol);
+            connectionListener.connectionCreated(NettyAcceptor.this, nc, protocolHandler.getProtocol(protocol));
 
             SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
             if (sslHandler != null) {
@@ -650,12 +651,12 @@ public class NettyAcceptor implements Acceptor {
       }
    }
 
-   private class Listener implements ConnectionLifeCycleListener {
+   private class Listener implements ServerConnectionLifeCycleListener {
 
       @Override
       public void connectionCreated(final ActiveMQComponent component,
                                     final Connection connection,
-                                    final String protocol) {
+                                    final ProtocolManager protocol) {
          if (connections.putIfAbsent(connection.getID(), (NettyServerConnection) connection)
!= null) {
             throw ActiveMQMessageBundle.BUNDLE.connectionExists(connection.getID());
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptorFactory.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptorFactory.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptorFactory.java
index 880522f..9a9bfea 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptorFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptorFactory.java
@@ -26,6 +26,7 @@ import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.AcceptorFactory;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
 import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
+import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener;
 
 public class NettyAcceptorFactory implements AcceptorFactory {
 
@@ -34,7 +35,7 @@ public class NettyAcceptorFactory implements AcceptorFactory {
                                   final ClusterConnection connection,
                                   final Map<String, Object> configuration,
                                   final BufferHandler handler,
-                                  final ConnectionLifeCycleListener listener,
+                                  final ServerConnectionLifeCycleListener listener,
                                   final Executor threadPool,
                                   final ScheduledExecutorService scheduledThreadPool,
                                   final Map<String, ProtocolManager> protocolMap) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyServerConnection.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyServerConnection.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyServerConnection.java
index 31957c4..7bdf0ab 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyServerConnection.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyServerConnection.java
@@ -22,12 +22,13 @@ import io.netty.channel.Channel;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
 import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
+import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener;
 
 public class NettyServerConnection extends NettyConnection {
 
    public NettyServerConnection(Map<String, Object> configuration,
                                 Channel channel,
-                                ConnectionLifeCycleListener listener,
+                                ServerConnectionLifeCycleListener listener,
                                 boolean batchingEnabled,
                                 boolean directDeliver) {
       super(configuration, channel, listener, batchingEnabled, directDeliver);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
index 50f0cab..748c89f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
@@ -65,12 +65,12 @@ import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.AcceptorFactory;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
-import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
+import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener;
 import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
 import org.apache.activemq.artemis.utils.ConfigurationHelper;
 import org.apache.activemq.artemis.utils.ReusableLatch;
 
-public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycleListener
{
+public class RemotingServiceImpl implements RemotingService, ServerConnectionLifeCycleListener
{
    // Constants -----------------------------------------------------
 
    private static final boolean isTrace = ActiveMQServerLogger.LOGGER.isTraceEnabled();
@@ -107,7 +107,7 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
 
    private final ClusterManager clusterManager;
 
-   private final Map<String, ProtocolManager> protocolMap = new ConcurrentHashMap();
+   private final Map<String, ProtocolManagerFactory> protocolMap = new ConcurrentHashMap();
 
    private ActiveMQPrincipal defaultInvmSecurityPrincipal;
 
@@ -144,7 +144,8 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
       this.flushExecutor = flushExecutor;
 
       ActiveMQServerLogger.LOGGER.addingProtocolSupport(coreProtocolManagerFactory.getProtocols()[0],
coreProtocolManagerFactory.getModuleName());
-      this.protocolMap.put(coreProtocolManagerFactory.getProtocols()[0], coreProtocolManagerFactory.createProtocolManager(server,
coreProtocolManagerFactory.filterInterceptors(incomingInterceptors), coreProtocolManagerFactory.filterInterceptors(outgoingInterceptors)));
+//      this.protocolMap.put(coreProtocolManagerFactory.getProtocols()[0], coreProtocolManagerFactory.createProtocolManager(server,
coreProtocolManagerFactory.filterInterceptors(incomingInterceptors), coreProtocolManagerFactory.filterInterceptors(outgoingInterceptors)));
+      this.protocolMap.put(coreProtocolManagerFactory.getProtocols()[0], coreProtocolManagerFactory);
 
       if (config.isResolveProtocols()) {
          resolveProtocols(server, this.getClass().getClassLoader());
@@ -157,9 +158,10 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
       if (protocolManagerFactories != null) {
          for (ProtocolManagerFactory protocolManagerFactory : protocolManagerFactories) {
             String[] protocols = protocolManagerFactory.getProtocols();
-            for (String protocol : protocols) {
-               ActiveMQServerLogger.LOGGER.addingProtocolSupport(protocol, protocolManagerFactory.getModuleName());
-               protocolMap.put(protocol, protocolManagerFactory.createProtocolManager(server,
incomingInterceptors, outgoingInterceptors));
+            for (String protocolName : protocols) {
+               ActiveMQServerLogger.LOGGER.addingProtocolSupport(protocolName, protocolManagerFactory.getModuleName());
+               //               protocolMap.put(protocol, protocolManagerFactory.createProtocolManager(server,
incomingInterceptors, outgoingInterceptors));
+               protocolMap.put(protocolName, protocolManagerFactory);
             }
          }
       }
@@ -172,7 +174,8 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
             String[] protocols = next.getProtocols();
             for (String protocol : protocols) {
                ActiveMQServerLogger.LOGGER.addingProtocolSupport(protocol, next.getModuleName());
-               protocolMap.put(protocol, next.createProtocolManager(server, next.filterInterceptors(incomingInterceptors),
next.filterInterceptors(outgoingInterceptors)));
+               //               protocolMap.put(protocol, next.createProtocolManager(server,
next.filterInterceptors(incomingInterceptors), next.filterInterceptors(outgoingInterceptors)));
+               protocolMap.put(protocol, next);
             }
          }
       }
@@ -210,45 +213,35 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
          try {
             AcceptorFactory factory = server.getServiceRegistry().getAcceptorFactory(info.getName(),
info.getFactoryClassName());
 
-            Map<String, ProtocolManager> supportedProtocols = new ConcurrentHashMap();
+            Map<String, ProtocolManagerFactory> selectedProtocolFactories = new ConcurrentHashMap();
 
             @SuppressWarnings("deprecation")
             String protocol = ConfigurationHelper.getStringProperty(TransportConstants.PROTOCOL_PROP_NAME,
null, info.getParams());
-
             if (protocol != null) {
                ActiveMQServerLogger.LOGGER.warnDeprecatedProtocol();
-               ProtocolManager protocolManager = protocolMap.get(protocol);
-
-               if (protocolManager == null) {
-                  ActiveMQServerLogger.LOGGER.noProtocolManagerFound(protocol, info.toString());
-               }
-               else {
-                  supportedProtocols.put(protocol, protocolManager);
-               }
+               locateProtocols(protocol, info, selectedProtocolFactories);
             }
 
             String protocols = ConfigurationHelper.getStringProperty(TransportConstants.PROTOCOLS_PROP_NAME,
null, info.getParams());
 
             if (protocols != null) {
-               String[] actualProtocols = protocols.split(",");
+               locateProtocols(protocols, info, selectedProtocolFactories);
+            }
 
-               if (actualProtocols != null) {
-                  for (String actualProtocol : actualProtocols) {
-                     ProtocolManager protocolManager = protocolMap.get(actualProtocol);
+            ClusterConnection clusterConnection = lookupClusterConnection(info);
 
-                     if (protocolManager == null) {
-                        ActiveMQServerLogger.LOGGER.noProtocolManagerFound(actualProtocol,
info.toString());
-                     }
-                     else {
-                        supportedProtocols.put(actualProtocol, protocolManager);
-                     }
-                  }
-               }
+            // If empty: we get the default list
+            if (selectedProtocolFactories.isEmpty()) {
+               selectedProtocolFactories = protocolMap;
             }
 
-            ClusterConnection clusterConnection = lookupClusterConnection(info);
+            Map<String, ProtocolManager> selectedProtocols = new ConcurrentHashMap();
+            for (Map.Entry<String, ProtocolManagerFactory> entry: selectedProtocolFactories.entrySet())
{
+               selectedProtocols.put(entry.getKey(), entry.getValue().createProtocolManager(server,
info.getExtraParams(), incomingInterceptors, outgoingInterceptors));
+            }
 
-            Acceptor acceptor = factory.createAcceptor(info.getName(), clusterConnection,
info.getAllParams(), new DelegatingBufferHandler(), this, threadPool, scheduledThreadPool,
supportedProtocols.isEmpty() ? protocolMap : supportedProtocols);
+
+            Acceptor acceptor = factory.createAcceptor(info.getName(), clusterConnection,
info.getParams(), new DelegatingBufferHandler(), this, threadPool, scheduledThreadPool, selectedProtocols);
 
             if (defaultInvmSecurityPrincipal != null && acceptor.isUnsecurable())
{
                acceptor.setDefaultActiveMQPrincipal(defaultInvmSecurityPrincipal);
@@ -280,6 +273,25 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
       started = true;
    }
 
+   private void locateProtocols(String protocolList,
+                                Object transportConfig,
+                                Map<String, ProtocolManagerFactory> protocolMap) {
+      String[] protocolsSplit = protocolList.split(",");
+
+      if (protocolsSplit != null) {
+         for (String protocolItem : protocolsSplit) {
+            ProtocolManagerFactory protocolManagerFactory = protocolMap.get(protocolItem);
+
+            if (protocolManagerFactory == null) {
+               ActiveMQServerLogger.LOGGER.noProtocolManagerFound(protocolItem, transportConfig.toString());
+            }
+            else {
+               protocolMap.put(protocolItem, protocolManagerFactory);
+            }
+         }
+      }
+   }
+
    @Override
    public synchronized void startAcceptors() throws Exception {
       if (isStarted()) {
@@ -469,25 +481,19 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
 
    // ConnectionLifeCycleListener implementation -----------------------------------
 
-   private ProtocolManager getProtocolManager(String protocol) {
+   private ProtocolManagerFactory getProtocolManager(String protocol) {
       return protocolMap.get(protocol);
    }
 
    @Override
    public void connectionCreated(final ActiveMQComponent component,
                                  final Connection connection,
-                                 final String protocol) {
+                                 final ProtocolManager protocol) {
       if (server == null) {
          throw new IllegalStateException("Unable to create connection, server hasn't finished
starting up");
       }
 
-      ProtocolManager pmgr = this.getProtocolManager(protocol.toString());
-
-      if (pmgr == null) {
-         throw ActiveMQMessageBundle.BUNDLE.unknownProtocol(protocol);
-      }
-
-      ConnectionEntry entry = pmgr.createConnectionEntry((Acceptor) component, connection);
+      ConnectionEntry entry = protocol.createConnectionEntry((Acceptor) component, connection);
 
       if (isTrace) {
          ActiveMQServerLogger.LOGGER.trace("Connection created " + connection);
@@ -720,9 +726,9 @@ public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycle
    }
 
    protected void updateProtocols() {
-      for (ProtocolManager<?> protocolManager : this.protocolMap.values()) {
-         protocolManager.updateInterceptors(incomingInterceptors, outgoingInterceptors);
-      }
+//      for (ProtocolManager<?> protocolManager : this.protocolMap.values()) {
+//         protocolManager.updateInterceptors(incomingInterceptors, outgoingInterceptors);
+//      }
 
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java
index d9a8688..cb48b49 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/MessageLoadBalancingType.java
@@ -16,7 +16,7 @@
  */
 package org.apache.activemq.artemis.core.server.cluster.impl;
 
-import org.apache.activemq.artemis.utils.uri.URISchema;
+import org.apache.activemq.artemis.utils.uri.BeanSupport;
 import org.apache.commons.beanutils.Converter;
 
 public enum MessageLoadBalancingType {
@@ -24,7 +24,7 @@ public enum MessageLoadBalancingType {
 
    static {
       // for URI support on ClusterConnection
-      URISchema.registerConverter(new MessageLoadBalancingTypeConverter(), MessageLoadBalancingType.class);
+      BeanSupport.registerConverter(new MessageLoadBalancingTypeConverter(), MessageLoadBalancingType.class);
    }
 
    static class MessageLoadBalancingTypeConverter implements Converter {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java
index 6c4eb8b..6a61065 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/AbstractProtocolManagerFactory.java
@@ -34,7 +34,7 @@ public abstract class AbstractProtocolManagerFactory<P extends BaseInterceptor>
     * @param listIn
     * @return
     */
-   protected List<P> filterInterceptors(Class<P> type, List<? extends BaseInterceptor>
listIn) {
+   protected List<P> internalFilterInterceptors(Class<P> type, List<? extends
BaseInterceptor> listIn) {
       if (listIn == null) {
          return Collections.emptyList();
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
index e7c1d07..d3b1b2e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/ProtocolManagerFactory.java
@@ -17,6 +17,7 @@
 package org.apache.activemq.artemis.spi.core.protocol;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.activemq.artemis.api.core.BaseInterceptor;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
@@ -34,8 +35,9 @@ public interface ProtocolManagerFactory<P extends BaseInterceptor>
{
     * @return
     */
    ProtocolManager createProtocolManager(ActiveMQServer server,
-                                         List<P> incomingInterceptors,
-                                         List<P> outgoingInterceptors);
+                                         Map<String, Object> parameters,
+                                         List<BaseInterceptor> incomingInterceptors,
+                                         List<BaseInterceptor> outgoingInterceptors)
throws Exception;
 
    /**
     * This should get the entire list and only return the ones this factory can deal with
*

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/AcceptorFactory.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/AcceptorFactory.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/AcceptorFactory.java
index 1580d18..4390d4f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/AcceptorFactory.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/AcceptorFactory.java
@@ -46,7 +46,7 @@ public interface AcceptorFactory {
                            ClusterConnection clusterConnection,
                            Map<String, Object> configuration,
                            BufferHandler handler,
-                           ConnectionLifeCycleListener listener,
+                           ServerConnectionLifeCycleListener listener,
                            Executor threadPool,
                            ScheduledExecutorService scheduledThreadPool,
                            Map<String, ProtocolManager> protocolMap);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java
index 1d8d5b0..7e3c8fd 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ServerConnectionLifeCycleListener.java
@@ -16,15 +16,7 @@
  */
 package org.apache.activemq.artemis.spi.core.remoting;
 
-public interface ServerConnectionLifeCycleListener extends ConnectionLifeCycleListener {
+import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
 
-   /**
-    * This method is used both by client connector creation and server connection creation
through acceptors.
-    * the acceptor will be set to null on client operations
-    *
-    * @param acceptor   The acceptor here will be always null on a client connection created
event.
-    * @param connection the connection that has been created
-    * @param protocol   the protocol to use
-    */
-   void connectionCreated(Acceptor acceptor, Connection connection, String protocol);
+public interface ServerConnectionLifeCycleListener extends BaseConnectionLifeCycleListener<ProtocolManager>
{
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.java
index f776924..b465be4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionMulticastSchema.java
@@ -21,6 +21,7 @@ import java.net.URI;
 import java.util.Map;
 
 import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
+import org.apache.activemq.artemis.utils.uri.BeanSupport;
 import org.apache.activemq.artemis.utils.uri.URISupport;
 
 public class ClusterConnectionMulticastSchema extends ClusterConnectionStaticSchema {
@@ -40,7 +41,7 @@ public class ClusterConnectionMulticastSchema extends ClusterConnectionStaticSch
       else {
          bean.setDiscoveryGroupName(uri.getHost());
          Map<String, String> parameters = URISupport.parseParameters(uri);
-         setData(uri, bean, parameters);
+         BeanSupport.setData(uri, bean, parameters);
 
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.java
index f81aa58..0f62d26 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/uri/schemas/clusterConnection/ClusterConnectionStaticSchema.java
@@ -21,6 +21,7 @@ import java.net.URI;
 import java.util.Map;
 
 import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
+import org.apache.activemq.artemis.utils.uri.BeanSupport;
 import org.apache.activemq.artemis.utils.uri.URISchema;
 import org.apache.activemq.artemis.utils.uri.URISupport;
 
@@ -50,7 +51,7 @@ public class ClusterConnectionStaticSchema extends URISchema<ClusterConnectionCo
       URISupport.CompositeData compositeData = URISupport.parseComposite(uri);
       bean.setCompositeMembers(compositeData);
 
-      setData(uri, bean, compositeData.getParameters());
+      BeanSupport.setData(uri, bean, compositeData.getParameters());
    }
 
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
new file mode 100644
index 0000000..be26473
--- /dev/null
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/uri/AcceptorParserTest.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.uri;
+
+import java.net.URI;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AcceptorParserTest {
+
+   @Test
+   public void testAcceptor() throws Exception {
+      AcceptorTransportConfigurationParser parser = new AcceptorTransportConfigurationParser();
+      List<TransportConfiguration> configs = parser.newObject(new URI("tcp://localhost:8080?tcpSendBufferSize=1048576&tcpReceiveBufferSize=1048576&protocols=openwire&banana=x"),
"test");
+
+      for (TransportConfiguration config : configs) {
+         System.out.println("config:" + config);
+         Assert.assertTrue(config.getExtraParams().get("banana").equals("x"));
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
index ac2ff3c..f2afea8 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
@@ -26,10 +26,12 @@ import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory;
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
+import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
 import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
 import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
+import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.junit.Assert;
 import org.junit.Test;
@@ -48,7 +50,7 @@ public class NettyAcceptorFactoryTest extends ActiveMQTestBase {
          }
       };
 
-      ConnectionLifeCycleListener listener = new ConnectionLifeCycleListener() {
+      ServerConnectionLifeCycleListener listener = new ServerConnectionLifeCycleListener()
{
 
          @Override
          public void connectionException(final Object connectionID, final ActiveMQException
me) {
@@ -61,7 +63,7 @@ public class NettyAcceptorFactoryTest extends ActiveMQTestBase {
          @Override
          public void connectionCreated(ActiveMQComponent component,
                                        final Connection connection,
-                                       final String protocol) {
+                                       final ProtocolManager protocol) {
          }
 
          @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
index f0ea5db..febe7db 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.tests.unit.core.remoting.impl.netty;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Executors;
@@ -25,13 +26,14 @@ import java.util.concurrent.TimeUnit;
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
+import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptor;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
-import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -72,7 +74,7 @@ public class NettyAcceptorTest extends ActiveMQTestBase {
       };
 
       Map<String, Object> params = new HashMap<>();
-      ConnectionLifeCycleListener listener = new ConnectionLifeCycleListener() {
+      ServerConnectionLifeCycleListener listener = new ServerConnectionLifeCycleListener()
{
 
          @Override
          public void connectionException(final Object connectionID, final ActiveMQException
me) {
@@ -85,7 +87,7 @@ public class NettyAcceptorTest extends ActiveMQTestBase {
          @Override
          public void connectionCreated(final ActiveMQComponent component,
                                        final Connection connection,
-                                       final String protocol) {
+                                       final ProtocolManager protocol) {
          }
 
          @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15ce38e9/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/server/impl/fake/FakeAcceptorFactory.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/server/impl/fake/FakeAcceptorFactory.java
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/server/impl/fake/FakeAcceptorFactory.java
index 838c829..3b858bf 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/server/impl/fake/FakeAcceptorFactory.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/server/impl/fake/FakeAcceptorFactory.java
@@ -27,7 +27,7 @@ import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;
 import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
 import org.apache.activemq.artemis.spi.core.remoting.AcceptorFactory;
 import org.apache.activemq.artemis.spi.core.remoting.BufferHandler;
-import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener;
+import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener;
 
 public class FakeAcceptorFactory implements AcceptorFactory {
 
@@ -38,7 +38,7 @@ public class FakeAcceptorFactory implements AcceptorFactory {
                                   ClusterConnection clusterConnection,
                                   Map<String, Object> configuration,
                                   BufferHandler handler,
-                                  ConnectionLifeCycleListener listener,
+                                  ServerConnectionLifeCycleListener listener,
                                   Executor threadPool,
                                   ScheduledExecutorService scheduledThreadPool,
                                   Map<String, ProtocolManager> protocolMap) {


Mime
View raw message