This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 5d0c0dfc2e ARTEMIS-5974 replace FactoryFinder with Java ServiceLoader
5d0c0dfc2e is described below

commit 5d0c0dfc2e8504b538d3ce7d63886fb4665e0973
Author: Justin Bertram <[email protected]>
AuthorDate: Sat Mar 28 23:04:53 2026 -0500

    ARTEMIS-5974 replace FactoryFinder with Java ServiceLoader
---
 .../artemis/cli/factory/BrokerFactory.java         |  29 ++--
 .../artemis/cli/factory/BrokerFactoryHandler.java  |   2 +
 .../artemis/cli/factory/BrokerHandler.java         |   2 +
 .../artemis/cli/factory/FileBrokerHandler.java     |   5 +
 .../artemis/cli/factory/jmx/JmxAclHandler.java     |   3 +
 .../artemis/cli/factory/jmx/ManagementFactory.java |  15 +-
 .../artemis/cli/factory/jmx/XmlJmxAclHandler.java  |   6 +
 .../cli/factory/security/JaasSecurityHandler.java  |   5 +
 .../cli/factory/security/SecurityHandler.java      |   2 +
 .../factory/security/SecurityManagerFactory.java   |  16 ++-
 .../factory/security/SecurityManagerHandler.java   |   5 +
 .../cli/factory/xml/XmlBrokerFactoryHandler.java   |   5 +
 ...tivemq.artemis.cli.factory.BrokerFactoryHandler |  18 +++
 ...ache.activemq.artemis.cli.factory.BrokerHandler |  18 +++
 ....activemq.artemis.cli.factory.jmx.JmxAclHandler |  18 +++
 ...mq.artemis.cli.factory.security.SecurityHandler |  19 +++
 .../org/apache/activemq/artemis/broker/jmx/xml     |  17 ---
 .../activemq/artemis/broker/security/jaas-security |  17 ---
 .../artemis/broker/security/security-manager       |  17 ---
 .../org/apache/activemq/artemis/broker/server/file |  17 ---
 .../org/apache/activemq/artemis/broker/xml         |  17 ---
 .../cli/factory/TestBrokerFactoryHandler.java      |   5 +
 ...tivemq.artemis.cli.factory.BrokerFactoryHandler |   1 +
 .../org/apache/activemq/artemis/broker/test        |  17 ---
 .../activemq/artemis/utils/FactoryFinder.java      | 153 ---------------------
 25 files changed, 154 insertions(+), 275 deletions(-)

diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactory.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactory.java
index 181207239e..7aa65d52c2 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactory.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactory.java
@@ -16,12 +16,12 @@
  */
 package org.apache.activemq.artemis.cli.factory;
 
-import java.io.IOException;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Properties;
+import java.util.ServiceLoader;
 
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.cli.ConfigurationException;
@@ -33,7 +33,6 @@ import org.apache.activemq.artemis.dto.SecurityManagerDTO;
 import org.apache.activemq.artemis.dto.ServerDTO;
 import org.apache.activemq.artemis.integration.Broker;
 import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
