Repository: activemq-artemis
Updated Branches:
  refs/heads/master eeca06d25 -> b9e7e7ed9


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java
deleted file mode 100644
index 67cef67..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/util/ProducerThread.java
+++ /dev/null
@@ -1,344 +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.cli.commands.util;
-
-import javax.jms.BytesMessage;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.activemq.artemis.utils.ReusableLatch;
-
-public class ProducerThread extends Thread {
-
-   protected final Session session;
-
-   boolean verbose;
-   int messageCount = 1000;
-   boolean runIndefinitely = false;
-   Destination destination;
-   int sleep = 0;
-   boolean persistent = true;
-   int messageSize = 0;
-   int textMessageSize;
-   long msgTTL = 0L;
-   String msgGroupID = null;
-   int transactionBatchSize;
-
-   int transactions = 0;
-   final AtomicInteger sentCount = new AtomicInteger(0);
-   String message;
-   String messageText = null;
-   String payloadUrl = null;
-   byte[] payload = null;
-   boolean running = false;
-   final ReusableLatch finished = new ReusableLatch(1);
-   final ReusableLatch paused = new ReusableLatch(0);
-
-   public ProducerThread(Session session, Destination destination, int 
threadNr) {
-      super("Producer " + destination.toString() + ", thread=" + threadNr);
-      this.destination = destination;
-      this.session = session;
-   }
-
-   @Override
-   public void run() {
-      MessageProducer producer = null;
-      String threadName = Thread.currentThread().getName();
-      try {
-         producer = session.createProducer(destination);
-         producer.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : 
DeliveryMode.NON_PERSISTENT);
-         producer.setTimeToLive(msgTTL);
-         initPayLoad();
-         running = true;
-
-         System.out.println(threadName + " Started to calculate elapsed time 
...\n");
-         long tStart = System.currentTimeMillis();
-
-         if (runIndefinitely) {
-            while (running) {
-               paused.await();
-               sendMessage(producer, threadName);
-               sentCount.incrementAndGet();
-            }
-         } else {
-            for (sentCount.set(0); sentCount.get() < messageCount && running; 
sentCount.incrementAndGet()) {
-               paused.await();
-               sendMessage(producer, threadName);
-            }
-         }
-
-         try {
-            session.commit();
-         } catch (Throwable ignored) {
-         }
-
-         System.out.println(threadName + " Produced: " + this.getSentCount() + 
" messages");
-         long tEnd = System.currentTimeMillis();
-         long elapsed = (tEnd - tStart) / 1000;
-         System.out.println(threadName + " Elapsed time in second : " + 
elapsed + " s");
-         System.out.println(threadName + " Elapsed time in milli second : " + 
(tEnd - tStart) + " milli seconds");
-
-      } catch (Exception e) {
-         e.printStackTrace();
-      } finally {
-         if (finished != null) {
-            finished.countDown();
-         }
-         if (producer != null) {
-            try {
-               producer.close();
-            } catch (JMSException e) {
-               e.printStackTrace();
-            }
-         }
-      }
-   }
-
-   private void sendMessage(MessageProducer producer, String threadName) 
throws Exception {
-      Message message = createMessage(sentCount.get(), threadName);
-      producer.send(message);
-      if (verbose) {
-         System.out.println(threadName + " Sent: " + (message instanceof 
TextMessage ? ((TextMessage) message).getText() : message.getJMSMessageID()));
-      }
-
-      if (transactionBatchSize > 0 && sentCount.get() > 0 && sentCount.get() % 
transactionBatchSize == 0) {
-         System.out.println(threadName + " Committing transaction: " + 
transactions++);
-         session.commit();
-      }
-
-      if (sleep > 0) {
-         Thread.sleep(sleep);
-      }
-   }
-
-   private void initPayLoad() {
-      if (messageSize > 0) {
-         payload = new byte[messageSize];
-         for (int i = 0; i < payload.length; i++) {
-            payload[i] = '.';
-         }
-      }
-   }
-
-   protected Message createMessage(int i, String threadName) throws Exception {
-      Message answer;
-      if (payload != null) {
-         answer = session.createBytesMessage();
-         ((BytesMessage) answer).writeBytes(payload);
-      } else {
-         if (textMessageSize > 0) {
-            if (messageText == null) {
-               messageText = 
readInputStream(getClass().getResourceAsStream("demo.txt"), textMessageSize, i);
-            }
-         } else if (payloadUrl != null) {
-            messageText = readInputStream(new URL(payloadUrl).openStream(), 
-1, i);
-         } else if (message != null) {
-            messageText = message;
-         } else {
-            messageText = createDefaultMessage(i);
-         }
-         answer = session.createTextMessage(messageText);
-      }
-      if ((msgGroupID != null) && (!msgGroupID.isEmpty())) {
-         answer.setStringProperty("JMSXGroupID", msgGroupID);
-      }
-
-      answer.setIntProperty("count", i);
-      answer.setStringProperty("ThreadSent", threadName);
-      return answer;
-   }
-
-   private String readInputStream(InputStream is, int size, int messageNumber) 
throws IOException {
-      try (InputStreamReader reader = new InputStreamReader(is)) {
-         char[] buffer;
-         if (size > 0) {
-            buffer = new char[size];
-         } else {
-            buffer = new char[1024];
-         }
-         int count;
-         StringBuilder builder = new StringBuilder();
-         while ((count = reader.read(buffer)) != -1) {
-            builder.append(buffer, 0, count);
-            if (size > 0)
-               break;
-         }
-         return builder.toString();
-      } catch (IOException ioe) {
-         return createDefaultMessage(messageNumber);
-      }
-   }
-
-   private String createDefaultMessage(int messageNumber) {
-      return "test message: " + messageNumber;
-   }
-
-   public ProducerThread setMessageCount(int messageCount) {
-      this.messageCount = messageCount;
-      return this;
-   }
-
-   public int getSleep() {
-      return sleep;
-   }
-
-   public ProducerThread setSleep(int sleep) {
-      this.sleep = sleep;
-      return this;
-   }
-
-   public int getMessageCount() {
-      return messageCount;
-   }
-
-   public int getSentCount() {
-      return sentCount.get();
-   }
-
-   public boolean isPersistent() {
-      return persistent;
-   }
-
-   public ProducerThread setPersistent(boolean persistent) {
-      this.persistent = persistent;
-      return this;
-   }
-
-   public boolean isRunning() {
-      return running;
-   }
-
-   public ProducerThread setRunning(boolean running) {
-      this.running = running;
-      return this;
-   }
-
-   public long getMsgTTL() {
-      return msgTTL;
-   }
-
-   public ProducerThread setMsgTTL(long msgTTL) {
-      this.msgTTL = msgTTL;
-      return this;
-   }
-
-   public int getTransactionBatchSize() {
-      return transactionBatchSize;
-   }
-
-   public ProducerThread setTransactionBatchSize(int transactionBatchSize) {
-      this.transactionBatchSize = transactionBatchSize;
-      return this;
-   }
-
-   public String getMsgGroupID() {
-      return msgGroupID;
-   }
-
-   public ProducerThread setMsgGroupID(String msgGroupID) {
-      this.msgGroupID = msgGroupID;
-      return this;
-   }
-
-   public int getTextMessageSize() {
-      return textMessageSize;
-   }
-
-   public ProducerThread setTextMessageSize(int textMessageSize) {
-      this.textMessageSize = textMessageSize;
-      return this;
-   }
-
-   public int getMessageSize() {
-      return messageSize;
-   }
-
-   public ProducerThread setMessageSize(int messageSize) {
-      this.messageSize = messageSize;
-      return this;
-   }
-
-   public ReusableLatch getFinished() {
-      return finished;
-   }
-
-   public ProducerThread setFinished(int value) {
-      finished.setCount(value);
-      return this;
-   }
-
-   public String getPayloadUrl() {
-      return payloadUrl;
-   }
-
-   public ProducerThread setPayloadUrl(String payloadUrl) {
-      this.payloadUrl = payloadUrl;
-      return this;
-   }
-
-   public String getMessage() {
-      return message;
-   }
-
-   public ProducerThread setMessage(String message) {
-      this.message = message;
-      return this;
-   }
-
-   public boolean isRunIndefinitely() {
-      return runIndefinitely;
-   }
-
-   public ProducerThread setRunIndefinitely(boolean runIndefinitely) {
-      this.runIndefinitely = runIndefinitely;
-      return this;
-   }
-
-   public ProducerThread pauseProducer() {
-      this.paused.countUp();
-      return this;
-   }
-
-   public ProducerThread resumeProducer() {
-      this.paused.countDown();
-      return this;
-   }
-
-   public ProducerThread resetCounters() {
-      this.sentCount.set(0);
-      return this;
-   }
-
-   public boolean isVerbose() {
-      return verbose;
-   }
-
-   public ProducerThread setVerbose(boolean verbose) {
-      this.verbose = verbose;
-      return this;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactory.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..dc9b9e1
--- /dev/null
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactory.java
@@ -0,0 +1,73 @@
+/*
+ * 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.cli.factory;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.activemq.artemis.cli.ConfigurationException;
+import org.apache.activemq.artemis.dto.BrokerDTO;
+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 {
+
+   private static BrokerDTO createBrokerConfiguration(URI configURI,
+                                                      String artemisHome,
+                                                      String artemisInstance,
+                                                      URI artemisURIInstance) 
throws Exception {
+      if (configURI.getScheme() == null) {
+         throw new ConfigurationException("Invalid configuration URI, no 
scheme specified: " + configURI);
+      }
+
+      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) {
+         throw new ConfigurationException("Invalid configuration URI, can't 
find configuration scheme: " + configURI.getScheme());
+      }
+      return factory.createBroker(configURI, artemisHome, artemisInstance, 
artemisURIInstance);
+   }
+
+   public static BrokerDTO createBrokerConfiguration(String configuration,
+                                                     String artemisHome,
+                                                     String artemisInstance,
+                                                     URI artemisURIInstance) 
throws Exception {
+      return createBrokerConfiguration(new URI(configuration), artemisHome, 
artemisInstance, artemisURIInstance);
+   }
+
+   public static Broker createServer(ServerDTO brokerDTO, 
ActiveMQSecurityManager security) 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) {
+            throw new ConfigurationException("Invalid configuration URI, can't 
find configuration scheme: " + configURI.getScheme());
+         }
+
+         return handler.createServer(brokerDTO, security);
+      }
+      return null;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactoryHandler.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..2d16c3a
--- /dev/null
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerFactoryHandler.java
@@ -0,0 +1,26 @@
+/*
+ * 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.cli.factory;
+
+import java.net.URI;
+
+import org.apache.activemq.artemis.dto.BrokerDTO;
+
+public interface BrokerFactoryHandler {
+
+   BrokerDTO createBroker(URI brokerURI, String artemisHome, String 
artemisInstance, URI artemisURIInstance) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerHandler.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..df874a7
--- /dev/null
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/BrokerHandler.java
@@ -0,0 +1,26 @@
+/*
+ * 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.cli.factory;
+
+import org.apache.activemq.artemis.dto.ServerDTO;
+import org.apache.activemq.artemis.integration.Broker;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
+
+public interface BrokerHandler {
+
+   Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security);
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/FileBrokerHandler.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..74d1eb7
--- /dev/null
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/FileBrokerHandler.java
@@ -0,0 +1,30 @@
+/*
+ * 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.cli.factory;
+
+import org.apache.activemq.artemis.dto.ServerDTO;
+import org.apache.activemq.artemis.integration.Broker;
+import org.apache.activemq.artemis.integration.FileBroker;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
+
+public class FileBrokerHandler implements BrokerHandler {
+
+   @Override
+   public Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager 
security) {
+      return new FileBroker(brokerDTO, security);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/JaasSecurityHandler.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..a096567
--- /dev/null
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/JaasSecurityHandler.java
@@ -0,0 +1,31 @@
+/*
+ * 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.cli.factory.security;
+
+import org.apache.activemq.artemis.dto.JaasSecurityDTO;
+import org.apache.activemq.artemis.dto.SecurityDTO;
+import 
org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
+
+public class JaasSecurityHandler implements SecurityHandler {
+
+   @Override
+   public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) 
throws Exception {
+      JaasSecurityDTO jaasSecurity = (JaasSecurityDTO) security;
+      return new ActiveMQJAASSecurityManager(jaasSecurity.domain, 
jaasSecurity.certificateDomain);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityHandler.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..df90517
--- /dev/null
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityHandler.java
@@ -0,0 +1,25 @@
+/*
+ * 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.cli.factory.security;
+
+import org.apache.activemq.artemis.dto.SecurityDTO;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
+
+public interface SecurityHandler {
+
+   ActiveMQSecurityManager createSecurityManager(SecurityDTO securityDTO) 
throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerFactory.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..3ebf8c3
--- /dev/null
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/security/SecurityManagerFactory.java
@@ -0,0 +1,35 @@
+/*
+ * 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.cli.factory.security;
+
+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 {
+
+   public static ActiveMQSecurityManager create(SecurityDTO config) throws 
Exception {
+      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());
+      return securityHandler.createSecurityManager(config);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/xml/XmlBrokerFactoryHandler.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..8284252
--- /dev/null
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/factory/xml/XmlBrokerFactoryHandler.java
@@ -0,0 +1,37 @@
+/*
+ * 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.cli.factory.xml;
+
+import java.io.File;
+import java.net.URI;
+
+import org.apache.activemq.artemis.cli.ConfigurationException;
+import org.apache.activemq.artemis.cli.factory.BrokerFactoryHandler;
+import org.apache.activemq.artemis.dto.BrokerDTO;
+import org.apache.activemq.artemis.dto.XmlUtil;
+
+public class XmlBrokerFactoryHandler implements BrokerFactoryHandler {
+
+   @Override
+   public BrokerDTO createBroker(URI brokerURI, String artemisHome, String 
artemisInstance, URI artemisURIInstance) throws Exception {
+      File file = new File(brokerURI.getSchemeSpecificPart());
+      if (!file.exists()) {
+         throw new ConfigurationException("Invalid configuration URI, can't 
find file: " + file.getName());
+      }
+      return XmlUtil.decode(BrokerDTO.class, file, artemisHome, 
artemisInstance, artemisURIInstance);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java
deleted file mode 100644
index a188c61..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java
+++ /dev/null
@@ -1,82 +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.factory;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.apache.activemq.artemis.cli.ConfigurationException;
-import org.apache.activemq.artemis.dto.BrokerDTO;
-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 {
-
-   public static BrokerDTO createBrokerConfiguration(URI configURI) throws 
Exception {
-      return createBrokerConfiguration(configURI, null, null, null);
-   }
-
-   public static BrokerDTO createBrokerConfiguration(URI configURI,
-                                                     String artemisHome,
-                                                     String artemisInstance,
-                                                     URI artemisURIInstance) 
throws Exception {
-      if (configURI.getScheme() == null) {
-         throw new ConfigurationException("Invalid configuration URI, no 
scheme specified: " + configURI);
-      }
-
-      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) {
-         throw new ConfigurationException("Invalid configuration URI, can't 
find configuration scheme: " + configURI.getScheme());
-      }
-
-      return factory.createBroker(configURI, artemisHome, artemisInstance, 
artemisURIInstance);
-   }
-
-   public static BrokerDTO createBrokerConfiguration(String configuration) 
throws Exception {
-      return createBrokerConfiguration(new URI(configuration), null, null, 
null);
-   }
-
-   public static BrokerDTO createBrokerConfiguration(String configuration,
-                                                     String artemisHome,
-                                                     String artemisInstance,
-                                                     URI artemisURIInstance) 
throws Exception {
-      return createBrokerConfiguration(new URI(configuration), artemisHome, 
artemisInstance, artemisURIInstance);
-   }
-
-   public static Broker createServer(ServerDTO brokerDTO, 
ActiveMQSecurityManager security) 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) {
-            throw new ConfigurationException("Invalid configuration URI, can't 
find configuration scheme: " + configURI.getScheme());
-         }
-
-         return handler.createServer(brokerDTO, security);
-      }
-      return null;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java
deleted file mode 100644
index f81a0de..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactoryHandler.java
+++ /dev/null
@@ -1,28 +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.factory;
-
-import java.net.URI;
-
-import org.apache.activemq.artemis.dto.BrokerDTO;
-
-public interface BrokerFactoryHandler {
-
-   BrokerDTO createBroker(URI brokerURI) throws Exception;
-
-   BrokerDTO createBroker(URI brokerURI, String artemisHome, String 
artemisInstance, URI artemisURIInstance) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerHandler.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerHandler.java
deleted file mode 100644
index 3fe4027..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerHandler.java
+++ /dev/null
@@ -1,26 +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.factory;
-
-import org.apache.activemq.artemis.dto.ServerDTO;
-import org.apache.activemq.artemis.integration.Broker;
-import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
-
-public interface BrokerHandler {
-
-   Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security);
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/FileBrokerHandler.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/FileBrokerHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/FileBrokerHandler.java
deleted file mode 100644
index f6afc7f..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/FileBrokerHandler.java
+++ /dev/null
@@ -1,30 +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.factory;
-
-import org.apache.activemq.artemis.dto.ServerDTO;
-import org.apache.activemq.artemis.integration.Broker;
-import org.apache.activemq.artemis.integration.FileBroker;
-import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
-
-public class FileBrokerHandler implements BrokerHandler {
-
-   @Override
-   public Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager 
security) {
-      return new FileBroker(brokerDTO, security);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java
deleted file mode 100644
index 9f0c489..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/JaasSecurityHandler.java
+++ /dev/null
@@ -1,32 +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.factory;
-
-import org.apache.activemq.artemis.dto.JaasSecurityDTO;
-import org.apache.activemq.artemis.dto.SecurityDTO;
-import 
org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
-import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
-
-public class JaasSecurityHandler implements SecurityHandler {
-
-   @Override
-   public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) 
throws Exception {
-      JaasSecurityDTO jaasSecurity = (JaasSecurityDTO) security;
-      ActiveMQJAASSecurityManager securityManager = new 
ActiveMQJAASSecurityManager(jaasSecurity.domain, 
jaasSecurity.certificateDomain);
-      return securityManager;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityHandler.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityHandler.java
deleted file mode 100644
index 75768d0..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityHandler.java
+++ /dev/null
@@ -1,25 +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.factory;
-
-import org.apache.activemq.artemis.dto.SecurityDTO;
-import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
-
-public interface SecurityHandler {
-
-   ActiveMQSecurityManager createSecurityManager(SecurityDTO securityDTO) 
throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java
deleted file mode 100644
index 4b71029..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java
+++ /dev/null
@@ -1,37 +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.factory;
-
-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 {
-
-   public static ActiveMQSecurityManager create(SecurityDTO config) throws 
Exception {
-      if (config != null) {
-         FactoryFinder finder = new 
FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/security/");
-         SecurityHandler securityHandler = (SecurityHandler) 
finder.newInstance(config.getClass().getAnnotation(XmlRootElement.class).name());
-         return securityHandler.createSecurityManager(config);
-      } else {
-         throw new Exception("No security manager configured!");
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java
deleted file mode 100644
index 0059c06..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java
+++ /dev/null
@@ -1,41 +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.factory;
-
-import java.io.File;
-import java.net.URI;
-
-import org.apache.activemq.artemis.cli.ConfigurationException;
-import org.apache.activemq.artemis.dto.BrokerDTO;
-import org.apache.activemq.artemis.dto.XmlUtil;
-
-public class XmlBrokerFactoryHandler implements BrokerFactoryHandler {
-
-   @Override
-   public BrokerDTO createBroker(URI brokerURI) throws Exception {
-      return createBroker(brokerURI, null, null, null);
-   }
-
-   @Override
-   public BrokerDTO createBroker(URI brokerURI, String artemisHome, String 
artemisInstance, URI artemisURIInstance) throws Exception {
-      File file = new File(brokerURI.getSchemeSpecificPart());
-      if (!file.exists()) {
-         throw new ConfigurationException("Invalid configuration URI, can't 
find file: " + file.getName());
-      }
-      return XmlUtil.decode(BrokerDTO.class, file, artemisHome, 
artemisInstance, artemisURIInstance);
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java
index e112644..af2286f 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java
@@ -21,13 +21,13 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
 import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
 import org.apache.activemq.artemis.core.config.FileDeploymentManager;
 import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.server.ServiceComponent;
 import org.apache.activemq.artemis.dto.ServerDTO;
 import 
org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger;
@@ -161,7 +161,7 @@ public class FileBroker implements Broker {
    * this makes sure the components are started in the correct order. Its 
simple at the mo as e only have core and jms but
    * will need impproving if we get more.
    * */
-   public ArrayList<ActiveMQComponent> getComponentsByStartOrder(Map<String, 
ActiveMQComponent> components) {
+   private ArrayList<ActiveMQComponent> getComponentsByStartOrder(Map<String, 
ActiveMQComponent> components) {
       ArrayList<ActiveMQComponent> activeMQComponents = new ArrayList<>();
       ActiveMQComponent jmsComponent = components.get("jms");
       if (jmsComponent != null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/util/FileBasedSecStoreConfig.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/FileBasedSecStoreConfig.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/FileBasedSecStoreConfig.java
deleted file mode 100644
index c3f30b3..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/FileBasedSecStoreConfig.java
+++ /dev/null
@@ -1,222 +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.util;
-
-import org.apache.activemq.artemis.api.core.Pair;
-import org.apache.activemq.artemis.utils.StringUtil;
-import org.apache.commons.configuration2.PropertiesConfiguration;
-import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
-import org.apache.commons.configuration2.builder.fluent.Configurations;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class FileBasedSecStoreConfig {
-
-   private static final String LICENSE_HEADER =
-           "## 
---------------------------------------------------------------------------\n" +
-           "## Licensed to the Apache Software Foundation (ASF) under one or 
more\n" +
-           "## contributor license agreements.  See the NOTICE file 
distributed with\n" +
-           "## this work for additional information regarding copyright 
ownership.\n" +
-           "## The ASF licenses this file to You under the Apache License, 
Version 2.0\n" +
-           "## (the \"License\"); you may not use this file except in 
compliance with\n" +
-           "## the License.  You may obtain a copy of the License at\n" +
-           "##\n" +
-           "## http://www.apache.org/licenses/LICENSE-2.0\n"; +
-           "##\n" +
-           "## Unless required by applicable law or agreed to in writing, 
software\n" +
-           "## distributed under the License is distributed on an \"AS IS\" 
BASIS,\n" +
-           "## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.\n" +
-           "## See the License for the specific language governing permissions 
and\n" +
-           "## limitations under the License.\n" +
-           "## 
---------------------------------------------------------------------------\n";
-   private FileBasedConfigurationBuilder<PropertiesConfiguration> userBuilder;
-   private FileBasedConfigurationBuilder<PropertiesConfiguration> roleBuilder;
-   private PropertiesConfiguration userConfig;
-   private PropertiesConfiguration roleConfig;
-
-   public FileBasedSecStoreConfig(File userFile, File roleFile) throws 
Exception {
-      Configurations configs = new Configurations();
-      userBuilder = configs.propertiesBuilder(userFile);
-      roleBuilder = configs.propertiesBuilder(roleFile);
-      userConfig = userBuilder.getConfiguration();
-      roleConfig = roleBuilder.getConfiguration();
-
-      String roleHeader = roleConfig.getLayout().getHeaderComment();
-      String userHeader = userConfig.getLayout().getHeaderComment();
-
-      if (userHeader == null) {
-         if (userConfig.isEmpty()) {
-            //clean and reset header
-            userConfig.clear();
-            userConfig.setHeader(LICENSE_HEADER);
-         }
-      }
-
-      if (roleHeader == null) {
-         if (roleConfig.isEmpty()) {
-            //clean and reset header
-            roleConfig.clear();
-            roleConfig.setHeader(LICENSE_HEADER);
-         }
-      }
-   }
-
-   public void addNewUser(String username, String hash, String... roles) 
throws Exception {
-      if (userConfig.getString(username) != null) {
-         throw new IllegalArgumentException("User already exist: " + username);
-      }
-      userConfig.addProperty(username, hash);
-      addRoles(username, roles);
-   }
-
-   public void save() throws Exception {
-      userBuilder.save();
-      roleBuilder.save();
-   }
-
-   public void removeUser(String username) throws Exception {
-      if (userConfig.getProperty(username) == null) {
-         throw new IllegalArgumentException("user " + username + " doesn't 
exist.");
-      }
-      userConfig.clearProperty(username);
-      removeRoles(username);
-   }
-
-   public List<String> listUser(String username) {
-      List<String> result = new ArrayList<>();
-      result.add("--- \"user\"(roles) ---\n");
-
-      int totalUsers = 0;
-      if (username != null) {
-         String roles = findRoles(username);
-         result.add("\"" + username + "\"(" + roles + ")");
-         totalUsers++;
-      } else {
-         Iterator<String> iter = userConfig.getKeys();
-         while (iter.hasNext()) {
-            String keyUser = iter.next();
-            String roles = findRoles(keyUser);
-            result.add("\"" + keyUser + "\"(" + roles + ")");
-            totalUsers++;
-         }
-      }
-      result.add("\n Total: " + totalUsers);
-      return result;
-   }
-
-   private String findRoles(String uname) {
-      Iterator<String> iter = roleConfig.getKeys();
-      StringBuilder builder = new StringBuilder();
-      boolean first = true;
-      while (iter.hasNext()) {
-         String role = iter.next();
-         List<String> names = roleConfig.getList(String.class, role);
-         for (String value : names) {
-            //each value may be a comma separated list
-            String[] items = value.split(",");
-            for (String item : items) {
-               if (item.equals(uname)) {
-                  if (!first) {
-                     builder.append(",");
-                  }
-                  builder.append(role);
-                  first = false;
-               }
-            }
-         }
-      }
-
-      return builder.toString();
-   }
-
-   public void updateUser(String username, String password, String[] roles) {
-      String oldPassword = (String) userConfig.getProperty(username);
-      if (oldPassword == null) {
-         throw new IllegalArgumentException("user " + username + " doesn't 
exist.");
-      }
-
-      if (password != null) {
-         userConfig.setProperty(username, password);
-      }
-
-      if (roles != null && roles.length > 0) {
-
-         removeRoles(username);
-         addRoles(username, roles);
-      }
-   }
-
-   private void addRoles(String username, String[] roles) {
-      for (String role : roles) {
-         List<String> users = roleConfig.getList(String.class, role);
-         if (users == null) {
-            users = new ArrayList<>();
-         }
-         users.add(username);
-         roleConfig.setProperty(role, StringUtil.joinStringList(users, ","));
-      }
-   }
-
-   private void removeRoles(String username) {
-
-      Iterator<String> iterKeys = roleConfig.getKeys();
-
-      List<Pair<String, List<String>>> updateMap = new ArrayList<>();
-      while (iterKeys.hasNext()) {
-         String theRole = iterKeys.next();
-
-         List<String> userList = roleConfig.getList(String.class, theRole);
-         List<String> newList = new ArrayList<>();
-
-         boolean roleChaned = false;
-         for (String value : userList) {
-            //each value may be comma separated.
-            List<String> update = new ArrayList<>();
-            String[] items = value.split(",");
-            boolean found = false;
-            for (String item : items) {
-               if (!item.equals(username)) {
-                  update.add(item);
-               } else {
-                  found = true;
-                  roleChaned = true;
-               }
-            }
-            if (found) {
-               if (update.size() > 0) {
-                  newList.add(StringUtil.joinStringList(update, ","));
-               }
-            }
-         }
-         if (roleChaned) {
-            updateMap.add(new Pair(theRole, newList));
-         }
-      }
-      //do update
-      Iterator<Pair<String, List<String>>> iterUpdate = updateMap.iterator();
-      while (iterUpdate.hasNext()) {
-         Pair<String, List<String>> entry = iterUpdate.next();
-         roleConfig.clearProperty(entry.getA());
-         if (entry.getB().size() > 0) {
-            roleConfig.addProperty(entry.getA(), entry.getB());
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/util/OptionsUtil.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/OptionsUtil.java 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/OptionsUtil.java
deleted file mode 100644
index ae0aba3..0000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/OptionsUtil.java
+++ /dev/null
@@ -1,67 +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.util;
-
-import io.airlift.airline.Option;
-import org.apache.activemq.artemis.cli.commands.Action;
-import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
-
-import java.lang.reflect.Field;
-import java.util.HashSet;
-import java.util.Set;
-
-public class OptionsUtil {
-
-   public static void findAllOptions(Set<String> options, Class<? extends 
Action> command) {
-      for (Field field  : command.getDeclaredFields()) {
-         if (field.isAnnotationPresent(Option.class)) {
-            Option annotation = field.getAnnotation(Option.class);
-            String[] names = annotation.name();
-            for (String n : names) {
-               options.add(n);
-            }
-         }
-      }
-      Class parent = command.getSuperclass();
-      if (Action.class.isAssignableFrom(parent)) {
-         findAllOptions(options, parent);
-      }
-   }
-
-   public static Set<String> findCommandOptions(Class<? extends Action> 
command) {
-      Set<String> options = new HashSet<>();
-      findAllOptions(options, command);
-
-      return options;
-   }
-
-   public static void checkCommandOptions(Class<? extends Action> cmdClass, 
String[] options) throws InvalidOptionsError {
-      Set<String> definedOptions = OptionsUtil.findCommandOptions(cmdClass);
-      for (String opt : options) {
-         if (opt.startsWith("--") && !"--".equals(opt.trim())) {
-            int index = opt.indexOf("=");
-            if (index > 0) {
-               opt = opt.substring(0, index);
-            }
-            if (!definedOptions.contains(opt)) {
-               throw new InvalidOptionsError("Found unexpected parameters: [" 
+ opt + "]");
-            }
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java
index 405e777..0a22d0f 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java
@@ -40,10 +40,9 @@ public class ServerUtil {
    }
 
    /**
-    *
     * @param artemisInstance
-    * @param serverName it will be used on logs
-    * @param id it will be used to add on the port
+    * @param serverName      it will be used on logs
+    * @param id              it will be used to add on the port
     * @param timeout
     * @return
     * @throws Exception
@@ -94,7 +93,8 @@ public class ServerUtil {
          try (ActiveMQConnectionFactory cf = 
ActiveMQJMSClient.createConnectionFactory(uri, null)) {
             cf.createConnection().close();
             System.out.println("server " + uri + " started");
-         } catch (Exception e) {
+         }
+         catch (Exception e) {
             System.out.println("awaiting server " + uri + " start at ");
             Thread.sleep(500);
             continue;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/jaas-security
----------------------------------------------------------------------
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
index 013a63c..b05ff70 100644
--- 
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
@@ -14,4 +14,4 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.factory.JaasSecurityHandler
+class=org.apache.activemq.artemis.cli.factory.security.JaasSecurityHandler

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/server/file
----------------------------------------------------------------------
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
index 26ec4fb..59419dd 100644
--- 
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
@@ -14,4 +14,4 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.factory.FileBrokerHandler
+class=org.apache.activemq.artemis.cli.factory.FileBrokerHandler

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/xml
----------------------------------------------------------------------
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
index 28251ef..4f7943d 100644
--- 
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
@@ -14,4 +14,4 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
-class=org.apache.activemq.artemis.factory.XmlBrokerFactoryHandler
+class=org.apache.activemq.artemis.cli.factory.xml.XmlBrokerFactoryHandler

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/ExportFormatTest.java
----------------------------------------------------------------------
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/ExportFormatTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/ExportFormatTest.java
index 16cedd2..c09218b 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/ExportFormatTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/ExportFormatTest.java
@@ -24,8 +24,8 @@ import 
org.apache.activemq.artemis.api.core.client.ClientProducer;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
-import org.apache.activemq.artemis.cli.commands.tools.DecodeJournal;
-import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal;
+import org.apache.activemq.artemis.cli.commands.tools.journal.DecodeJournal;
+import org.apache.activemq.artemis.cli.commands.tools.journal.EncodeJournal;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.junit.Ignore;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java
----------------------------------------------------------------------
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java
index 16f6462..790ed82 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/XmlImportExportTest.java
@@ -32,6 +32,7 @@ import java.util.Set;
 import java.util.UUID;
 
 import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
@@ -42,14 +43,13 @@ import 
org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter;
-import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter;
+import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter;
+import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataImporter;
 import 
org.apache.activemq.artemis.core.persistence.impl.journal.BatchingIDGenerator;
 import 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
 import 
org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl;
 import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.server.JMSServerManager;
 import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/XmlImportExportStressTest.java
----------------------------------------------------------------------
diff --git 
a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/XmlImportExportStressTest.java
 
b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/XmlImportExportStressTest.java
index 9c733ac..e73687b 100644
--- 
a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/XmlImportExportStressTest.java
+++ 
b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/journal/XmlImportExportStressTest.java
@@ -27,8 +27,8 @@ import 
org.apache.activemq.artemis.api.core.client.ClientProducer;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.api.core.client.ServerLocator;
-import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter;
-import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter;
+import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter;
+import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataImporter;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f82623a2/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java
----------------------------------------------------------------------
diff --git 
a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java
 
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java
index e5650cb..b22881d 100644
--- 
a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java
+++ 
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java
@@ -27,8 +27,8 @@ import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
 
-import org.apache.activemq.artemis.cli.commands.tools.DecodeJournal;
-import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal;
+import org.apache.activemq.artemis.cli.commands.tools.journal.DecodeJournal;
+import org.apache.activemq.artemis.cli.commands.tools.journal.EncodeJournal;
 import org.apache.activemq.artemis.core.io.SequentialFileFactory;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;

Reply via email to