You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/04/12 22:17:00 UTC
[2/2] activemq-artemis git commit: ARTEMIS-463 Refactored protocol
loading code to not duplicate logic, and load from the default list.
ARTEMIS-463 Refactored protocol loading code to not duplicate logic, and load from the default list.
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/5b8ab202
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/5b8ab202
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/5b8ab202
Branch: refs/heads/master
Commit: 5b8ab202192dbb3fdfa92d452bcfc73c00d45e73
Parents: 9fc60cd
Author: John D. Ament <jo...@apache.org>
Authored: Mon Apr 11 20:18:28 2016 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Apr 12 16:15:55 2016 -0400
----------------------------------------------------------------------
.../server/impl/RemotingServiceImpl.java | 94 +++++++++++---------
1 file changed, 50 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5b8ab202/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 795bbb5..2ed6e3a 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
@@ -146,40 +146,18 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
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);
if (config.isResolveProtocols()) {
- resolveProtocols(server, this.getClass().getClassLoader());
+ resolveProtocols(this.getClass().getClassLoader());
if (this.getClass().getClassLoader() != Thread.currentThread().getContextClassLoader()) {
- resolveProtocols(server, Thread.currentThread().getContextClassLoader());
+ resolveProtocols(Thread.currentThread().getContextClassLoader());
}
}
if (protocolManagerFactories != null) {
- for (ProtocolManagerFactory protocolManagerFactory : protocolManagerFactories) {
- String[] protocols = protocolManagerFactory.getProtocols();
- for (String protocolName : protocols) {
- ActiveMQServerLogger.LOGGER.addingProtocolSupport(protocolName, protocolManagerFactory.getModuleName());
- // protocolMap.put(protocol, protocolManagerFactory.createProtocolManager(server, incomingInterceptors, outgoingInterceptors));
- protocolMap.put(protocolName, protocolManagerFactory);
- }
- }
- }
- }
-
- private void resolveProtocols(ActiveMQServer server, ClassLoader loader) {
- ServiceLoader<ProtocolManagerFactory> serviceLoader = ServiceLoader.load(ProtocolManagerFactory.class, loader);
- if (serviceLoader != null) {
- for (ProtocolManagerFactory next : serviceLoader) {
- 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);
- }
- }
+ loadProtocolManagerFactories(protocolManagerFactories);
}
}
@@ -277,25 +255,6 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
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()) {
@@ -742,4 +701,51 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
}
}
+ /**
+ * Locates protocols from the internal default map and moves them into the input protocol map.
+ *
+ * @param protocolList
+ * @param transportConfig
+ * @param protocolMap
+ */
+ private void locateProtocols(String protocolList,
+ Object transportConfig,
+ Map<String, ProtocolManagerFactory> protocolMap) {
+ String[] protocolsSplit = protocolList.split(",");
+
+ for (String protocolItem : protocolsSplit) {
+ ProtocolManagerFactory protocolManagerFactory = this.protocolMap.get(protocolItem);
+
+ if (protocolManagerFactory == null) {
+ ActiveMQServerLogger.LOGGER.noProtocolManagerFound(protocolItem, transportConfig.toString());
+ }
+ else {
+ protocolMap.put(protocolItem, protocolManagerFactory);
+ }
+ }
+ }
+
+ /**
+ * Finds protocol support from a given classloader.
+ * @param loader
+ */
+ private void resolveProtocols(ClassLoader loader) {
+ ServiceLoader<ProtocolManagerFactory> serviceLoader = ServiceLoader.load(ProtocolManagerFactory.class, loader);
+ loadProtocolManagerFactories(serviceLoader);
+ }
+
+ /**
+ * Loads the protocols found into a map.
+ * @param protocolManagerFactoryCollection
+ */
+ private void loadProtocolManagerFactories(Iterable<ProtocolManagerFactory> protocolManagerFactoryCollection) {
+ for (ProtocolManagerFactory next : protocolManagerFactoryCollection) {
+ String[] protocols = next.getProtocols();
+ for (String protocol : protocols) {
+ ActiveMQServerLogger.LOGGER.addingProtocolSupport(protocol, next.getModuleName());
+ protocolMap.put(protocol, next);
+ }
+ }
+ }
+
}