From fa439375e9dc950e9047ea661ebf53a05e08e7c6 Mon Sep 17 00:00:00 2001 From: Emmanuel Hugonnet Date: Wed, 22 Sep 2021 14:06:18 +0200 Subject: [PATCH] [ARTEMIS-3494]: ActiveMQClientProtocolManagerFactory shouldn't have a private constructor. * Removing the 'private' constructor * Removing the use of a static getInstance Issue: https://issues.apache.org/jira/browse/ARTEMIS-3494 --- .../artemis/core/client/impl/ServerLocatorImpl.java | 4 ++-- .../core/impl/ActiveMQClientProtocolManagerFactory.java | 6 ++---- .../spi/core/remoting/ClientProtocolManagerFactory.java | 2 +- .../hornetq/client/HornetQClientProtocolManagerFactory.java | 3 ++- .../cluster/ActiveMQServerSideProtocolManagerFactory.java | 3 ++- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java index 2ac0fd3106..363849fef2 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java @@ -95,7 +95,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery private static final long serialVersionUID = -1615857864410205260L; // This is the default value - private ClientProtocolManagerFactory protocolManagerFactory = ActiveMQClientProtocolManagerFactory.getInstance(this); + private ClientProtocolManagerFactory protocolManagerFactory = new ActiveMQClientProtocolManagerFactory().setLocator(this); private final boolean ha; @@ -506,7 +506,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery public ClientProtocolManagerFactory getProtocolManagerFactory() { if (protocolManagerFactory == null) { // Default one in case it's null - protocolManagerFactory = ActiveMQClientProtocolManagerFactory.getInstance(this); + protocolManagerFactory = new ActiveMQClientProtocolManagerFactory().setLocator(this); } return protocolManagerFactory; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java index 866713cfdd..64e9009d1d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManagerFactory.java @@ -25,9 +25,6 @@ public class ActiveMQClientProtocolManagerFactory implements ClientProtocolManag private static final long serialVersionUID = 1; - private ActiveMQClientProtocolManagerFactory() { - } - ServerLocator locator; @Override @@ -36,8 +33,9 @@ public class ActiveMQClientProtocolManagerFactory implements ClientProtocolManag } @Override - public void setLocator(ServerLocator locator) { + public ClientProtocolManagerFactory setLocator(ServerLocator locator) { this.locator = locator; + return this; } public static final ActiveMQClientProtocolManagerFactory getInstance(ServerLocator locator) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java index 96e9eadba5..78d3db3572 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/spi/core/remoting/ClientProtocolManagerFactory.java @@ -23,7 +23,7 @@ public interface ClientProtocolManagerFactory { ClientProtocolManager newProtocolManager(); - void setLocator(ServerLocator locator); + ClientProtocolManagerFactory setLocator(ServerLocator locator); ServerLocator getLocator(); diff --git a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java index 57f2c94d7f..0ac83746e0 100644 --- a/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java +++ b/artemis-protocols/artemis-hqclient-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/hornetq/client/HornetQClientProtocolManagerFactory.java @@ -36,10 +36,11 @@ public class HornetQClientProtocolManagerFactory implements ClientProtocolManage } @Override - public void setLocator(ServerLocator locator) { + public ClientProtocolManagerFactory setLocator(ServerLocator locator) { this.locator = locator; locator.addIncomingInterceptor(new HQPropertiesConversionInterceptor(true)); locator.addOutgoingInterceptor(new HQPropertiesConversionInterceptor(false)); + return this; } /** diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java index eae6c36de9..48e56660a2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ActiveMQServerSideProtocolManagerFactory.java @@ -44,8 +44,9 @@ public class ActiveMQServerSideProtocolManagerFactory implements ClientProtocolM } @Override - public void setLocator(ServerLocator locator) { + public ClientProtocolManagerFactory setLocator(ServerLocator locator) { this.locator = locator; + return this; } public static ActiveMQServerSideProtocolManagerFactory getInstance(ServerLocator locator, StorageManager storageManager) {