-import org.apache.activemq.artemis.utils.FactoryFinder;
 
 public class BrokerFactory {
 
@@ -50,11 +49,15 @@ public class BrokerFactory {
          throw new ConfigurationException("Invalid configuration URI, no 
scheme specified: " + configURI);
       }
 
+      ServiceLoader<BrokerFactoryHandler> loader = 
ServiceLoader.load(BrokerFactoryHandler.class, 
BrokerFactory.class.getClassLoader());
       BrokerFactoryHandler factory = null;
-      try {
-         FactoryFinder finder = new 
FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/");
-         factory = (BrokerFactoryHandler) 
finder.newInstance(configURI.getScheme());
-      } catch (IOException ioe) {
+      for (BrokerFactoryHandler handler : loader) {
+         if (handler.getName().equals(configURI.getScheme())) {
+            factory = handler;
+            break;
+         }
+      }
+      if (factory == null) {
          throw new ConfigurationException("Invalid configuration URI, can't 
find configuration scheme: " + configURI.getScheme());
       }
       BrokerDTO broker = factory.createBroker(configURI, artemisHome, 
artemisInstance, artemisURIInstance);
@@ -104,13 +107,17 @@ public class BrokerFactory {
 
    public static Broker createServer(ServerDTO brokerDTO, 
ActiveMQSecurityManager security, ActivateCallback activateCallback) throws 
Exception {
       if (brokerDTO.configuration != null) {
-         BrokerHandler handler;
          URI configURI = brokerDTO.getConfigurationURI();
 
-         try {
-            FactoryFinder finder = new 
FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/server/");
-            handler = (BrokerHandler) 
finder.newInstance(configURI.getScheme());
-         } catch (IOException ioe) {
+         ServiceLoader<BrokerHandler> loader = 
ServiceLoader.load(BrokerHandler.class, BrokerFactory.class.getClassLoader());
+         BrokerHandler handler = null;
+         for (BrokerHandler h : loader) {
+            if (h.getName().equals(configURI.getScheme())) {
+               handler = h;
+               break;
+            }
+         }
+         if (handler == null) {
             throw new ConfigurationException("Invalid configuration URI, can't 
find configuration scheme: " + configURI.getScheme());
          }
 
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactoryHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactoryHandler.java
index 2d16c3ae0d..71a5678774 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactoryHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactoryHandler.java
@@ -22,5 +22,7 @@ import org.apache.activemq.artemis.dto.BrokerDTO;
 
 public interface BrokerFactoryHandler {
 
+   String getName();
+
    BrokerDTO createBroker(URI brokerURI, String artemisHome, String 
artemisInstance, URI artemisURIInstance) throws Exception;
 }
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerHandler.java
index 513206c1ea..12ae9f425c 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerHandler.java
@@ -23,5 +23,7 @@ import 
org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
 
 public interface BrokerHandler {
 
+   String getName();
+
    Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security, 
ActivateCallback activateCallback);
 }
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/FileBrokerHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/FileBrokerHandler.java
index 2b5faecd75..9054a1d94d 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/FileBrokerHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/FileBrokerHandler.java
@@ -24,6 +24,11 @@ import 
org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
 
 public class FileBrokerHandler implements BrokerHandler {
 
+   @Override
+   public String getName() {
+      return "file";
+   }
+
    @Override
    public Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager 
security, ActivateCallback activateCallback) {
       return new FileBroker(brokerDTO, security, activateCallback);
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/JmxAclHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/JmxAclHandler.java
index 95ee33d2f6..44344320dc 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/JmxAclHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/JmxAclHandler.java
@@ -21,5 +21,8 @@ import org.apache.activemq.artemis.dto.ManagementContextDTO;
 import java.net.URI;
 
 public interface JmxAclHandler {
+
+   String getName();
+
    ManagementContextDTO createJmxAcl(URI configURI, String artemisHome, String 
artemisInstance, URI artemisURIInstance) throws Exception;
 }
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/ManagementFactory.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/ManagementFactory.java
index 687e67140e..618c2853f1 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/ManagementFactory.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/ManagementFactory.java
@@ -31,11 +31,10 @@ import org.apache.activemq.artemis.dto.MatchDTO;
 import org.apache.activemq.artemis.core.server.management.JMXAccessControlList;
 import org.apache.activemq.artemis.dto.WhiteListDTO;
 import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
-import org.apache.activemq.artemis.utils.FactoryFinder;
 
-import java.io.IOException;
 import java.net.URI;
 import java.util.List;
+import java.util.ServiceLoader;
 
 public class ManagementFactory {
 
@@ -47,11 +46,15 @@ public class ManagementFactory {
          throw new ConfigurationException("Invalid configuration URI, no 
scheme specified: " + configURI);
       }
 
+      ServiceLoader<JmxAclHandler> loader = 
ServiceLoader.load(JmxAclHandler.class, 
ManagementFactory.class.getClassLoader());
       JmxAclHandler factory = null;
-      try {
-         FactoryFinder finder = new 
FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/jmx/");
-         factory = (JmxAclHandler) finder.newInstance(configURI.getScheme());
-      } catch (IOException ioe) {
+      for (JmxAclHandler handler : loader) {
+         if (handler.getName().equals(configURI.getScheme())) {
+            factory = handler;
+            break;
+         }
+      }
+      if (factory == null) {
          throw new ConfigurationException("Invalid configuration URI, can't 
find configuration scheme: " + configURI.getScheme());
       }
       return factory.createJmxAcl(configURI, artemisHome, artemisInstance, 
artemisURIInstance);
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/XmlJmxAclHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/XmlJmxAclHandler.java
index 41a0b1c23a..7a4d684049 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/XmlJmxAclHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/jmx/XmlJmxAclHandler.java
@@ -25,6 +25,12 @@ import java.io.File;
 import java.net.URI;
 
 public class XmlJmxAclHandler implements JmxAclHandler {
+
+   @Override
+   public String getName() {
+      return "xml";
+   }
+
    @Override
    public ManagementContextDTO createJmxAcl(URI configURI, String artemisHome, 
String artemisInstance, URI artemisURIInstance) throws Exception {
       File file = new File(configURI.getSchemeSpecificPart());
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/JaasSecurityHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/JaasSecurityHandler.java
index a096567b4e..84629307db 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/JaasSecurityHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/JaasSecurityHandler.java
@@ -23,6 +23,11 @@ import 
org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
 
 public class JaasSecurityHandler implements SecurityHandler {
 
+   @Override
+   public String getName() {
+      return "jaas-security";
+   }
+
    @Override
    public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) 
throws Exception {
       JaasSecurityDTO jaasSecurity = (JaasSecurityDTO) security;
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityHandler.java
index df905178eb..7aecda8e03 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityHandler.java
@@ -21,5 +21,7 @@ import 
org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
 
 public interface SecurityHandler {
 
+   String getName();
+
    ActiveMQSecurityManager createSecurityManager(SecurityDTO securityDTO) 
throws Exception;
 }
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerFactory.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerFactory.java
index 3ebf8c3fae..05a6380361 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerFactory.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerFactory.java
@@ -16,11 +16,11 @@
  */
 package org.apache.activemq.artemis.cli.factory.security;
 
+import java.util.ServiceLoader;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.activemq.artemis.dto.SecurityDTO;
 import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
-import org.apache.activemq.artemis.utils.FactoryFinder;
 
 public class SecurityManagerFactory {
 
@@ -28,8 +28,18 @@ public class SecurityManagerFactory {
       if (config == null) {
          throw new Exception("No security manager configured!");
       }
-      FactoryFinder finder = new 
FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/security/");
-      SecurityHandler securityHandler = (SecurityHandler) 
finder.newInstance(config.getClass().getAnnotation(XmlRootElement.class).name());
+      String name = 
config.getClass().getAnnotation(XmlRootElement.class).name();
+      ServiceLoader<SecurityHandler> loader = 
ServiceLoader.load(SecurityHandler.class, 
SecurityManagerFactory.class.getClassLoader());
+      SecurityHandler securityHandler = null;
+      for (SecurityHandler handler : loader) {
+         if (handler.getName().equals(name)) {
+            securityHandler = handler;
+            break;
+         }
+      }
+      if (securityHandler == null) {
+         throw new Exception("Invalid security configuration, can't find 
security handler: " + name);
+      }
       return securityHandler.createSecurityManager(config);
    }
 }
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerHandler.java
index 166b8aa759..b1791acd82 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerHandler.java
@@ -29,6 +29,11 @@ import 
org.apache.activemq.artemis.utils.sm.SecurityManagerShim;
 
 public class SecurityManagerHandler implements SecurityHandler {
 
+   @Override
+   public String getName() {
+      return "security-manager";
+   }
+
    @Override
    public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) {
       SecurityManagerDTO customSecurity = (SecurityManagerDTO) security;
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/xml/XmlBrokerFactoryHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/xml/XmlBrokerFactoryHandler.java
index 828425286f..a2d4d5c91e 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/xml/XmlBrokerFactoryHandler.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/xml/XmlBrokerFactoryHandler.java
@@ -26,6 +26,11 @@ import org.apache.activemq.artemis.dto.XmlUtil;
 
 public class XmlBrokerFactoryHandler implements BrokerFactoryHandler {
 
+   @Override
+   public String getName() {
+      return "xml";
+   }
+
    @Override
    public BrokerDTO createBroker(URI brokerURI, String artemisHome, String 
artemisInstance, URI artemisURIInstance) throws Exception {
       File file = new File(brokerURI.getSchemeSpecificPart());
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerFactoryHandler
 
b/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerFactoryHandler
new file mode 100644
index 0000000000..f3091cf94c
--- /dev/null
+++ 
b/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerFactoryHandler
@@ -0,0 +1,18 @@
+# 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.
+
+org.apache.activemq.artemis.cli.factory.xml.XmlBrokerFactoryHandler
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerHandler
 
b/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerHandler
new file mode 100644
index 0000000000..44767a961d
--- /dev/null
+++ 
b/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerHandler
@@ -0,0 +1,18 @@
+# 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.
+
+org.apache.activemq.artemis.cli.factory.FileBrokerHandler
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.jmx.JmxAclHandler
 
b/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.jmx.JmxAclHandler
new file mode 100644
index 0000000000..589ab3ebf5
--- /dev/null
+++ 
b/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.jmx.JmxAclHandler
@@ -0,0 +1,18 @@
+# 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.
+
+org.apache.activemq.artemis.cli.factory.jmx.XmlJmxAclHandler
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.security.SecurityHandler
 
b/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.security.SecurityHandler
new file mode 100644
index 0000000000..1069686342
--- /dev/null
+++ 
b/artemis-cli/src/main/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.security.SecurityHandler
@@ -0,0 +1,19 @@
+# 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.
+
+org.apache.activemq.artemis.cli.factory.security.JaasSecurityHandler
+org.apache.activemq.artemis.cli.factory.security.SecurityManagerHandler
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/jmx/xml
 
b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/jmx/xml
deleted file mode 100644
index 3d2dd012fe..0000000000
--- 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/jmx/xml
+++ /dev/null
@@ -1,17 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.cli.factory.jmx.XmlJmxAclHandler
\ No newline at end of file
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/jaas-security
 
b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/jaas-security
deleted file mode 100644
index b05ff707ce..0000000000
--- 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/jaas-security
+++ /dev/null
@@ -1,17 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.cli.factory.security.JaasSecurityHandler
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/security-manager
 
b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/security-manager
deleted file mode 100644
index 128f2260e5..0000000000
--- 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/security-manager
+++ /dev/null
@@ -1,17 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.cli.factory.security.SecurityManagerHandler
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/server/file
 
b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/server/file
deleted file mode 100644
index 59419dd202..0000000000
--- 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/server/file
+++ /dev/null
@@ -1,17 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.cli.factory.FileBrokerHandler
diff --git 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/xml
 
b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/xml
deleted file mode 100644
index 4f7943d95e..0000000000
--- 
a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/xml
+++ /dev/null
@@ -1,17 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.cli.factory.xml.XmlBrokerFactoryHandler
diff --git 
a/artemis-cli/src/test/java/org/apache/activemq/artemis/cli/factory/TestBrokerFactoryHandler.java
 
b/artemis-cli/src/test/java/org/apache/activemq/artemis/cli/factory/TestBrokerFactoryHandler.java
index 7bae00bc59..44dd6b883c 100644
--- 
a/artemis-cli/src/test/java/org/apache/activemq/artemis/cli/factory/TestBrokerFactoryHandler.java
+++ 
b/artemis-cli/src/test/java/org/apache/activemq/artemis/cli/factory/TestBrokerFactoryHandler.java
@@ -76,6 +76,11 @@ public class TestBrokerFactoryHandler implements 
BrokerFactoryHandler {
       broker = null;
    }
 
+   @Override
+   public String getName() {
+      return "test";
+   }
+
    @Override
    public BrokerDTO createBroker(URI brokerURI, String artemisHome, String 
artemisInstance, URI artemisURIInstance) throws Exception {
       TestBrokerFactoryHandler.brokerURI = brokerURI;
diff --git 
a/artemis-cli/src/test/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerFactoryHandler
 
b/artemis-cli/src/test/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerFactoryHandler
new file mode 100644
index 0000000000..1edbe842ab
--- /dev/null
+++ 
b/artemis-cli/src/test/resources/META-INF/services/org.apache.activemq.artemis.cli.factory.BrokerFactoryHandler
@@ -0,0 +1 @@
+org.apache.activemq.artemis.cli.factory.TestBrokerFactoryHandler
diff --git 
a/artemis-cli/src/test/resources/META-INF/services/org/apache/activemq/artemis/broker/test
 
b/artemis-cli/src/test/resources/META-INF/services/org/apache/activemq/artemis/broker/test
deleted file mode 100644
index 4259e4bb64..0000000000
--- 
a/artemis-cli/src/test/resources/META-INF/services/org/apache/activemq/artemis/broker/test
+++ /dev/null
@@ -1,17 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.cli.factory.TestBrokerFactoryHandler
diff --git 
a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java
 
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java
deleted file mode 100644
index 2373d5748f..0000000000
--- 
a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FactoryFinder.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.utils;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-public class FactoryFinder {
-
-   /**
-    * The strategy that the FactoryFinder uses to find load and instantiate 
Objects can be changed out by calling the
-    * setObjectFactory method with a custom implementation of ObjectFactory.
-    * <p>
-    * The default ObjectFactory is typically changed out when running in a 
specialized container environment where
-    * service discovery needs to be done via the container system.  For 
example, in an OSGi scenario.
-    */
-   public interface ObjectFactory {
-
-      /**
-       * Creates an {@code Object} based on the input
-       *
-       * @param path the full service path
-       * @return {@code Object}
-       * @throws IllegalAccessException illegal access
-       * @throws InstantiationException on instantiation error
-       * @throws IOException            On IO Error
-       * @throws ClassNotFoundException On class not found error
-       */
-      Object create(String path) throws IllegalAccessException, 
InstantiationException, IOException, ClassNotFoundException;
-
-   }
-
-   /**
-    * The default implementation of Object factory which works well in 
standalone applications.
-    */
-   protected static class StandaloneObjectFactory implements ObjectFactory {
-
-      final ConcurrentMap<String, Class> classMap = new ConcurrentHashMap<>();
-
-      @Override
-      public Object create(final String path) throws InstantiationException, 
IllegalAccessException, ClassNotFoundException, IOException {
-         Class clazz = classMap.get(path);
-         if (clazz == null) {
-            clazz = loadClass(loadProperties(path));
-            classMap.put(path, clazz);
-         }
-         try {
-            return clazz.getDeclaredConstructor().newInstance();
-         } catch (NoSuchMethodException | InvocationTargetException e) {
-            throw new IOException(e);
-         }
-      }
-
-      static Class loadClass(Properties properties) throws 
ClassNotFoundException, IOException {
-
-         String className = properties.getProperty("class");
-         if (className == null) {
-            throw new IOException("Expected property is missing: class");
-         }
-         Class clazz = null;
-         ClassLoader loader = Thread.currentThread().getContextClassLoader();
-         if (loader != null) {
-            try {
-               clazz = loader.loadClass(className);
-            } catch (ClassNotFoundException e) {
-               // ignore
-            }
-         }
-         if (clazz == null) {
-            clazz = FactoryFinder.class.getClassLoader().loadClass(className);
-         }
-
-         return clazz;
-      }
-
-      public Properties loadProperties(String uri) throws IOException {
-         // lets try the thread context class loader first
-         ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
-         if (classLoader == null) {
-            classLoader = StandaloneObjectFactory.class.getClassLoader();
-         }
-         InputStream in = classLoader.getResourceAsStream(uri);
-         if (in == null) {
-            in = FactoryFinder.class.getClassLoader().getResourceAsStream(uri);
-            if (in == null) {
-               throw new IOException("Could not find factory class for 
resource: " + uri);
-            }
-         }
-
-         // lets load the file
-         try (BufferedInputStream reader = new BufferedInputStream(in)) {
-            Properties properties = new Properties();
-            properties.load(reader);
-            return properties;
-         }
-      }
-   }
-
-   // ================================================================
-   // Class methods and properties
-   // ================================================================
-   private static ObjectFactory objectFactory = new StandaloneObjectFactory();
-
-   public static ObjectFactory getObjectFactory() {
-      return objectFactory;
-   }
-
-   public static void setObjectFactory(ObjectFactory objectFactory) {
-      FactoryFinder.objectFactory = objectFactory;
-   }
-
-   // ================================================================
-   // Instance methods and properties
-   // ================================================================
-   private final String path;
-
-   public FactoryFinder(String path) {
-      this.path = path;
-   }
-
-   /**
-    * Creates a new instance of the given key
-    *
-    * @param key is the key to add to the path to find a text file containing 
the factory name
-    * @return a newly created instance
-    * @throws IllegalAccessException On illegal access
-    * @throws InstantiationException On can not instantiate exception
-    * @throws IOException            On IOException
-    * @throws ClassNotFoundException When class not on class path
-    */
-   public Object newInstance(String key) throws IllegalAccessException, 
InstantiationException, IOException, ClassNotFoundException {
-      return objectFactory.create(path + key);
-   }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to