You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2015/05/04 17:30:36 UTC
[05/11] activemq-artemis git commit: Moving artemis-tools to
artemis-cli and improving the tooling
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java
new file mode 100644
index 0000000..9af1cd8
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataImporter.java
@@ -0,0 +1,1093 @@
+/**
+ * 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.tools;
+
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import io.airlift.command.Arguments;
+import io.airlift.command.Command;
+import io.airlift.command.Option;
+import org.apache.activemq.artemis.cli.commands.Action;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.api.core.Message;
+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;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.apache.activemq.artemis.api.core.client.ClientProducer;
+import org.apache.activemq.artemis.api.core.client.ClientRequestor;
+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.core.management.ManagementHelper;
+import org.apache.activemq.artemis.api.core.management.ResourceNames;
+import org.apache.activemq.artemis.core.message.impl.MessageImpl;
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
+import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
+import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
+import org.apache.activemq.artemis.utils.Base64;
+import org.apache.activemq.artemis.utils.UUIDGenerator;
+
+/**
+ * Read XML output from <code>org.apache.activemq.artemis.core.persistence.impl.journal.XmlDataExporter</code>, create a core session, and
+ * send the messages to a running instance of ActiveMQ. It uses the StAX <code>javax.xml.stream.XMLStreamReader</code>
+ * for speed and simplicity.
+ */
+@Command(name = "imp", description = "Import all message-data using an XML that could be interpreted by any system.")
+public final class XmlDataImporter implements Action
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private XMLStreamReader reader;
+
+ // this session is really only needed if the "session" variable does not auto-commit sends
+ ClientSession managementSession;
+
+ boolean localSession;
+
+ final Map<String, String> addressMap = new HashMap<>();
+
+ final Map<String, Long> queueIDs = new HashMap<>();
+
+ String tempFileName = "";
+
+ private ClientSession session;
+
+ @Option(name = "--host", description = "The host used to import the data (default localhost)")
+ public String host = "localhost";
+
+ @Option(name = "--port", description = "The port used to import the data (default 61616)")
+ public int port = 61616;
+
+ @Option(name = "--transaction", description = "If this is set to true you will need a whole transaction to commit at the end. (default false)")
+ public boolean transactional;
+
+ @Option(name = "--user", description = "User name used to import the data. (default null)")
+ public String user = null;
+
+ @Option(name = "--password", description = "User name used to import the data. (default null)")
+ public String password = null;
+
+ @Arguments(description = "The input file name (default=exp.dmp)", required = true)
+ public String input;
+
+
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+
+ public String getUser()
+ {
+ return user;
+ }
+
+ public void setUser(String user)
+ {
+ this.user = user;
+ }
+
+
+ @Override
+ public Object execute(ActionContext context) throws Exception
+ {
+ process(input, host, port, transactional);
+ return null;
+ }
+
+ public void process(String inputFile, String host, int port, boolean transactional) throws Exception
+ {
+ this.process(new FileInputStream(inputFile), host, port, transactional);
+ }
+
+ /**
+ * This is the normal constructor for programmatic access to the
+ * <code>org.apache.activemq.artemis.core.persistence.impl.journal.XmlDataImporter</code> if the session passed
+ * in uses auto-commit for sends.
+ * <p/>
+ * If the session needs to be transactional then use the constructor which takes 2 sessions.
+ *
+ * @param inputStream the stream from which to read the XML for import
+ * @param session used for sending messages, must use auto-commit for sends
+ * @throws Exception
+ */
+ public void process(InputStream inputStream, ClientSession session) throws Exception
+ {
+ this.process(inputStream, session, null);
+ }
+
+ /**
+ * This is the constructor to use if you wish to import all messages transactionally.
+ * <p/>
+ * Pass in a session which doesn't use auto-commit for sends, and one that does (for management
+ * operations necessary during import).
+ *
+ * @param inputStream the stream from which to read the XML for import
+ * @param session used for sending messages, doesn't need to auto-commit sends
+ * @param managementSession used for management queries, must use auto-commit for sends
+ */
+ public void process(InputStream inputStream, ClientSession session, ClientSession managementSession) throws Exception
+ {
+ reader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
+ this.session = session;
+ if (managementSession != null)
+ {
+ this.managementSession = managementSession;
+ }
+ else
+ {
+ this.managementSession = session;
+ }
+ localSession = false;
+
+
+ processXml();
+
+ }
+
+ public void process(InputStream inputStream, String host, int port, boolean transactional) throws Exception
+ {
+ reader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
+ HashMap<String, Object> connectionParams = new HashMap<>();
+ connectionParams.put(TransportConstants.HOST_PROP_NAME, host);
+ connectionParams.put(TransportConstants.PORT_PROP_NAME, Integer.toString(port));
+ ServerLocator serverLocator =
+ ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(
+ NettyConnectorFactory.class.getName(),
+ connectionParams));
+ ClientSessionFactory sf = serverLocator.createSessionFactory();
+
+ if (user != null || password != null)
+ {
+ session = sf.createSession(user, password, false, !transactional, true, false, 0);
+ managementSession = sf.createSession(user, password, false, true, true, false, 0);
+ }
+ else
+ {
+ session = sf.createSession(false, !transactional, true);
+ managementSession = sf.createSession(false, true, true);
+ }
+ localSession = true;
+
+ processXml();
+ }
+
+ private void processXml() throws Exception
+ {
+ try
+ {
+ while (reader.hasNext())
+ {
+ ActiveMQServerLogger.LOGGER.debug("EVENT:[" + reader.getLocation().getLineNumber() + "][" + reader.getLocation().getColumnNumber() + "] ");
+ if (reader.getEventType() == XMLStreamConstants.START_ELEMENT)
+ {
+ if (XmlDataConstants.BINDINGS_CHILD.equals(reader.getLocalName()))
+ {
+ bindQueue();
+ }
+ else if (XmlDataConstants.MESSAGES_CHILD.equals(reader.getLocalName()))
+ {
+ processMessage();
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORIES.equals(reader.getLocalName()))
+ {
+ createJmsConnectionFactories();
+ }
+ else if (XmlDataConstants.JMS_DESTINATIONS.equals(reader.getLocalName()))
+ {
+ createJmsDestinations();
+ }
+ }
+ reader.next();
+ }
+
+ if (!session.isAutoCommitSends())
+ {
+ session.commit();
+ }
+ }
+ finally
+ {
+ // if the session was created in our constructor then close it (otherwise the caller will close it)
+ if (localSession)
+ {
+ session.close();
+ managementSession.close();
+ }
+ }
+ }
+
+ private void processMessage() throws Exception
+ {
+ Byte type = 0;
+ Byte priority = 0;
+ Long expiration = 0L;
+ Long timestamp = 0L;
+ org.apache.activemq.artemis.utils.UUID userId = null;
+ ArrayList<String> queues = new ArrayList<>();
+
+ // get message's attributes
+ for (int i = 0; i < reader.getAttributeCount(); i++)
+ {
+ String attributeName = reader.getAttributeLocalName(i);
+ switch (attributeName)
+ {
+ case XmlDataConstants.MESSAGE_TYPE:
+ type = getMessageType(reader.getAttributeValue(i));
+ break;
+ case XmlDataConstants.MESSAGE_PRIORITY:
+ priority = Byte.parseByte(reader.getAttributeValue(i));
+ break;
+ case XmlDataConstants.MESSAGE_EXPIRATION:
+ expiration = Long.parseLong(reader.getAttributeValue(i));
+ break;
+ case XmlDataConstants.MESSAGE_TIMESTAMP:
+ timestamp = Long.parseLong(reader.getAttributeValue(i));
+ break;
+ case XmlDataConstants.MESSAGE_USER_ID:
+ userId = UUIDGenerator.getInstance().generateUUID();
+ break;
+ }
+ }
+
+ Message message = session.createMessage(type, true, expiration, timestamp, priority);
+ message.setUserID(userId);
+
+ boolean endLoop = false;
+
+ // loop through the XML and gather up all the message's data (i.e. body, properties, queues, etc.)
+ while (reader.hasNext())
+ {
+ int eventType = reader.getEventType();
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ if (XmlDataConstants.MESSAGE_BODY.equals(reader.getLocalName()))
+ {
+ processMessageBody(message);
+ }
+ else if (XmlDataConstants.PROPERTIES_CHILD.equals(reader.getLocalName()))
+ {
+ processMessageProperties(message);
+ }
+ else if (XmlDataConstants.QUEUES_CHILD.equals(reader.getLocalName()))
+ {
+ processMessageQueues(queues);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (XmlDataConstants.MESSAGES_CHILD.equals(reader.getLocalName()))
+ {
+ endLoop = true;
+ }
+ break;
+ }
+ if (endLoop)
+ {
+ break;
+ }
+ reader.next();
+ }
+
+ sendMessage(queues, message);
+ }
+
+ private Byte getMessageType(String value)
+ {
+ Byte type = Message.DEFAULT_TYPE;
+ switch (value)
+ {
+ case XmlDataConstants.DEFAULT_TYPE_PRETTY:
+ type = Message.DEFAULT_TYPE;
+ break;
+ case XmlDataConstants.BYTES_TYPE_PRETTY:
+ type = Message.BYTES_TYPE;
+ break;
+ case XmlDataConstants.MAP_TYPE_PRETTY:
+ type = Message.MAP_TYPE;
+ break;
+ case XmlDataConstants.OBJECT_TYPE_PRETTY:
+ type = Message.OBJECT_TYPE;
+ break;
+ case XmlDataConstants.STREAM_TYPE_PRETTY:
+ type = Message.STREAM_TYPE;
+ break;
+ case XmlDataConstants.TEXT_TYPE_PRETTY:
+ type = Message.TEXT_TYPE;
+ break;
+ }
+ return type;
+ }
+
+ private void sendMessage(ArrayList<String> queues, Message message) throws Exception
+ {
+ StringBuilder logMessage = new StringBuilder();
+ String destination = addressMap.get(queues.get(0));
+
+ logMessage.append("Sending ").append(message).append(" to address: ").append(destination).append("; routed to queues: ");
+ ByteBuffer buffer = ByteBuffer.allocate(queues.size() * 8);
+
+ for (String queue : queues)
+ {
+ long queueID;
+
+ if (queueIDs.containsKey(queue))
+ {
+ queueID = queueIDs.get(queue);
+ }
+ else
+ {
+ // Get the ID of the queues involved so the message can be routed properly. This is done because we cannot
+ // send directly to a queue, we have to send to an address instead but not all the queues related to the
+ // address may need the message
+ ClientRequestor requestor = new ClientRequestor(managementSession, "jms.queue.activemq.management");
+ ClientMessage managementMessage = managementSession.createMessage(false);
+ ManagementHelper.putAttribute(managementMessage, "core.queue." + queue, "ID");
+ managementSession.start();
+ ActiveMQServerLogger.LOGGER.debug("Requesting ID for: " + queue);
+ ClientMessage reply = requestor.request(managementMessage);
+ queueID = (Integer) ManagementHelper.getResult(reply);
+ requestor.close();
+ ActiveMQServerLogger.LOGGER.debug("ID for " + queue + " is: " + queueID);
+ queueIDs.put(queue, queueID); // store it so we don't have to look it up every time
+ }
+
+ logMessage.append(queue).append(", ");
+ buffer.putLong(queueID);
+ }
+
+ logMessage.delete(logMessage.length() - 2, logMessage.length()); // take off the trailing comma
+ ActiveMQServerLogger.LOGGER.debug(logMessage);
+
+ message.putBytesProperty(MessageImpl.HDR_ROUTE_TO_IDS, buffer.array());
+ ClientProducer producer = session.createProducer(destination);
+ producer.send(message);
+ producer.close();
+
+ if (tempFileName.length() > 0)
+ {
+ File tempFile = new File(tempFileName);
+ if (!tempFile.delete())
+ {
+ ActiveMQServerLogger.LOGGER.warn("Could not delete: " + tempFileName);
+ }
+ tempFileName = "";
+ }
+ }
+
+ private void processMessageQueues(ArrayList<String> queues)
+ {
+ for (int i = 0; i < reader.getAttributeCount(); i++)
+ {
+ if (XmlDataConstants.QUEUE_NAME.equals(reader.getAttributeLocalName(i)))
+ {
+ queues.add(reader.getAttributeValue(i));
+ }
+ }
+ }
+
+ private void processMessageProperties(Message message)
+ {
+ String key = "";
+ String value = "";
+ String propertyType = "";
+ String realValue = null;
+
+ for (int i = 0; i < reader.getAttributeCount(); i++)
+ {
+ String attributeName = reader.getAttributeLocalName(i);
+ switch (attributeName)
+ {
+ case XmlDataConstants.PROPERTY_NAME:
+ key = reader.getAttributeValue(i);
+ break;
+ case XmlDataConstants.PROPERTY_VALUE:
+ value = reader.getAttributeValue(i);
+ break;
+ case XmlDataConstants.PROPERTY_TYPE:
+ propertyType = reader.getAttributeValue(i);
+ break;
+ }
+ }
+
+ switch (propertyType)
+ {
+ case XmlDataConstants.PROPERTY_TYPE_SHORT:
+ message.putShortProperty(key, Short.parseShort(value));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_BOOLEAN:
+ message.putBooleanProperty(key, Boolean.parseBoolean(value));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_BYTE:
+ message.putByteProperty(key, Byte.parseByte(value));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_BYTES:
+ message.putBytesProperty(key, decode(value));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_DOUBLE:
+ message.putDoubleProperty(key, Double.parseDouble(value));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_FLOAT:
+ message.putFloatProperty(key, Float.parseFloat(value));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_INTEGER:
+ message.putIntProperty(key, Integer.parseInt(value));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_LONG:
+ message.putLongProperty(key, Long.parseLong(value));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_SIMPLE_STRING:
+ if (!value.equals(XmlDataConstants.NULL))
+ {
+ realValue = value;
+ }
+ message.putStringProperty(new SimpleString(key), new SimpleString(realValue));
+ break;
+ case XmlDataConstants.PROPERTY_TYPE_STRING:
+ if (!value.equals(XmlDataConstants.NULL))
+ {
+ realValue = value;
+ }
+ message.putStringProperty(key, realValue);
+ break;
+ }
+ }
+
+ private void processMessageBody(Message message) throws XMLStreamException, IOException
+ {
+ boolean isLarge = false;
+
+ for (int i = 0; i < reader.getAttributeCount(); i++)
+ {
+ String attributeName = reader.getAttributeLocalName(i);
+ if (XmlDataConstants.MESSAGE_IS_LARGE.equals(attributeName))
+ {
+ isLarge = Boolean.parseBoolean(reader.getAttributeValue(i));
+ }
+ }
+ reader.next();
+ if (isLarge)
+ {
+ tempFileName = UUID.randomUUID().toString() + ".tmp";
+ ActiveMQServerLogger.LOGGER.debug("Creating temp file " + tempFileName + " for large message.");
+ try (OutputStream out = new FileOutputStream(tempFileName))
+ {
+ while (reader.hasNext())
+ {
+ if (reader.getEventType() == XMLStreamConstants.END_ELEMENT)
+ {
+ break;
+ }
+ else
+ {
+ String characters = new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength());
+ String trimmedCharacters = characters.trim();
+ if (trimmedCharacters.length() > 0) // this will skip "indentation" characters
+ {
+ byte[] data = decode(trimmedCharacters);
+ out.write(data);
+ }
+ }
+ reader.next();
+ }
+ }
+ FileInputStream fileInputStream = new FileInputStream(tempFileName);
+ BufferedInputStream bufferedInput = new BufferedInputStream(fileInputStream);
+ ((ClientMessage) message).setBodyInputStream(bufferedInput);
+ }
+ else
+ {
+ reader.next(); // step past the "indentation" characters to get to the CDATA with the message body
+ String characters = new String(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength());
+ message.getBodyBuffer().writeBytes(decode(characters.trim()));
+ }
+ }
+
+ private void bindQueue() throws Exception
+ {
+ String queueName = "";
+ String address = "";
+ String filter = "";
+
+ for (int i = 0; i < reader.getAttributeCount(); i++)
+ {
+ String attributeName = reader.getAttributeLocalName(i);
+ switch (attributeName)
+ {
+ case XmlDataConstants.BINDING_ADDRESS:
+ address = reader.getAttributeValue(i);
+ break;
+ case XmlDataConstants.BINDING_QUEUE_NAME:
+ queueName = reader.getAttributeValue(i);
+ break;
+ case XmlDataConstants.BINDING_FILTER_STRING:
+ filter = reader.getAttributeValue(i);
+ break;
+ }
+ }
+
+ ClientSession.QueueQuery queueQuery = session.queueQuery(new SimpleString(queueName));
+
+ if (!queueQuery.isExists())
+ {
+ session.createQueue(address, queueName, filter, true);
+ ActiveMQServerLogger.LOGGER.debug("Binding queue(name=" + queueName + ", address=" + address + ", filter=" + filter + ")");
+ }
+ else
+ {
+ ActiveMQServerLogger.LOGGER.debug("Binding " + queueName + " already exists so won't re-bind.");
+ }
+
+ addressMap.put(queueName, address);
+ }
+
+ private void createJmsConnectionFactories() throws Exception
+ {
+ boolean endLoop = false;
+
+ while (reader.hasNext())
+ {
+ int eventType = reader.getEventType();
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ if (XmlDataConstants.JMS_CONNECTION_FACTORY.equals(reader.getLocalName()))
+ {
+ createJmsConnectionFactory();
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (XmlDataConstants.JMS_CONNECTION_FACTORIES.equals(reader.getLocalName()))
+ {
+ endLoop = true;
+ }
+ break;
+ }
+ if (endLoop)
+ {
+ break;
+ }
+ reader.next();
+ }
+ }
+
+ private void createJmsDestinations() throws Exception
+ {
+ boolean endLoop = false;
+
+ while (reader.hasNext())
+ {
+ int eventType = reader.getEventType();
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ if (XmlDataConstants.JMS_DESTINATION.equals(reader.getLocalName()))
+ {
+ createJmsDestination();
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (XmlDataConstants.JMS_DESTINATIONS.equals(reader.getLocalName()))
+ {
+ endLoop = true;
+ }
+ break;
+ }
+ if (endLoop)
+ {
+ break;
+ }
+ reader.next();
+ }
+ }
+
+ private void createJmsConnectionFactory() throws Exception
+ {
+ String name = "";
+ String callFailoverTimeout = "";
+ String callTimeout = "";
+ String clientFailureCheckPeriod = "";
+ String clientId = "";
+ String confirmationWindowSize = "";
+ String connectionTtl = "";
+ String connectors = "";
+ String consumerMaxRate = "";
+ String consumerWindowSize = "";
+ String discoveryGroupName = "";
+ String dupsOkBatchSize = "";
+ String groupId = "";
+ String loadBalancingPolicyClassName = "";
+ String maxRetryInterval = "";
+ String minLargeMessageSize = "";
+ String producerMaxRate = "";
+ String producerWindowSize = "";
+ String reconnectAttempts = "";
+ String retryInterval = "";
+ String retryIntervalMultiplier = "";
+ String scheduledThreadMaxPoolSize = "";
+ String threadMaxPoolSize = "";
+ String transactionBatchSize = "";
+ String type = "";
+ String entries = "";
+ String autoGroup = "";
+ String blockOnAcknowledge = "";
+ String blockOnDurableSend = "";
+ String blockOnNonDurableSend = "";
+ String cacheLargeMessagesClient = "";
+ String compressLargeMessages = "";
+ String failoverOnInitialConnection = "";
+ String ha = "";
+ String preacknowledge = "";
+ String useGlobalPools = "";
+
+ boolean endLoop = false;
+
+ while (reader.hasNext())
+ {
+ int eventType = reader.getEventType();
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ if (XmlDataConstants.JMS_CONNECTION_FACTORY_CALL_FAILOVER_TIMEOUT.equals(reader.getLocalName()))
+ {
+ callFailoverTimeout = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory callFailoverTimeout: " + callFailoverTimeout);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CALL_TIMEOUT.equals(reader.getLocalName()))
+ {
+ callTimeout = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory callTimeout: " + callTimeout);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_FAILURE_CHECK_PERIOD.equals(reader.getLocalName()))
+ {
+ clientFailureCheckPeriod = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory clientFailureCheckPeriod: " + clientFailureCheckPeriod);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CLIENT_ID.equals(reader.getLocalName()))
+ {
+ clientId = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory clientId: " + clientId);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONFIRMATION_WINDOW_SIZE.equals(reader.getLocalName()))
+ {
+ confirmationWindowSize = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory confirmationWindowSize: " + confirmationWindowSize);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTION_TTL.equals(reader.getLocalName()))
+ {
+ connectionTtl = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory connectionTtl: " + connectionTtl);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTOR.equals(reader.getLocalName()))
+ {
+ connectors = getConnectors();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory getLocalName: " + connectors);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_MAX_RATE.equals(reader.getLocalName()))
+ {
+ consumerMaxRate = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory consumerMaxRate: " + consumerMaxRate);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONSUMER_WINDOW_SIZE.equals(reader.getLocalName()))
+ {
+ consumerWindowSize = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory consumerWindowSize: " + consumerWindowSize);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DISCOVERY_GROUP_NAME.equals(reader.getLocalName()))
+ {
+ discoveryGroupName = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory discoveryGroupName: " + discoveryGroupName);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_DUPS_OK_BATCH_SIZE.equals(reader.getLocalName()))
+ {
+ dupsOkBatchSize = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory dupsOkBatchSize: " + dupsOkBatchSize);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_GROUP_ID.equals(reader.getLocalName()))
+ {
+ groupId = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory groupId: " + groupId);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_LOAD_BALANCING_POLICY_CLASS_NAME.equals(reader.getLocalName()))
+ {
+ loadBalancingPolicyClassName = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory loadBalancingPolicyClassName: " + loadBalancingPolicyClassName);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MAX_RETRY_INTERVAL.equals(reader.getLocalName()))
+ {
+ maxRetryInterval = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory maxRetryInterval: " + maxRetryInterval);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_MIN_LARGE_MESSAGE_SIZE.equals(reader.getLocalName()))
+ {
+ minLargeMessageSize = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory minLargeMessageSize: " + minLargeMessageSize);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_NAME.equals(reader.getLocalName()))
+ {
+ name = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory name: " + name);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_MAX_RATE.equals(reader.getLocalName()))
+ {
+ producerMaxRate = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory producerMaxRate: " + producerMaxRate);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PRODUCER_WINDOW_SIZE.equals(reader.getLocalName()))
+ {
+ producerWindowSize = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory producerWindowSize: " + producerWindowSize);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RECONNECT_ATTEMPTS.equals(reader.getLocalName()))
+ {
+ reconnectAttempts = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory reconnectAttempts: " + reconnectAttempts);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL.equals(reader.getLocalName()))
+ {
+ retryInterval = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory retryInterval: " + retryInterval);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_RETRY_INTERVAL_MULTIPLIER.equals(reader.getLocalName()))
+ {
+ retryIntervalMultiplier = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory retryIntervalMultiplier: " + retryIntervalMultiplier);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_SCHEDULED_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName()))
+ {
+ scheduledThreadMaxPoolSize = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory scheduledThreadMaxPoolSize: " + scheduledThreadMaxPoolSize);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_THREAD_POOL_MAX_SIZE.equals(reader.getLocalName()))
+ {
+ threadMaxPoolSize = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory threadMaxPoolSize: " + threadMaxPoolSize);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TRANSACTION_BATCH_SIZE.equals(reader.getLocalName()))
+ {
+ transactionBatchSize = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory transactionBatchSize: " + transactionBatchSize);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_TYPE.equals(reader.getLocalName()))
+ {
+ type = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory type: " + type);
+ }
+ else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName()))
+ {
+ entries = getEntries();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory entries: " + entries);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_AUTO_GROUP.equals(reader.getLocalName()))
+ {
+ autoGroup = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory autoGroup: " + autoGroup);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_ACKNOWLEDGE.equals(reader.getLocalName()))
+ {
+ blockOnAcknowledge = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory blockOnAcknowledge: " + blockOnAcknowledge);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_DURABLE_SEND.equals(reader.getLocalName()))
+ {
+ blockOnDurableSend = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory blockOnDurableSend: " + blockOnDurableSend);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_BLOCK_ON_NON_DURABLE_SEND.equals(reader.getLocalName()))
+ {
+ blockOnNonDurableSend = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory blockOnNonDurableSend: " + blockOnNonDurableSend);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_CACHE_LARGE_MESSAGES_CLIENT.equals(reader.getLocalName()))
+ {
+ cacheLargeMessagesClient = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.info("JMS connection factory " + name + " cacheLargeMessagesClient: " + cacheLargeMessagesClient);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_COMPRESS_LARGE_MESSAGES.equals(reader.getLocalName()))
+ {
+ compressLargeMessages = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory compressLargeMessages: " + compressLargeMessages);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_FAILOVER_ON_INITIAL_CONNECTION.equals(reader.getLocalName()))
+ {
+ failoverOnInitialConnection = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory failoverOnInitialConnection: " + failoverOnInitialConnection);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_HA.equals(reader.getLocalName()))
+ {
+ ha = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory ha: " + ha);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_PREACKNOWLEDGE.equals(reader.getLocalName()))
+ {
+ preacknowledge = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory preacknowledge: " + preacknowledge);
+ }
+ else if (XmlDataConstants.JMS_CONNECTION_FACTORY_USE_GLOBAL_POOLS.equals(reader.getLocalName()))
+ {
+ useGlobalPools = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS connection factory useGlobalPools: " + useGlobalPools);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (XmlDataConstants.JMS_CONNECTION_FACTORY.equals(reader.getLocalName()))
+ {
+ endLoop = true;
+ }
+ break;
+ }
+ if (endLoop)
+ {
+ break;
+ }
+ reader.next();
+ }
+
+ ClientRequestor requestor = new ClientRequestor(managementSession, "jms.queue.activemq.management");
+ ClientMessage managementMessage = managementSession.createMessage(false);
+ ManagementHelper.putOperationInvocation(managementMessage,
+ ResourceNames.JMS_SERVER,
+ "createConnectionFactory",
+ name,
+ Boolean.parseBoolean(ha),
+ discoveryGroupName.length() > 0,
+ Integer.parseInt(type),
+ connectors,
+ entries,
+ clientId,
+ Long.parseLong(clientFailureCheckPeriod),
+ Long.parseLong(connectionTtl),
+ Long.parseLong(callTimeout),
+ Long.parseLong(callFailoverTimeout),
+ Integer.parseInt(minLargeMessageSize),
+ Boolean.parseBoolean(compressLargeMessages),
+ Integer.parseInt(consumerWindowSize),
+ Integer.parseInt(consumerMaxRate),
+ Integer.parseInt(confirmationWindowSize),
+ Integer.parseInt(producerWindowSize),
+ Integer.parseInt(producerMaxRate),
+ Boolean.parseBoolean(blockOnAcknowledge),
+ Boolean.parseBoolean(blockOnDurableSend),
+ Boolean.parseBoolean(blockOnNonDurableSend),
+ Boolean.parseBoolean(autoGroup),
+ Boolean.parseBoolean(preacknowledge),
+ loadBalancingPolicyClassName,
+ Integer.parseInt(transactionBatchSize),
+ Integer.parseInt(dupsOkBatchSize),
+ Boolean.parseBoolean(useGlobalPools),
+ Integer.parseInt(scheduledThreadMaxPoolSize),
+ Integer.parseInt(threadMaxPoolSize),
+ Long.parseLong(retryInterval),
+ Double.parseDouble(retryIntervalMultiplier),
+ Long.parseLong(maxRetryInterval),
+ Integer.parseInt(reconnectAttempts),
+ Boolean.parseBoolean(failoverOnInitialConnection),
+ groupId);
+ //Boolean.parseBoolean(cacheLargeMessagesClient));
+ managementSession.start();
+ ClientMessage reply = requestor.request(managementMessage);
+ if (ManagementHelper.hasOperationSucceeded(reply))
+ {
+ ActiveMQServerLogger.LOGGER.debug("Created connection factory " + name);
+ }
+ else
+ {
+ ActiveMQServerLogger.LOGGER.error("Problem creating " + name);
+ }
+
+ requestor.close();
+ }
+
+ private void createJmsDestination() throws Exception
+ {
+ String name = "";
+ String selector = "";
+ String entries = "";
+ String type = "";
+ boolean endLoop = false;
+
+ while (reader.hasNext())
+ {
+ int eventType = reader.getEventType();
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ if (XmlDataConstants.JMS_DESTINATION_NAME.equals(reader.getLocalName()))
+ {
+ name = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS destination name: " + name);
+ }
+ else if (XmlDataConstants.JMS_DESTINATION_SELECTOR.equals(reader.getLocalName()))
+ {
+ selector = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS destination selector: " + selector);
+ }
+ else if (XmlDataConstants.JMS_DESTINATION_TYPE.equals(reader.getLocalName()))
+ {
+ type = reader.getElementText();
+ ActiveMQServerLogger.LOGGER.debug("JMS destination type: " + type);
+ }
+ else if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName()))
+ {
+ entries = getEntries();
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (XmlDataConstants.JMS_DESTINATION.equals(reader.getLocalName()))
+ {
+ endLoop = true;
+ }
+ break;
+ }
+ if (endLoop)
+ {
+ break;
+ }
+ reader.next();
+ }
+
+ ClientRequestor requestor = new ClientRequestor(managementSession, "jms.queue.activemq.management");
+ ClientMessage managementMessage = managementSession.createMessage(false);
+ if ("Queue".equals(type))
+ {
+ ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createQueue", name, entries, selector);
+ }
+ else if ("Topic".equals(type))
+ {
+ ManagementHelper.putOperationInvocation(managementMessage, ResourceNames.JMS_SERVER, "createTopic", name, entries);
+ }
+ managementSession.start();
+ ClientMessage reply = requestor.request(managementMessage);
+ if (ManagementHelper.hasOperationSucceeded(reply))
+ {
+ ActiveMQServerLogger.LOGGER.debug("Created " + type.toLowerCase() + " " + name);
+ }
+ else
+ {
+ ActiveMQServerLogger.LOGGER.error("Problem creating " + name);
+ }
+
+ requestor.close();
+ }
+
+ private String getEntries() throws Exception
+ {
+ StringBuilder entry = new StringBuilder();
+ boolean endLoop = false;
+
+ while (reader.hasNext())
+ {
+ int eventType = reader.getEventType();
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ if (XmlDataConstants.JMS_JNDI_ENTRY.equals(reader.getLocalName()))
+ {
+ String elementText = reader.getElementText();
+ entry.append(elementText).append(", ");
+ ActiveMQServerLogger.LOGGER.debug("JMS admin object JNDI entry: " + entry.toString());
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName()))
+ {
+ endLoop = true;
+ }
+ break;
+ }
+ if (endLoop)
+ {
+ break;
+ }
+ reader.next();
+ }
+
+ return entry.delete(entry.length() - 2, entry.length()).toString();
+ }
+
+ private String getConnectors() throws Exception
+ {
+ StringBuilder entry = new StringBuilder();
+ boolean endLoop = false;
+
+ while (reader.hasNext())
+ {
+ int eventType = reader.getEventType();
+ switch (eventType)
+ {
+ case XMLStreamConstants.START_ELEMENT:
+ if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTOR.equals(reader.getLocalName()))
+ {
+ entry.append(reader.getElementText()).append(", ");
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTORS.equals(reader.getLocalName()))
+ {
+ endLoop = true;
+ }
+ break;
+ }
+ if (endLoop)
+ {
+ break;
+ }
+ reader.next();
+ }
+
+ return entry.delete(entry.length() - 2, entry.length()).toString();
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private static byte[] decode(String data)
+ {
+ return Base64.decode(data, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
+ }
+
+ // Inner classes -------------------------------------------------
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/java/org/apache/activemq/artemis/components/ExternalComponent.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/components/ExternalComponent.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/components/ExternalComponent.java
new file mode 100644
index 0000000..9317c1b
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/components/ExternalComponent.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.components;
+
+import org.apache.activemq.artemis.core.server.ActiveMQComponent;
+import org.apache.activemq.artemis.dto.ComponentDTO;
+
+public interface ExternalComponent extends ActiveMQComponent
+{
+ void configure(ComponentDTO config, String activemqHome) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BasicSecurityHandler.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BasicSecurityHandler.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BasicSecurityHandler.java
new file mode 100644
index 0000000..adb0850
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BasicSecurityHandler.java
@@ -0,0 +1,54 @@
+/**
+ * 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 org.apache.activemq.artemis.core.config.impl.FileSecurityConfiguration;
+import org.apache.activemq.artemis.dto.BasicSecurityDTO;
+import org.apache.activemq.artemis.dto.SecurityDTO;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl;
+
+public class BasicSecurityHandler implements SecurityHandler
+{
+
+
+ static String fixupFileURI(String value)
+ {
+ if (value != null && value.startsWith("file:"))
+ {
+ value = value.substring("file:".length());
+ value = new File(value).toURI().toString();
+ }
+ return value;
+ }
+
+ @Override
+ public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) throws Exception
+ {
+ BasicSecurityDTO fileSecurity = (BasicSecurityDTO) security;
+ String home = System.getProperty("activemq.home");
+ FileSecurityConfiguration securityConfiguration = new FileSecurityConfiguration(fixupFileURI(fileSecurity.users),
+ fixupFileURI(fileSecurity.roles),
+ fileSecurity.defaultUser,
+ fileSecurity.maskPassword,
+ fileSecurity.passwordCodec);
+ securityConfiguration.start();
+ return new ActiveMQSecurityManagerImpl(securityConfiguration);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/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
new file mode 100644
index 0000000..06ad977
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/BrokerFactory.java
@@ -0,0 +1,92 @@
+/**
+ * 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.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;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+
+public class BrokerFactory
+{
+
+ public static BrokerDTO createBrokerConfiguration(URI configURI) 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);
+ }
+
+ public static BrokerDTO createBrokerConfiguration(String configuration) throws Exception
+ {
+ return createBrokerConfiguration(new URI(configuration));
+ }
+
+ static String fixupFileURI(String value)
+ {
+ if (value != null && value.startsWith("file:"))
+ {
+ value = value.substring("file:".length());
+ value = new File(value).toURI().toString();
+ }
+ return value;
+ }
+
+ public static Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security) throws Exception
+ {
+ if (brokerDTO.configuration != null)
+ {
+ BrokerHandler handler;
+ URI configURI = new URI(fixupFileURI(brokerDTO.configuration));
+
+ 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/ea3370b3/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
new file mode 100644
index 0000000..5ac0d73
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/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.factory;
+
+import org.apache.activemq.artemis.dto.BrokerDTO;
+
+import java.net.URI;
+
+public interface BrokerFactoryHandler
+{
+ BrokerDTO createBroker(URI brokerURI) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/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
new file mode 100644
index 0000000..bd51f39
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/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.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/ea3370b3/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
new file mode 100644
index 0000000..ce0590f
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/FileBrokerHandler.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.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/ea3370b3/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
new file mode 100644
index 0000000..d157d7b
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/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.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/ea3370b3/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
new file mode 100644
index 0000000..d7fd588
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/SecurityManagerFactory.java
@@ -0,0 +1,42 @@
+/**
+ * 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;
+import org.apache.activemq.artemis.utils.FactoryFinder;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+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/ea3370b3/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
new file mode 100644
index 0000000..d600f79
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/factory/XmlBrokerFactoryHandler.java
@@ -0,0 +1,38 @@
+/**
+ * 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.cli.ConfigurationException;
+import org.apache.activemq.artemis.dto.BrokerDTO;
+import org.apache.activemq.artemis.dto.XmlUtil;
+
+import java.io.File;
+import java.net.URI;
+
+public class XmlBrokerFactoryHandler implements BrokerFactoryHandler
+{
+ @Override
+ public BrokerDTO createBroker(URI brokerURI) 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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.java
new file mode 100644
index 0000000..8fb5794
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/Broker.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.integration;
+
+import org.apache.activemq.artemis.core.server.ActiveMQComponent;
+
+/**
+ * A Broker os a set of ActiveMQComponents that create a Server, for instance core and jms.
+ */
+public interface Broker extends ActiveMQComponent
+{
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/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
new file mode 100644
index 0000000..4bf2df2
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java
@@ -0,0 +1,118 @@
+/**
+ * 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.integration;
+
+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.dto.ServerDTO;
+import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger;
+import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
+
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Map;
+
+public class FileBroker implements Broker
+{
+ private final String configurationUrl;
+
+ private boolean started;
+
+ private final ActiveMQSecurityManager securityManager;
+
+ private Map<String, ActiveMQComponent> components;
+
+ public FileBroker(ServerDTO broker, ActiveMQSecurityManager security)
+ {
+ this.securityManager = security;
+ this.configurationUrl = broker.configuration;
+ }
+
+
+ public synchronized void start() throws Exception
+ {
+ if (started)
+ {
+ return;
+ }
+
+ //todo if we start to pullout more configs from the main config then we should pull out the configuration objects from factories if available
+ FileConfiguration configuration = new FileConfiguration();
+ FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
+
+ FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(configurationUrl);
+ fileDeploymentManager.addDeployable(configuration).addDeployable(jmsConfiguration);
+ fileDeploymentManager.readConfiguration();
+
+ components = fileDeploymentManager.buildService(securityManager, ManagementFactory.getPlatformMBeanServer());
+
+ ArrayList<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components);
+ ActiveMQBootstrapLogger.LOGGER.serverStarting();
+ for (ActiveMQComponent component : componentsByStartOrder)
+ {
+ component.start();
+ }
+ started = true;
+
+
+ }
+
+ @Override
+ public void stop() throws Exception
+ {
+ if (!started)
+ {
+ return;
+ }
+ ActiveMQComponent[] mqComponents = new ActiveMQComponent[components.size()];
+ components.values().toArray(mqComponents);
+ for (int i = mqComponents.length - 1; i >= 0; i--)
+ {
+ mqComponents[i].stop();
+ }
+ started = false;
+ }
+
+ @Override
+ public boolean isStarted()
+ {
+ return started;
+ }
+
+ public Map<String, ActiveMQComponent> getComponents()
+ {
+ return components;
+ }
+
+ /*
+ * 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)
+ {
+ ArrayList<ActiveMQComponent> activeMQComponents = new ArrayList<ActiveMQComponent>();
+ ActiveMQComponent jmsComponent = components.get("jms");
+ if (jmsComponent != null)
+ {
+ activeMQComponents.add(jmsComponent);
+ }
+ activeMQComponents.add(components.get("core"));
+ return activeMQComponents;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/bootstrap/ActiveMQBootstrapBundle.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/bootstrap/ActiveMQBootstrapBundle.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/bootstrap/ActiveMQBootstrapBundle.java
new file mode 100644
index 0000000..4254e8a
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/bootstrap/ActiveMQBootstrapBundle.java
@@ -0,0 +1,32 @@
+/**
+ * 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.integration.bootstrap;
+
+
+import org.jboss.logging.annotations.MessageBundle;
+
+/**
+ * Logger Code 10
+ *
+ * each message id must be 6 digits long starting with 10, the 3rd digit should be 9
+ *
+ * so 109000 to 109999
+ */
+@MessageBundle(projectCode = "AMQ")
+public class ActiveMQBootstrapBundle
+{
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/bootstrap/ActiveMQBootstrapLogger.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/bootstrap/ActiveMQBootstrapLogger.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/bootstrap/ActiveMQBootstrapLogger.java
new file mode 100644
index 0000000..c1bea17
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/bootstrap/ActiveMQBootstrapLogger.java
@@ -0,0 +1,71 @@
+/**
+ * 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.integration.bootstrap;
+
+import org.jboss.logging.BasicLogger;
+import org.jboss.logging.Logger;
+import org.jboss.logging.annotations.Cause;
+import org.jboss.logging.annotations.LogMessage;
+import org.jboss.logging.annotations.Message;
+import org.jboss.logging.annotations.MessageLogger;
+
+/**
+ * Logger Code 10
+ *
+ * each message id must be 6 digits long starting with 10, the 3rd digit donates the level so
+ *
+ * INF0 1
+ * WARN 2
+ * DEBUG 3
+ * ERROR 4
+ * TRACE 5
+ * FATAL 6
+ *
+ * so an INFO message would be 101000 to 101999
+ */
+@MessageLogger(projectCode = "AMQ")
+public interface ActiveMQBootstrapLogger extends BasicLogger
+{
+ /**
+ * The default logger.
+ */
+ ActiveMQBootstrapLogger LOGGER = Logger.getMessageLogger(ActiveMQBootstrapLogger.class, ActiveMQBootstrapLogger.class.getPackage().getName());
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 101000, value = "Starting ActiveMQ Server", format = Message.Format.MESSAGE_FORMAT)
+ void serverStarting();
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 101001, value = "Stopping ActiveMQ Server", format = Message.Format.MESSAGE_FORMAT)
+ void serverStopping();
+
+ @LogMessage(level = Logger.Level.INFO)
+ @Message(id = 101002, value = "Starting Naming server on {0}:{1,number,#} (rmi {2}:{3,number,#})", format = Message.Format.MESSAGE_FORMAT)
+ void startedNamingService(String bindAddress, int port, String rmiBindAddress, int rmiPort);
+
+ @LogMessage(level = Logger.Level.WARN)
+ @Message(id = 102000, value = "Error during undeployment: {0}", format = Message.Format.MESSAGE_FORMAT)
+ void errorDuringUndeployment(@Cause Throwable t, String name);
+
+ @LogMessage(level = Logger.Level.ERROR)
+ @Message(id = 104000, value = "Failed to delete file {0}", format = Message.Format.MESSAGE_FORMAT)
+ void errorDeletingFile(String name);
+
+ @LogMessage(level = Logger.Level.ERROR)
+ @Message(id = 104001, value = "Failed to start server", format = Message.Format.MESSAGE_FORMAT)
+ void errorStartingServer(@Cause Exception e);
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/basic-security
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/basic-security b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/basic-security
new file mode 100644
index 0000000..8418fe9
--- /dev/null
+++ b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/security/basic-security
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.factory.BasicSecurityHandler
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/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
new file mode 100644
index 0000000..26ec4fb
--- /dev/null
+++ b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/server/file
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.factory.FileBrokerHandler
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/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
new file mode 100644
index 0000000..28251ef
--- /dev/null
+++ b/artemis-cli/src/main/resources/META-INF/services/org/apache/activemq/artemis/broker/xml
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.factory.XmlBrokerFactoryHandler
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
new file mode 100755
index 0000000..c5e973e
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
@@ -0,0 +1,119 @@
+#!/bin/sh
+# 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.
+
+if [ -z "$ARTEMIS_INSTANCE" ] ; then
+
+ ## resolve links - $0 may be a link to ActiveMQ's home
+ PRG="$0"
+ progname=`basename "$0"`
+ saveddir=`pwd`
+
+ # need this for relative symlinks
+ dirname_prg=`dirname "$PRG"`
+ cd "$dirname_prg"
+
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '.*/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+ done
+
+ ARTEMIS_INSTANCE=`dirname "$PRG"`
+ cd "$saveddir"
+
+ # make it fully qualified
+ ARTEMIS_INSTANCE=`cd "$ARTEMIS_INSTANCE/.." && pwd`
+fi
+
+# Set Defaults Properties
+ARTEMIS_LOGGING_CONF="file:$ARTEMIS_INSTANCE/etc/logging.properties"
+ARTEMIS_DATA_DIR="$ARTEMIS_INSTANCE/data"
+ARTEMIS_LOG_MANAGER=org.jboss.logmanager.LogManager
+JAVA_ARGS="-XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M"
+
+# Load Profile Data
+. "$ARTEMIS_INSTANCE/etc/artemis.profile"
+
+CLASSPATH="$ARTEMIS_HOME/lib/artemis-boot.jar"
+
+# OS specific support.
+cygwin=false;
+darwin=false;
+case "`uname`" in
+ CYGWIN*) cygwin=true
+ OSTYPE=cygwin
+ export OSTYPE
+ ;;
+ Darwin*) darwin=true
+ if [ -z "$JAVA_HOME" ] ; then
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+ fi
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$ARTEMIS_INSTANCE" ] &&
+ ARTEMIS_INSTANCE=`cygpath --unix "$ARTEMIS_INSTANCE"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD=`which java 2> /dev/null `
+ if [ -z "$JAVACMD" ] ; then
+ JAVACMD=java
+ fi
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly."
+ echo " We cannot execute $JAVACMD"
+ exit 1
+fi
+
+if $cygwin ; then
+ JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
+ ARTEMIS_HOME=`cygpath --windows "$ARTEMIS_HOME"`
+ CLASSPATH=`cygpath --windows "$CLASSPATH"`
+fi
+
+exec "$JAVACMD" $JAVA_ARGS $ARTEMIS_CLUSTER_PROPS \
+ -classpath "$CLASSPATH" \
+ -Dartemis.home="$ARTEMIS_HOME" \
+ -Dartemis.instance="$ARTEMIS_INSTANCE" \
+ -Djava.library.path="$ARTEMIS_HOME/bin/lib/linux-i686:$ARTEMIS_HOME/bin/lib/linux-x86_64" \
+ -Djava.io.tmpdir="$ARTEMIS_INSTANCE/tmp" \
+ -Ddata.dir="$ARTEMIS_DATA_DIR" \
+ -Djava.util.logging.manager="$ARTEMIS_LOG_MANAGER" \
+ -Dlogging.configuration="$ARTEMIS_LOGGING_CONF" \
+ $DEBUG_ARGS \
+ org.apache.activemq.artemis.boot.Artemis $@