You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/01/15 18:19:27 UTC
[25/27] activemq-6 git commit: ACTIVEMQ6-67 - cleaned up configuration
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-bootstrap/src/main/resources/META-INF/services/org/apache/activemq/broker/security/basic-security
----------------------------------------------------------------------
diff --git a/activemq-bootstrap/src/main/resources/META-INF/services/org/apache/activemq/broker/security/basic-security b/activemq-bootstrap/src/main/resources/META-INF/services/org/apache/activemq/broker/security/basic-security
new file mode 100644
index 0000000..b262a51
--- /dev/null
+++ b/activemq-bootstrap/src/main/resources/META-INF/services/org/apache/activemq/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.factory.BasicSecurityHandler
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-bootstrap/src/main/resources/META-INF/services/org/apache/activemq/broker/server/file
----------------------------------------------------------------------
diff --git a/activemq-bootstrap/src/main/resources/META-INF/services/org/apache/activemq/broker/server/file b/activemq-bootstrap/src/main/resources/META-INF/services/org/apache/activemq/broker/server/file
new file mode 100644
index 0000000..e3cf2b1
--- /dev/null
+++ b/activemq-bootstrap/src/main/resources/META-INF/services/org/apache/activemq/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.factory.FileBrokerHandler
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-dto/src/main/java/org/apache/activemq/dto/BasicSecurityDTO.java
----------------------------------------------------------------------
diff --git a/activemq-dto/src/main/java/org/apache/activemq/dto/BasicSecurityDTO.java b/activemq-dto/src/main/java/org/apache/activemq/dto/BasicSecurityDTO.java
index 7d64011..9b25d18 100644
--- a/activemq-dto/src/main/java/org/apache/activemq/dto/BasicSecurityDTO.java
+++ b/activemq-dto/src/main/java/org/apache/activemq/dto/BasicSecurityDTO.java
@@ -18,10 +18,25 @@ package org.apache.activemq.dto;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "basic-security")
@XmlAccessorType(XmlAccessType.FIELD)
public class BasicSecurityDTO extends SecurityDTO
{
+ @XmlElement(required = true)
+ public String users;
+
+ @XmlElement(required = true)
+ public String roles;
+
+ @XmlElement(name = "default-user")
+ public String defaultUser;
+
+ @XmlElement(name = "mask-password")
+ public Boolean maskPassword = false;
+
+ @XmlElement
+ public String passwordCodec;
}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java
----------------------------------------------------------------------
diff --git a/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java b/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java
index 252b050..a11d6b8 100644
--- a/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java
+++ b/activemq-dto/src/main/java/org/apache/activemq/dto/BrokerDTO.java
@@ -27,15 +27,12 @@ import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class BrokerDTO
{
-
@XmlElementRef
- public CoreDTO core;
-
- @XmlElementRef(required = false)
- public JmsDTO jms;
+ public SecurityDTO security;
@XmlElementRef
- public SecurityDTO security;
+ public ServerDTO server;
+
@XmlElementRef(required = false)
public WebServerDTO web;
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-dto/src/main/java/org/apache/activemq/dto/CoreDTO.java
----------------------------------------------------------------------
diff --git a/activemq-dto/src/main/java/org/apache/activemq/dto/CoreDTO.java b/activemq-dto/src/main/java/org/apache/activemq/dto/CoreDTO.java
deleted file mode 100644
index 820d461..0000000
--- a/activemq-dto/src/main/java/org/apache/activemq/dto/CoreDTO.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.dto;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "core")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class CoreDTO
-{
-
- @XmlAttribute
- public String configuration;
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-dto/src/main/java/org/apache/activemq/dto/JmsDTO.java
----------------------------------------------------------------------
diff --git a/activemq-dto/src/main/java/org/apache/activemq/dto/JmsDTO.java b/activemq-dto/src/main/java/org/apache/activemq/dto/JmsDTO.java
deleted file mode 100644
index efa0da2..0000000
--- a/activemq-dto/src/main/java/org/apache/activemq/dto/JmsDTO.java
+++ /dev/null
@@ -1,33 +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.dto;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "jms")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class JmsDTO
-{
-
- @XmlAttribute
- public String configuration;
-
-}
-
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-dto/src/main/java/org/apache/activemq/dto/ServerDTO.java
----------------------------------------------------------------------
diff --git a/activemq-dto/src/main/java/org/apache/activemq/dto/ServerDTO.java b/activemq-dto/src/main/java/org/apache/activemq/dto/ServerDTO.java
new file mode 100644
index 0000000..9ef2168
--- /dev/null
+++ b/activemq-dto/src/main/java/org/apache/activemq/dto/ServerDTO.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.dto;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "server")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ServerDTO
+{
+
+ @XmlAttribute
+ public String configuration;
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index
----------------------------------------------------------------------
diff --git a/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index b/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index
index 9cffb01..5803f73 100644
--- a/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index
+++ b/activemq-dto/src/main/resources/org/apache/activemq/dto/jaxb.index
@@ -15,8 +15,6 @@
## limitations under the License.
## ---------------------------------------------------------------------------
BrokerDTO
-CoreDTO
-JmsDTO
SecurityDTO
BasicSecurityDTO
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/config/impl/FileJMSConfiguration.java
----------------------------------------------------------------------
diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/config/impl/FileJMSConfiguration.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/config/impl/FileJMSConfiguration.java
new file mode 100644
index 0000000..b1fd386
--- /dev/null
+++ b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/config/impl/FileJMSConfiguration.java
@@ -0,0 +1,219 @@
+/**
+ * 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.jms.server.config.impl;
+
+import org.apache.activemq.api.config.ActiveMQDefaultConfiguration;
+import org.apache.activemq.core.config.impl.Validators;
+import org.apache.activemq.core.deployers.Deployable;
+import org.apache.activemq.core.server.ActiveMQComponent;
+import org.apache.activemq.core.server.impl.ActiveMQServerImpl;
+import org.apache.activemq.jms.server.ActiveMQJMSServerLogger;
+import org.apache.activemq.jms.server.config.JMSQueueConfiguration;
+import org.apache.activemq.jms.server.config.TopicConfiguration;
+import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
+import org.apache.activemq.spi.core.security.ActiveMQSecurityManager;
+import org.apache.activemq.utils.XMLConfigurationUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.management.MBeanServer;
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class FileJMSConfiguration extends JMSConfigurationImpl implements Deployable
+{
+ private static final String CONFIGURATION_SCHEMA_URL = "schema/activemq-jms.xsd";
+
+ private static final String CONFIGURATION_SCHEMA_ROOT_ELEMENT = "jms";
+
+ private static final String NAME_ATTR = "name";
+
+ private static final String QUEUE_NODE_NAME = "queue";
+
+ private static final String QUEUE_SELECTOR_NODE_NAME = "selector";
+
+ private static final String TOPIC_NODE_NAME = "topic";
+
+ private static final String JMX_DOMAIN_NAME = "jmx-domain";
+
+ private static final boolean DEFAULT_QUEUE_DURABILITY = true;
+
+ private boolean parsed = false;
+
+ @Override
+ public void parse(Element config) throws Exception
+ {
+ parseConfiguration(config);
+ parsed = true;
+ }
+
+ @Override
+ public boolean isParsed()
+ {
+ return parsed;
+ }
+
+ @Override
+ public String getRootElement()
+ {
+ return CONFIGURATION_SCHEMA_ROOT_ELEMENT;
+ }
+
+ @Override
+ public void buildService(ActiveMQSecurityManager securityManager, MBeanServer mBeanServer, Map<String, Deployable> deployables, Map<String, ActiveMQComponent> components) throws Exception
+ {
+ ActiveMQServerImpl server = (ActiveMQServerImpl) components.get("core");
+ components.put(CONFIGURATION_SCHEMA_ROOT_ELEMENT, new JMSServerManagerImpl(server, this));
+ }
+
+ @Override
+ public String getSchema()
+ {
+ return CONFIGURATION_SCHEMA_URL;
+ }
+
+
+ /**
+ * Parse the JMS Configuration XML
+ */
+ public void parseConfiguration(final Node rootnode) throws Exception
+ {
+
+ ArrayList<JMSQueueConfiguration> queues = new ArrayList<>();
+ ArrayList<TopicConfiguration> topics = new ArrayList<>();
+
+ Element e = (Element) rootnode;
+
+ String[] elements = new String[]{QUEUE_NODE_NAME, TOPIC_NODE_NAME};
+ for (String element : elements)
+ {
+ NodeList children = e.getElementsByTagName(element);
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node node = children.item(i);
+ Node keyNode = node.getAttributes().getNamedItem(NAME_ATTR);
+ if (keyNode == null)
+ {
+ ActiveMQJMSServerLogger.LOGGER.jmsConfigMissingKey(node);
+ continue;
+ }
+
+ if (node.getNodeName().equals(TOPIC_NODE_NAME))
+ {
+ topics.add(parseTopicConfiguration(node));
+ }
+ else if (node.getNodeName().equals(QUEUE_NODE_NAME))
+ {
+ queues.add(parseQueueConfiguration(node));
+ }
+ }
+ }
+
+ String domain = XMLConfigurationUtil.getString(e, JMX_DOMAIN_NAME, ActiveMQDefaultConfiguration.getDefaultJmxDomain(), Validators.NO_CHECK);
+
+ newConfig(queues, topics, domain);
+ }
+
+ /**
+ * Parse the topic node as a TopicConfiguration object
+ *
+ * @param node
+ * @return topic configuration
+ * @throws Exception
+ */
+ public static TopicConfiguration parseTopicConfiguration(final Node node) throws Exception
+ {
+ String topicName = node.getAttributes().getNamedItem(NAME_ATTR).getNodeValue();
+
+ return newTopic(topicName);
+ }
+
+ /**
+ * Parse the Queue Configuration node as a QueueConfiguration object
+ *
+ * @param node
+ * @return jms queue configuration
+ * @throws Exception
+ */
+ public static JMSQueueConfiguration parseQueueConfiguration(final Node node) throws Exception
+ {
+ Element e = (Element) node;
+ NamedNodeMap atts = node.getAttributes();
+ String queueName = atts.getNamedItem(NAME_ATTR).getNodeValue();
+ String selectorString = null;
+ boolean durable = XMLConfigurationUtil.getBoolean(e, "durable", DEFAULT_QUEUE_DURABILITY);
+ NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+
+ if (QUEUE_SELECTOR_NODE_NAME.equals(children.item(i).getNodeName()))
+ {
+ Node selectorNode = children.item(i);
+ Node attNode = selectorNode.getAttributes().getNamedItem("string");
+ selectorString = attNode.getNodeValue();
+ }
+ }
+
+ return newQueue(queueName, selectorString, durable);
+ }
+
+ /**
+ * @param topicName
+ * @return
+ */
+ protected static TopicConfiguration newTopic(final String topicName)
+ {
+ return new TopicConfigurationImpl()
+ .setName(topicName);
+ }
+
+ /**
+ * @param queueName
+ * @param selectorString
+ * @param durable
+ * @return
+ */
+ protected static JMSQueueConfiguration newQueue(final String queueName,
+ final String selectorString,
+ final boolean durable)
+ {
+ return new JMSQueueConfigurationImpl().
+ setName(queueName).
+ setSelector(selectorString).
+ setDurable(durable);
+ }
+
+ /**
+ * @param queues
+ * @param topics
+ * @param domain
+ * @return
+ */
+ protected void newConfig(final ArrayList<JMSQueueConfiguration> queues,
+ final ArrayList<TopicConfiguration> topics, String domain)
+ {
+ setQueueConfigurations(queues)
+ .setTopicConfigurations(topics)
+ .setDomain(domain);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java
----------------------------------------------------------------------
diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java
index e2d5550..bb6277e 100644
--- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java
+++ b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/embedded/EmbeddedJMS.java
@@ -18,11 +18,13 @@ package org.apache.activemq.jms.server.embedded;
import javax.naming.Context;
+import org.apache.activemq.core.config.FileDeploymentManager;
import org.apache.activemq.core.registry.JndiBindingRegistry;
import org.apache.activemq.core.registry.MapBindingRegistry;
import org.apache.activemq.core.server.embedded.EmbeddedActiveMQ;
import org.apache.activemq.jms.server.JMSServerManager;
import org.apache.activemq.jms.server.config.JMSConfiguration;
+import org.apache.activemq.jms.server.config.impl.FileJMSConfiguration;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
import org.apache.activemq.spi.core.naming.BindingRegistry;
@@ -40,19 +42,9 @@ public class EmbeddedJMS extends EmbeddedActiveMQ
{
protected JMSServerManagerImpl serverManager;
protected BindingRegistry registry;
- protected String jmsConfigResourcePath;
protected JMSConfiguration jmsConfiguration;
protected Context context;
- /**
- * Classpath resource where JMS config file is. Defaults to 'activemq-jms.xml'
- *
- * @param jmsConfigResourcePath
- */
- public void setJmsConfigResourcePath(String jmsConfigResourcePath)
- {
- this.jmsConfigResourcePath = jmsConfigResourcePath;
- }
public BindingRegistry getRegistry()
{
@@ -113,8 +105,22 @@ public class EmbeddedJMS extends EmbeddedActiveMQ
{
serverManager = new JMSServerManagerImpl(activeMQServer, jmsConfiguration);
}
- else if (jmsConfigResourcePath == null) serverManager = new JMSServerManagerImpl(activeMQServer);
- else serverManager = new JMSServerManagerImpl(activeMQServer, jmsConfigResourcePath);
+ else
+ {
+ FileJMSConfiguration fileConfiguration = new FileJMSConfiguration();
+ FileDeploymentManager deploymentManager;
+ if (configResourcePath != null)
+ {
+ deploymentManager = new FileDeploymentManager(configResourcePath);
+ }
+ else
+ {
+ deploymentManager = new FileDeploymentManager();
+ }
+ deploymentManager.addDeployable(fileConfiguration);
+ deploymentManager.readConfiguration();
+ serverManager = new JMSServerManagerImpl(activeMQServer, fileConfiguration);
+ }
if (registry == null)
{
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerConfigParserImpl.java
----------------------------------------------------------------------
diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerConfigParserImpl.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerConfigParserImpl.java
deleted file mode 100644
index cd948c1..0000000
--- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerConfigParserImpl.java
+++ /dev/null
@@ -1,205 +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.jms.server.impl;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-
-import org.apache.activemq.api.config.ActiveMQDefaultConfiguration;
-import org.apache.activemq.core.config.impl.Validators;
-import org.apache.activemq.jms.server.ActiveMQJMSServerLogger;
-import org.apache.activemq.jms.server.JMSServerConfigParser;
-import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration;
-import org.apache.activemq.jms.server.config.JMSConfiguration;
-import org.apache.activemq.jms.server.config.JMSQueueConfiguration;
-import org.apache.activemq.jms.server.config.TopicConfiguration;
-import org.apache.activemq.jms.server.config.impl.JMSConfigurationImpl;
-import org.apache.activemq.jms.server.config.impl.JMSQueueConfigurationImpl;
-import org.apache.activemq.jms.server.config.impl.TopicConfigurationImpl;
-import org.apache.activemq.utils.XMLConfigurationUtil;
-import org.apache.activemq.utils.XMLUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * JMS Configuration File Parser.
- *
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- */
-public final class JMSServerConfigParserImpl implements JMSServerConfigParser
-{
- protected static final String NAME_ATTR = "name";
-
- public JMSServerConfigParserImpl()
- {
- }
-
- /**
- * Parse the JMS Configuration XML as a JMSConfiguration object
- */
- public JMSConfiguration parseConfiguration(final InputStream stream) throws Exception
- {
- Reader reader = new InputStreamReader(stream);
- String xml = org.apache.activemq.utils.XMLUtil.readerToString(reader);
- xml = XMLUtil.replaceSystemProps(xml);
- return parseConfiguration(XMLUtil.stringToElement(xml));
- }
-
- /**
- * Parse the JMS Configuration XML as a JMSConfiguration object
- */
- public JMSConfiguration parseConfiguration(final Node rootnode) throws Exception
- {
-
- ArrayList<JMSQueueConfiguration> queues = new ArrayList<JMSQueueConfiguration>();
- ArrayList<TopicConfiguration> topics = new ArrayList<TopicConfiguration>();
- ArrayList<ConnectionFactoryConfiguration> cfs = new ArrayList<ConnectionFactoryConfiguration>();
- String domain = ActiveMQDefaultConfiguration.getDefaultJmxDomain();
-
- Element e = (Element) rootnode;
-
- org.apache.activemq.utils.XMLUtil.validate(rootnode, "schema/activemq-jms.xsd");
-
- String[] elements = new String[]{JMSServerDeployer.QUEUE_NODE_NAME,
- JMSServerDeployer.TOPIC_NODE_NAME};
- for (String element : elements)
- {
- NodeList children = e.getElementsByTagName(element);
- for (int i = 0; i < children.getLength(); i++)
- {
- Node node = children.item(i);
- Node keyNode = node.getAttributes().getNamedItem(JMSServerConfigParserImpl.NAME_ATTR);
- if (keyNode == null)
- {
- ActiveMQJMSServerLogger.LOGGER.jmsConfigMissingKey(node);
- continue;
- }
-
- if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME))
- {
- topics.add(parseTopicConfiguration(node));
- }
- else if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME))
- {
- queues.add(parseQueueConfiguration(node));
- }
- }
- }
-
- domain = XMLConfigurationUtil.getString(e, JMSServerDeployer.JMX_DOMAIN_NAME, ActiveMQDefaultConfiguration.getDefaultJmxDomain(), Validators.NO_CHECK);
-
-
- JMSConfiguration value = newConfig(queues, topics, domain);
-
- return value;
- }
-
- /**
- * Parse the topic node as a TopicConfiguration object
- *
- * @param node
- * @return topic configuration
- * @throws Exception
- */
- public TopicConfiguration parseTopicConfiguration(final Node node) throws Exception
- {
- String topicName = node.getAttributes().getNamedItem(JMSServerConfigParserImpl.NAME_ATTR).getNodeValue();
-
- return newTopic(topicName);
- }
-
- /**
- * Parse the Queue Configuration node as a QueueConfiguration object
- *
- * @param node
- * @return jms queue configuration
- * @throws Exception
- */
- public JMSQueueConfiguration parseQueueConfiguration(final Node node) throws Exception
- {
- Element e = (Element) node;
- NamedNodeMap atts = node.getAttributes();
- String queueName = atts.getNamedItem(JMSServerConfigParserImpl.NAME_ATTR).getNodeValue();
- String selectorString = null;
- boolean durable = XMLConfigurationUtil.getBoolean(e, "durable", JMSServerDeployer.DEFAULT_QUEUE_DURABILITY);
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++)
- {
- Node child = children.item(i);
-
- if (JMSServerDeployer.QUEUE_SELECTOR_NODE_NAME.equals(children.item(i).getNodeName()))
- {
- Node selectorNode = children.item(i);
- Node attNode = selectorNode.getAttributes().getNamedItem("string");
- selectorString = attNode.getNodeValue();
- }
- }
-
- return newQueue(queueName, selectorString, durable);
- }
-
- /**
- * hook for integration layers
- *
- * @param topicName
- * @return
- */
- protected TopicConfiguration newTopic(final String topicName)
- {
- return new TopicConfigurationImpl()
- .setName(topicName);
- }
-
- /**
- * hook for integration layers
- *
- * @param queueName
- * @param selectorString
- * @param durable
- * @return
- */
- protected JMSQueueConfiguration newQueue(final String queueName,
- final String selectorString,
- final boolean durable)
- {
- return new JMSQueueConfigurationImpl().
- setName(queueName).
- setSelector(selectorString).
- setDurable(durable);
- }
-
- /**
- * hook for integration layers
- *
- * @param queues
- * @param topics
- * @param domain
- * @return
- */
- protected JMSConfiguration newConfig(final ArrayList<JMSQueueConfiguration> queues,
- final ArrayList<TopicConfiguration> topics, String domain)
- {
- return new JMSConfigurationImpl()
- .setQueueConfigurations(queues)
- .setTopicConfigurations(topics)
- .setDomain(domain);
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerDeployer.java
----------------------------------------------------------------------
diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerDeployer.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerDeployer.java
deleted file mode 100644
index 7d3d568..0000000
--- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerDeployer.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.server.impl;
-
-import org.apache.activemq.core.deployers.DeploymentManager;
-import org.apache.activemq.core.deployers.impl.XmlDeployer;
-import org.apache.activemq.jms.server.JMSServerConfigParser;
-import org.apache.activemq.jms.server.JMSServerManager;
-import org.apache.activemq.jms.server.config.JMSQueueConfiguration;
-import org.apache.activemq.jms.server.config.TopicConfiguration;
-import org.w3c.dom.Node;
-
-/**
- * @author <a href="ataylor@redhat.com">Andy Taylor</a>
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="jmesnil@redhat.com">Jeff Mesnil</a>
- */
-public class JMSServerDeployer extends XmlDeployer
-{
- private final JMSServerConfigParser parser;
-
- private final JMSServerManager jmsServerManager;
-
- protected static final String QUEUE_NODE_NAME = "queue";
-
- protected static final String QUEUE_SELECTOR_NODE_NAME = "selector";
-
- protected static final String TOPIC_NODE_NAME = "topic";
-
- protected static final String JMX_DOMAIN_NAME = "jmx-domain";
-
- protected static final boolean DEFAULT_QUEUE_DURABILITY = true;
-
- public JMSServerDeployer(final JMSServerManager jmsServerManager,
- final DeploymentManager deploymentManager)
- {
- super(deploymentManager);
-
- this.jmsServerManager = jmsServerManager;
-
- parser = new JMSServerConfigParserImpl();
- }
-
- /**
- * the names of the elements to deploy
- *
- * @return the names of the elements todeploy
- */
- @Override
- public String[] getElementTagName()
- {
- return new String[]{JMSServerDeployer.QUEUE_NODE_NAME,
- JMSServerDeployer.TOPIC_NODE_NAME};
- }
-
- @Override
- public void validate(final Node rootNode) throws Exception
- {
- org.apache.activemq.utils.XMLUtil.validate(rootNode, "schema/activemq-jms.xsd");
- }
-
- /**
- * deploy an element
- *
- * @param node the element to deploy
- * @throws Exception
- */
- @Override
- public void deploy(final Node node) throws Exception
- {
- createAndBindObject(node);
- }
-
- /**
- * Creates the object to bind, this will either be a ActiveMQQueue or ActiveMQTopic.
- *
- * @param node the config
- * @throws Exception
- */
- private void createAndBindObject(final Node node) throws Exception
- {
- if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME))
- {
- deployQueue(node);
- }
- else if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME))
- {
- deployTopic(node);
- }
- }
-
- /**
- * Undeploys an element.
- *
- * @param node the element to undeploy
- * @throws Exception
- */
- @Override
- public void undeploy(final Node node) throws Exception
- {
- if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME))
- {
- String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
- jmsServerManager.removeQueueFromBindingRegistry(queueName);
- }
- else if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME))
- {
- String topicName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
- jmsServerManager.removeTopicFromBindingRegistry(topicName);
- }
- }
-
- @Override
- public String[] getDefaultConfigFileNames()
- {
- return new String[]{"activemq-jms.xml"};
- }
-
-
- /**
- * @param node
- * @throws Exception
- */
- private void deployTopic(final Node node) throws Exception
- {
- TopicConfiguration topicConfig = parser.parseTopicConfiguration(node);
- jmsServerManager.createTopic(false, topicConfig.getName());
- }
-
- /**
- * @param node
- * @throws Exception
- */
- private void deployQueue(final Node node) throws Exception
- {
- JMSQueueConfiguration queueconfig = parser.parseQueueConfiguration(node);
- jmsServerManager.createQueue(false, queueconfig.getName(), queueconfig.getSelector(), queueconfig.isDurable());
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java
----------------------------------------------------------------------
diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java
index 5e9fa43..020dd36 100644
--- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java
+++ b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java
@@ -42,9 +42,6 @@ import org.apache.activemq.api.core.management.ResourceNames;
import org.apache.activemq.api.jms.ActiveMQJMSClient;
import org.apache.activemq.api.jms.JMSFactoryType;
import org.apache.activemq.core.config.Configuration;
-import org.apache.activemq.core.deployers.DeploymentManager;
-import org.apache.activemq.core.deployers.impl.FileDeploymentManager;
-import org.apache.activemq.core.deployers.impl.XmlDeployer;
import org.apache.activemq.core.postoffice.Binding;
import org.apache.activemq.core.postoffice.BindingType;
import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory;
@@ -130,16 +127,10 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
private JMSManagementService jmsManagementService;
- private XmlDeployer jmsDeployer;
-
private boolean startCalled;
private boolean active;
- private DeploymentManager deploymentManager;
-
- private final String configFileName;
-
private JMSConfiguration config;
private Configuration coreConfig;
@@ -153,8 +144,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
this.server = server;
this.coreConfig = server.getConfiguration();
-
- configFileName = null;
}
/**
@@ -170,44 +159,18 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
this.coreConfig = server.getConfiguration();
- configFileName = null;
-
this.registry = registry;
}
- public JMSServerManagerImpl(final ActiveMQServer server, final String configFileName) throws Exception
- {
- this.server = server;
-
- this.coreConfig = server.getConfiguration();
-
- this.configFileName = configFileName;
- }
-
public JMSServerManagerImpl(final ActiveMQServer server, final JMSConfiguration configuration) throws Exception
{
this.server = server;
this.coreConfig = server.getConfiguration();
- configFileName = null;
-
config = configuration;
}
- /**
- * Unused
- */
- @Deprecated
- public JMSServerManagerImpl(ActiveMQServer server, String configFilename, JMSStorageManager storageManager)
- {
- this.server = server;
-
- configFileName = null;
-
- storage = storageManager;
- }
-
// ActivateCallback implementation -------------------------------------
public void preActivate()
@@ -234,27 +197,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
initJournal();
- // start the JMS deployer only if the configuration is not done using the JMSConfiguration object
- if (config == null)
- {
- if (server.getConfiguration().isFileDeploymentEnabled())
- {
- jmsDeployer = new JMSServerDeployer(this, deploymentManager);
-
- if (configFileName != null)
- {
- jmsDeployer.setConfigFileNames(new String[]{configFileName});
- }
-
- jmsDeployer.start();
-
- deploymentManager.start();
- }
- }
- else
- {
- deploy();
- }
+ deploy();
for (Runnable run : cachedCommands)
{
@@ -285,16 +228,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
return;
}
- if (jmsDeployer != null)
- {
- jmsDeployer.stop();
- }
-
- if (deploymentManager != null)
- {
- deploymentManager.stop();
- }
-
// Storage could be null on a shared store backup server before initialization
if (storage != null && storage.isStarted())
{
@@ -329,7 +262,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
jmsManagementService.stop();
}
- jmsDeployer = null;
jmsManagementService = null;
active = false;
@@ -472,7 +404,6 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
return;
}
- deploymentManager = new FileDeploymentManager(server.getConfiguration().getFileDeployerScanPeriod());
server.registerActivateCallback(this);
/**
* See this method's javadoc.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-jms-server/src/main/resources/schema/activemq-jms.xsd
----------------------------------------------------------------------
diff --git a/activemq-jms-server/src/main/resources/schema/activemq-jms.xsd b/activemq-jms-server/src/main/resources/schema/activemq-jms.xsd
index b1b728c..0a01c32 100644
--- a/activemq-jms-server/src/main/resources/schema/activemq-jms.xsd
+++ b/activemq-jms-server/src/main/resources/schema/activemq-jms.xsd
@@ -16,14 +16,13 @@
limitations under the License.
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="urn:activemq"
- xmlns="urn:activemq"
- xmlns:amq="urn:org.apache.activemq"
+ xmlns="urn:activemq:jms"
+ targetNamespace="urn:activemq:jms"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">
- <xsd:element name="configuration" amq:schema="activemq-jms-configuration">
+ <xsd:element name="jms">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="jmx-domain" type="xsd:string" default="org.apache.activemq"
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-maven-plugin/src/main/java/org/apache/activemq/server/ActiveMQBootstrap.java
----------------------------------------------------------------------
diff --git a/activemq-maven-plugin/src/main/java/org/apache/activemq/server/ActiveMQBootstrap.java b/activemq-maven-plugin/src/main/java/org/apache/activemq/server/ActiveMQBootstrap.java
index ae7ecfb..daf6a4b 100644
--- a/activemq-maven-plugin/src/main/java/org/apache/activemq/server/ActiveMQBootstrap.java
+++ b/activemq-maven-plugin/src/main/java/org/apache/activemq/server/ActiveMQBootstrap.java
@@ -24,15 +24,21 @@ import java.util.Timer;
import java.util.TimerTask;
import org.apache.activemq.core.config.Configuration;
+import org.apache.activemq.core.config.FileDeploymentManager;
import org.apache.activemq.core.config.HAPolicyConfiguration;
import org.apache.activemq.core.config.impl.ConfigurationImpl;
import org.apache.activemq.core.config.impl.FileConfiguration;
+import org.apache.activemq.core.config.impl.FileSecurityConfiguration;
+import org.apache.activemq.core.config.impl.SecurityConfiguration;
import org.apache.activemq.core.server.ActiveMQServer;
import org.apache.activemq.core.server.JournalType;
import org.apache.activemq.core.server.NodeManager;
import org.apache.activemq.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.core.server.impl.InVMNodeManager;
import org.apache.activemq.jms.server.JMSServerManager;
+import org.apache.activemq.jms.server.config.JMSConfiguration;
+import org.apache.activemq.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.jms.server.config.impl.FileJMSConfiguration;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
import org.apache.activemq.maven.InVMNodeManagerServer;
import org.apache.activemq.spi.core.security.ActiveMQSecurityManager;
@@ -59,6 +65,10 @@ public class ActiveMQBootstrap
private Configuration configuration;
+ private JMSConfiguration jmsFileConfiguration;
+
+ private SecurityConfiguration securityConfiguration;
+
private JMSServerManager manager;
private ActiveMQSecurityManager securityManager;
@@ -89,13 +99,25 @@ public class ActiveMQBootstrap
//extendPluginClasspath(configurationDir);
configuration = new FileConfiguration();
File file = new File(configurationDir + "/" + "activemq-configuration.xml");
- ((FileConfiguration) configuration).setConfigurationUrl(file.toURI().toURL().toExternalForm());
- ((FileConfiguration) configuration).start();
+ jmsFileConfiguration = new FileJMSConfiguration();
+ FileDeploymentManager deploymentManager = new FileDeploymentManager(file.toURI().toURL().toExternalForm());
+ deploymentManager.addDeployable((FileConfiguration)configuration);
+ deploymentManager.addDeployable((FileJMSConfiguration) jmsFileConfiguration);
+
+ securityConfiguration = new FileSecurityConfiguration("file://" + configurationDir + "/" + "activemq-users.properties",
+ "file://" + configurationDir + "/" + "activemq-roles.properties",
+ "guest",
+ false,
+ null);
+ ((FileSecurityConfiguration)securityConfiguration).start();
+ deploymentManager.readConfiguration();
}
else
{
configuration = new ConfigurationImpl();
configuration.setJournalType(JournalType.NIO);
+ jmsFileConfiguration = new JMSConfigurationImpl();
+ securityConfiguration = new SecurityConfiguration();
}
createServer(configuration);
@@ -158,12 +180,12 @@ public class ActiveMQBootstrap
managerMap.put(nodeId, nodeManager);
}
server = new InVMNodeManagerServer(configuration, ManagementFactory.getPlatformMBeanServer(),
- securityManager != null ? securityManager : new ActiveMQSecurityManagerImpl(), nodeManager);
+ securityManager != null ? securityManager : new ActiveMQSecurityManagerImpl(securityConfiguration), nodeManager);
}
else
{
server = new ActiveMQServerImpl(configuration, ManagementFactory.getPlatformMBeanServer(),
- securityManager != null ? securityManager : new ActiveMQSecurityManagerImpl());
+ securityManager != null ? securityManager : new ActiveMQSecurityManagerImpl(securityConfiguration));
}
manager = new JMSServerManagerImpl(server);
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/QueueDestinationsResource.java
----------------------------------------------------------------------
diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/QueueDestinationsResource.java b/activemq-rest/src/main/java/org/apache/activemq/rest/queue/QueueDestinationsResource.java
index 0358db1..4f4a877 100644
--- a/activemq-rest/src/main/java/org/apache/activemq/rest/queue/QueueDestinationsResource.java
+++ b/activemq-rest/src/main/java/org/apache/activemq/rest/queue/QueueDestinationsResource.java
@@ -35,7 +35,7 @@ import org.apache.activemq.api.core.client.ClientSession;
import org.apache.activemq.jms.client.ActiveMQDestination;
import org.apache.activemq.jms.client.ActiveMQQueue;
import org.apache.activemq.jms.server.config.JMSQueueConfiguration;
-import org.apache.activemq.jms.server.impl.JMSServerConfigParserImpl;
+import org.apache.activemq.jms.server.config.impl.FileJMSConfiguration;
import org.apache.activemq.rest.ActiveMQRestLogger;
import org.apache.activemq.rest.queue.push.PushConsumerResource;
import org.apache.activemq.rest.queue.push.xml.PushRegistration;
@@ -65,8 +65,7 @@ public class QueueDestinationsResource
try
{
- JMSServerConfigParserImpl parser = new JMSServerConfigParserImpl();
- JMSQueueConfiguration queue = parser.parseQueueConfiguration(document.getDocumentElement());
+ JMSQueueConfiguration queue = FileJMSConfiguration.parseQueueConfiguration(document.getDocumentElement());
ActiveMQQueue activeMQQueue = ActiveMQDestination.createQueue(queue.getName());
String queueName = activeMQQueue.getAddress();
ClientSession session = manager.getSessionFactory().createSession(false, false, false);
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/main/java/org/apache/activemq/rest/topic/TopicDestinationsResource.java
----------------------------------------------------------------------
diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/topic/TopicDestinationsResource.java b/activemq-rest/src/main/java/org/apache/activemq/rest/topic/TopicDestinationsResource.java
index 8ab2a0e..ad65b90 100644
--- a/activemq-rest/src/main/java/org/apache/activemq/rest/topic/TopicDestinationsResource.java
+++ b/activemq-rest/src/main/java/org/apache/activemq/rest/topic/TopicDestinationsResource.java
@@ -35,7 +35,7 @@ import org.apache.activemq.api.core.client.ClientSession;
import org.apache.activemq.jms.client.ActiveMQDestination;
import org.apache.activemq.jms.client.ActiveMQTopic;
import org.apache.activemq.jms.server.config.TopicConfiguration;
-import org.apache.activemq.jms.server.impl.JMSServerConfigParserImpl;
+import org.apache.activemq.jms.server.config.impl.FileJMSConfiguration;
import org.apache.activemq.rest.ActiveMQRestLogger;
import org.apache.activemq.rest.queue.DestinationSettings;
import org.apache.activemq.rest.queue.PostMessage;
@@ -66,8 +66,7 @@ public class TopicDestinationsResource
try
{
- JMSServerConfigParserImpl parser = new JMSServerConfigParserImpl();
- TopicConfiguration topic = parser.parseTopicConfiguration(document.getDocumentElement());
+ TopicConfiguration topic = FileJMSConfiguration.parseTopicConfiguration(document.getDocumentElement());
ActiveMQTopic activeMQTopic = ActiveMQDestination.createTopic(topic.getName());
String topicName = activeMQTopic.getAddress();
ClientSession session = manager.getSessionFactory().createSession(false, false, false);
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/main/resources/schema/hornetq-rest.xsd
----------------------------------------------------------------------
diff --git a/activemq-rest/src/main/resources/schema/hornetq-rest.xsd b/activemq-rest/src/main/resources/schema/hornetq-rest.xsd
index ede8a11..de52b74 100644
--- a/activemq-rest/src/main/resources/schema/hornetq-rest.xsd
+++ b/activemq-rest/src/main/resources/schema/hornetq-rest.xsd
@@ -15,8 +15,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<xsd:schema xmlns="urn:activemq" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:activemq">
+<xsd:schema xmlns="urn:activemq:rest" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:activemq:rest">
<xsd:element name="rest-messaging">
<xsd:complexType>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/test/java/org/apache/activemq/rest/test/EmbeddedTest.java
----------------------------------------------------------------------
diff --git a/activemq-rest/src/test/java/org/apache/activemq/rest/test/EmbeddedTest.java b/activemq-rest/src/test/java/org/apache/activemq/rest/test/EmbeddedTest.java
index 1ab39d4..e5a322d 100644
--- a/activemq-rest/src/test/java/org/apache/activemq/rest/test/EmbeddedTest.java
+++ b/activemq-rest/src/test/java/org/apache/activemq/rest/test/EmbeddedTest.java
@@ -27,9 +27,11 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.activemq.api.jms.JMSFactoryType;
+import org.apache.activemq.core.config.impl.FileSecurityConfiguration;
import org.apache.activemq.rest.HttpHeaderProperty;
import org.apache.activemq.rest.integration.EmbeddedRestActiveMQJMS;
import org.apache.activemq.spi.core.naming.BindingRegistry;
+import org.apache.activemq.spi.core.security.ActiveMQSecurityManagerImpl;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.spi.Link;
@@ -51,6 +53,13 @@ public class EmbeddedTest
{
server = new EmbeddedRestActiveMQJMS();
server.getManager().setConfigResourcePath("activemq-rest.xml");
+ FileSecurityConfiguration securityConfiguration = new FileSecurityConfiguration("activemq-users.properties",
+ "activemq-roles.properties",
+ "guest",
+ false,
+ null);
+ securityConfiguration.start();
+ server.getEmbeddedJMS().setSecurityManager(new ActiveMQSecurityManagerImpl(securityConfiguration));
server.start();
List<String> connectors = new ArrayList<>();
connectors.add("in-vm");
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/test/resources/activemq-configuration.xml
----------------------------------------------------------------------
diff --git a/activemq-rest/src/test/resources/activemq-configuration.xml b/activemq-rest/src/test/resources/activemq-configuration.xml
index 13828ec..f8cb882 100644
--- a/activemq-rest/src/test/resources/activemq-configuration.xml
+++ b/activemq-rest/src/test/resources/activemq-configuration.xml
@@ -16,35 +16,42 @@
-->
<configuration xmlns="urn:activemq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:activemq /schema/activemq-configuration.xsd">
-
- <persistence-enabled>false</persistence-enabled>
- <!-- Connectors -->
-
- <connectors>
- <connector name="in-vm">
- <factory-class>org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
- </connector>
- </connectors>
-
- <acceptors>
- <acceptor name="in-vm">
- <factory-class>org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
- </acceptor>
- </acceptors>
-
- <!-- Other config -->
-
- <security-settings>
- <!--security for example queue-->
- <security-setting match="jms.queue.exampleQueue">
- <permission type="createDurableQueue" roles="guest"/>
- <permission type="deleteDurableQueue" roles="guest"/>
- <permission type="createNonDurableQueue" roles="guest"/>
- <permission type="deleteNonDurableQueue" roles="guest"/>
- <permission type="consume" roles="guest"/>
- <permission type="send" roles="guest"/>
- </security-setting>
- </security-settings>
+ xsi:schemaLocation="urn:activemq /schema/activemq-server.xsd">
+ <jms xmlns="urn:activemq:jms">
+ <!--the queue used by the example-->
+ <queue name="exampleQueue"/>
+ </jms>
+
+ <core xmlns="urn:activemq:core">
+
+ <persistence-enabled>false</persistence-enabled>
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="in-vm">
+ <factory-class>org.apache.activemq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+ </connector>
+ </connectors>
+
+ <acceptors>
+ <acceptor name="in-vm">
+ <factory-class>org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+ </acceptor>
+ </acceptors>
+
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.exampleQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue" roles="guest"/>
+ <permission type="deleteNonDurableQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+ </core>
</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/test/resources/activemq-jms.xml
----------------------------------------------------------------------
diff --git a/activemq-rest/src/test/resources/activemq-jms.xml b/activemq-rest/src/test/resources/activemq-jms.xml
deleted file mode 100644
index b6016bf..0000000
--- a/activemq-rest/src/test/resources/activemq-jms.xml
+++ /dev/null
@@ -1,24 +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.
--->
-<configuration xmlns="urn:activemq"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:activemq /schema/activemq-jms.xsd">
-
- <!--the queue used by the example-->
- <queue name="exampleQueue"/>
-
-</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/test/resources/activemq-roles.properties
----------------------------------------------------------------------
diff --git a/activemq-rest/src/test/resources/activemq-roles.properties b/activemq-rest/src/test/resources/activemq-roles.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/activemq-rest/src/test/resources/activemq-roles.properties
@@ -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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/test/resources/activemq-users.properties
----------------------------------------------------------------------
diff --git a/activemq-rest/src/test/resources/activemq-users.properties b/activemq-rest/src/test/resources/activemq-users.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/activemq-rest/src/test/resources/activemq-users.properties
@@ -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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-rest/src/test/resources/activemq-users.xml
----------------------------------------------------------------------
diff --git a/activemq-rest/src/test/resources/activemq-users.xml b/activemq-rest/src/test/resources/activemq-users.xml
deleted file mode 100644
index 61c6afe..0000000
--- a/activemq-rest/src/test/resources/activemq-users.xml
+++ /dev/null
@@ -1,23 +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.
--->
-<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:activemq /schema/activemq-users.xsd">
- <!-- the default user. this is used where username is null-->
- <defaultuser name="guest" password="guest">
- <role name="guest"/>
- </defaultuser>
-</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-server/src/main/java/org/apache/activemq/core/config/Configuration.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/config/Configuration.java b/activemq-server/src/main/java/org/apache/activemq/core/config/Configuration.java
index 22a0b0e..f6974cd 100644
--- a/activemq-server/src/main/java/org/apache/activemq/core/config/Configuration.java
+++ b/activemq-server/src/main/java/org/apache/activemq/core/config/Configuration.java
@@ -132,17 +132,6 @@ public interface Configuration extends Serializable
Configuration setSharedStore(boolean sharedStore);
/**
- * Returns whether this server will use files to configure and deploy its resources. <br>
- * Default value is {@value org.apache.activemq.api.config.ActiveMQDefaultConfiguration#DEFAULT_FILE_DEPLOYMENT_ENABLED}.
- */
- boolean isFileDeploymentEnabled();
-
- /**
- * Sets whether this server will use files to configure and deploy its resources.
- */
- Configuration setFileDeploymentEnabled(boolean enable);
-
- /**
* Returns whether this server is using persistence and store data. <br>
* Default value is {@value org.apache.activemq.api.config.ActiveMQDefaultConfiguration#DEFAULT_PERSISTENCE_ENABLED}.
*/
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-server/src/main/java/org/apache/activemq/core/config/FileDeploymentManager.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/config/FileDeploymentManager.java b/activemq-server/src/main/java/org/apache/activemq/core/config/FileDeploymentManager.java
new file mode 100644
index 0000000..66384bf
--- /dev/null
+++ b/activemq-server/src/main/java/org/apache/activemq/core/config/FileDeploymentManager.java
@@ -0,0 +1,115 @@
+/**
+ * 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.core.config;
+
+import org.apache.activemq.core.deployers.Deployable;
+import org.apache.activemq.core.server.ActiveMQComponent;
+import org.apache.activemq.spi.core.security.ActiveMQSecurityManager;
+import org.apache.activemq.utils.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.management.MBeanServer;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * ised to build a set of ActiveMQComponents from a set of Deployables pulled out of the configuration file
+ */
+public class FileDeploymentManager
+{
+ private static final String DEFAULT_CONFIGURATION_URL = "activemq-configuration.xml";
+
+ private final String configurationUrl;
+
+ LinkedHashMap<String, Deployable> deployables = new LinkedHashMap<>();
+
+ public FileDeploymentManager()
+ {
+ this.configurationUrl = DEFAULT_CONFIGURATION_URL;
+ }
+
+ public FileDeploymentManager(String configurationUrl)
+ {
+ this.configurationUrl = configurationUrl;
+ }
+
+ /*
+ * parse a set of configuration with the Deployables that were given.
+ */
+ public void readConfiguration() throws Exception
+ {
+ URL url = getClass().getClassLoader().getResource(configurationUrl);
+
+ if (url == null)
+ {
+ // The URL is outside of the classloader. Trying a pure url now
+ url = new URL(configurationUrl);
+ }
+ // create a reader
+ Reader reader = new InputStreamReader(url.openStream());
+ String xml = org.apache.activemq.utils.XMLUtil.readerToString(reader);
+ //replace any system props
+ xml = XMLUtil.replaceSystemProps(xml);
+ Element e = org.apache.activemq.utils.XMLUtil.stringToElement(xml);
+
+ //iterate around all the deployables
+ for (Deployable deployable : deployables.values())
+ {
+ String root = deployable.getRootElement();
+ NodeList children = e.getElementsByTagName(root);
+ //if the root element exists then parse it
+ if (root != null && children.getLength() > 0)
+ {
+ Node item = children.item(0);
+ XMLUtil.validate(item, deployable.getSchema());
+ deployable.parse((Element) item);
+ }
+ }
+ }
+
+ /*
+ * Build a set of ActiveMQComponents from the Deployables configured
+ */
+ public Map<String, ActiveMQComponent> buildService(ActiveMQSecurityManager securityManager, MBeanServer mBeanServer) throws Exception
+ {
+ Map<String, ActiveMQComponent> components = new HashMap<>();
+ for (Deployable deployable : deployables.values())
+ {
+ // if the deployable was parsed then build the service
+ if (deployable.isParsed())
+ {
+ deployable.buildService(securityManager, mBeanServer, deployables, components);
+ }
+ }
+ return components;
+ }
+
+ /*
+ * add a Deployable to be configured
+ */
+ public FileDeploymentManager addDeployable(Deployable deployable)
+ {
+ deployables.put(deployable.getRootElement(), deployable);
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/ConfigurationImpl.java b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/ConfigurationImpl.java
index 0c69c2b..f951099 100644
--- a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/ConfigurationImpl.java
+++ b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/ConfigurationImpl.java
@@ -65,8 +65,6 @@ public class ConfigurationImpl implements Configuration
private String name = "ConfigurationImpl::" + System.identityHashCode(this);
- protected boolean fileDeploymentEnabled = ActiveMQDefaultConfiguration.isDefaultFileDeploymentEnabled();
-
private boolean persistenceEnabled = ActiveMQDefaultConfiguration.isDefaultPersistenceEnabled();
protected long fileDeploymentScanPeriod = ActiveMQDefaultConfiguration.getDefaultFileDeployerScanPeriod();
@@ -224,17 +222,6 @@ public class ConfigurationImpl implements Configuration
return !getClusterConfigurations().isEmpty();
}
- public boolean isFileDeploymentEnabled()
- {
- return fileDeploymentEnabled;
- }
-
- public ConfigurationImpl setFileDeploymentEnabled(final boolean enable)
- {
- fileDeploymentEnabled = enable;
- return this;
- }
-
public boolean isPersistenceEnabled()
{
return persistenceEnabled;
@@ -1360,7 +1347,6 @@ public class ConfigurationImpl implements Configuration
result = prime * result + ((discoveryGroupConfigurations == null) ? 0 : discoveryGroupConfigurations.hashCode());
result = prime * result + ((divertConfigurations == null) ? 0 : divertConfigurations.hashCode());
result = prime * result + (failoverOnServerShutdown ? 1231 : 1237);
- result = prime * result + (fileDeploymentEnabled ? 1231 : 1237);
result = prime * result + (int)(fileDeploymentScanPeriod ^ (fileDeploymentScanPeriod >>> 32));
result = prime * result + ((groupingHandlerConfiguration == null) ? 0 : groupingHandlerConfiguration.hashCode());
result = prime * result + idCacheSize;
@@ -1528,8 +1514,6 @@ public class ConfigurationImpl implements Configuration
return false;
if (failoverOnServerShutdown != other.failoverOnServerShutdown)
return false;
- if (fileDeploymentEnabled != other.fileDeploymentEnabled)
- return false;
if (fileDeploymentScanPeriod != other.fileDeploymentScanPeriod)
return false;
if (groupingHandlerConfiguration == null)
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileConfiguration.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileConfiguration.java b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileConfiguration.java
index f4bfd21..0d19be2 100644
--- a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileConfiguration.java
+++ b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileConfiguration.java
@@ -16,68 +16,39 @@
*/
package org.apache.activemq.core.config.impl;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
+import java.util.Map;
+import org.apache.activemq.core.deployers.Deployable;
import org.apache.activemq.core.deployers.impl.FileConfigurationParser;
-import org.apache.activemq.core.server.ActiveMQServerLogger;
-import org.apache.activemq.utils.XMLUtil;
+import org.apache.activemq.core.server.ActiveMQComponent;
+import org.apache.activemq.core.server.impl.ActiveMQServerImpl;
+import org.apache.activemq.spi.core.security.ActiveMQSecurityManager;
import org.w3c.dom.Element;
+import javax.management.MBeanServer;
+
/**
* A {@code FileConfiguration} reads configuration values from a file.
*
* @author <a href="ataylor@redhat.com">Andy Taylor</a>
* @author <a href="tim.fox@jboss.com">Tim Fox</a>
*/
-public final class FileConfiguration extends ConfigurationImpl
+public final class FileConfiguration extends ConfigurationImpl implements Deployable
{
private static final long serialVersionUID = -4766689627675039596L;
- // Constants ------------------------------------------------------------------------
- private static final String DEFAULT_CONFIGURATION_URL = "activemq-configuration.xml";
+ private static final String CONFIGURATION_SCHEMA_URL = "schema/activemq-configuration.xsd";
+
+ private static final String CONFIGURATION_SCHEMA_ROOT_ELEMENT = "core";
// For a bridge confirmations must be activated or send acknowledgments won't return
public static final int DEFAULT_CONFIRMATION_WINDOW_SIZE = 1024 * 1024;
- public FileConfiguration()
- {
- configurationUrl = DEFAULT_CONFIGURATION_URL;
- }
-
- public FileConfiguration(String configurationUrl)
- {
- this.configurationUrl = configurationUrl;
- }
-
- private String configurationUrl = DEFAULT_CONFIGURATION_URL;
-
- private boolean started;
+ private boolean parsed = false;
- public synchronized void start() throws Exception
+ @Override
+ public void parse(Element config) throws Exception
{
- if (started)
- {
- return;
- }
-
-
- URL url = getClass().getClassLoader().getResource(configurationUrl);
-
- if (url == null)
- {
- // The URL is outside of the classloader. Trying a pure url now
- url = new URL(configurationUrl);
- }
-
- ActiveMQServerLogger.LOGGER.debug("Loading server configuration from " + url);
-
- Reader reader = new InputStreamReader(url.openStream());
- String xml = org.apache.activemq.utils.XMLUtil.readerToString(reader);
- xml = XMLUtil.replaceSystemProps(xml);
- Element e = org.apache.activemq.utils.XMLUtil.stringToElement(xml);
-
FileConfigurationParser parser = new FileConfigurationParser();
// https://jira.jboss.org/browse/HORNETQ-478 - We only want to validate AIO when
@@ -85,24 +56,32 @@ public final class FileConfiguration extends ConfigurationImpl
// and we don't want to do it when deploying activemq-queues.xml which uses the same parser and XML format
parser.setValidateAIO(true);
- parser.parseMainConfig(e, this);
+ parser.parseMainConfig(config, this);
- started = true;
+ parsed = true;
+ }
+ @Override
+ public boolean isParsed()
+ {
+ return parsed;
}
- public synchronized void stop() throws Exception
+ @Override
+ public String getRootElement()
{
- started = false;
+ return CONFIGURATION_SCHEMA_ROOT_ELEMENT;
}
- public String getConfigurationUrl()
+ @Override
+ public void buildService(ActiveMQSecurityManager securityManager, MBeanServer mBeanServer, Map<String, Deployable> deployables, Map<String, ActiveMQComponent> components)
{
- return configurationUrl;
+ components.put(getRootElement(), new ActiveMQServerImpl(this, mBeanServer, securityManager));
}
- public void setConfigurationUrl(final String configurationUrl)
+ @Override
+ public String getSchema()
{
- this.configurationUrl = configurationUrl;
+ return CONFIGURATION_SCHEMA_URL;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileSecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileSecurityConfiguration.java b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileSecurityConfiguration.java
new file mode 100644
index 0000000..554e759
--- /dev/null
+++ b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/FileSecurityConfiguration.java
@@ -0,0 +1,127 @@
+/**
+ * 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.core.config.impl;
+
+import org.apache.activemq.utils.PasswordMaskingUtil;
+import org.apache.activemq.utils.SensitiveDataCodec;
+
+import java.net.URL;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class FileSecurityConfiguration extends SecurityConfiguration
+{
+ private final String usersUrl;
+
+ private final String rolesUrl;
+
+ private boolean maskPassword;
+
+ private String passwordCodec;
+
+ private boolean started;
+
+ public FileSecurityConfiguration(String usersUrl, String rolesUrl, String defaultUser, Boolean maskPassword, String passwordCodec)
+ {
+ this.usersUrl = usersUrl;
+ this.rolesUrl = rolesUrl;
+ this.defaultUser = defaultUser;
+ this.maskPassword = maskPassword;
+ this.passwordCodec = passwordCodec;
+ }
+
+ public void stop() throws Exception
+ {
+ users.clear();
+
+ roles.clear();
+
+ defaultUser = null;
+ }
+
+ public boolean isStarted()
+ {
+ return true;
+ }
+
+
+ public synchronized void start() throws Exception
+ {
+ if (started)
+ {
+ return;
+ }
+ SensitiveDataCodec<String> codec = null;
+ if (maskPassword)
+ {
+ if (passwordCodec != null)
+ {
+ codec = PasswordMaskingUtil.getDefaultCodec();
+ }
+ else
+ {
+ codec = PasswordMaskingUtil.getCodec(passwordCodec);
+ }
+ }
+ URL theUsersUrl = getClass().getClassLoader().getResource(usersUrl);
+
+ if (theUsersUrl == null)
+ {
+ // The URL is outside of the classloader. Trying a pure url now
+ theUsersUrl = new URL(usersUrl);
+ }
+ Properties userProps = new Properties();
+ userProps.load(theUsersUrl.openStream());
+ URL theRolesUrl = getClass().getClassLoader().getResource(usersUrl);
+
+ if (theRolesUrl == null)
+ {
+ // The URL is outside of the classloader. Trying a pure url now
+ theRolesUrl = new URL(rolesUrl);
+ }
+ Properties roleProps = new Properties();
+ roleProps.load(theRolesUrl.openStream());
+
+ Set<String> keys = userProps.stringPropertyNames();
+
+ for (String username : keys)
+ {
+ String password = userProps.getProperty(username);
+ if (codec != null)
+ {
+ password = codec.decode(password);
+ }
+ addUser(username, password);
+ }
+
+ for (String username : keys)
+ {
+ String roles = roleProps.getProperty(username);
+ String[] split = roles.split(",");
+ for (String role : split)
+ {
+ addRole(username, role.trim());
+ }
+ }
+
+ started = true;
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java
new file mode 100644
index 0000000..81decfd
--- /dev/null
+++ b/activemq-server/src/main/java/org/apache/activemq/core/config/impl/SecurityConfiguration.java
@@ -0,0 +1,103 @@
+/**
+ * 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.core.config.impl;
+
+import org.apache.activemq.core.security.User;
+import org.apache.activemq.core.server.ActiveMQMessageBundle;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+public class SecurityConfiguration
+{ /**
+ * the current valid users
+ */
+ protected final Map<String, User> users = new HashMap<String, User>();
+
+ protected String defaultUser = null;
+
+ /**
+ * the roles for the users
+ */
+ protected final Map<String, List<String>> roles = new HashMap<String, List<String>>();
+
+
+ public void addUser(final String user, final String password)
+ {
+ if (user == null)
+ {
+ throw ActiveMQMessageBundle.BUNDLE.nullUser();
+ }
+ if (password == null)
+ {
+ throw ActiveMQMessageBundle.BUNDLE.nullPassword();
+ }
+ users.put(user, new User(user, password));
+ }
+
+ public void removeUser(final String user)
+ {
+ users.remove(user);
+ roles.remove(user);
+ }
+
+ public void addRole(final String user, final String role)
+ {
+ if (roles.get(user) == null)
+ {
+ roles.put(user, new ArrayList<String>());
+ }
+ roles.get(user).add(role);
+ }
+
+ public void removeRole(final String user, final String role)
+ {
+ if (roles.get(user) == null)
+ {
+ return;
+ }
+ roles.get(user).remove(role);
+ }
+
+ /*
+ * set the default user for null users
+ */
+ public void setDefaultUser(final String username)
+ {
+ defaultUser = username;
+ }
+
+ public String getDefaultUser()
+ {
+ return defaultUser;
+ }
+
+ public org.apache.activemq.core.security.User getUser(String username)
+ {
+ return users.get(username);
+ }
+
+ public List<String> getRole(String username)
+ {
+ return roles.get(username);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-server/src/main/java/org/apache/activemq/core/deployers/Deployable.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/deployers/Deployable.java b/activemq-server/src/main/java/org/apache/activemq/core/deployers/Deployable.java
new file mode 100644
index 0000000..282bda4
--- /dev/null
+++ b/activemq-server/src/main/java/org/apache/activemq/core/deployers/Deployable.java
@@ -0,0 +1,57 @@
+/**
+ * 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.core.deployers;
+
+import org.apache.activemq.core.server.ActiveMQComponent;
+import org.apache.activemq.spi.core.security.ActiveMQSecurityManager;
+import org.w3c.dom.Element;
+
+import javax.management.MBeanServer;
+import java.util.Map;
+
+/**
+ * A Deployable is an object that can be configured via an xml configuration element in the main configuration file "activemq-configuration.xml"
+ * It holds all the information needed by the FileDeploymentManager to parse the configuration and build the component
+ */
+public interface Deployable
+{
+ /*
+ * parse the element from the xml configuration
+ */
+ void parse(Element config) throws Exception;
+
+ /*
+ * has this Deployable been parsed
+ */
+ boolean isParsed();
+
+ /*
+ * The name of the root xml element for this Deployable, i.e. core or jms
+ */
+ String getRootElement();
+
+ /*
+ * The schema that should be used to validate the xml
+ */
+ String getSchema();
+
+ /*
+ * builds the service. The implementation should add a component to the components map passed in if it needs to.
+ */
+ void buildService(ActiveMQSecurityManager securityManager, MBeanServer mBeanServer, Map<String, Deployable> deployables, Map<String, ActiveMQComponent> components) throws Exception;
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/4b63891a/activemq-server/src/main/java/org/apache/activemq/core/deployers/Deployer.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/deployers/Deployer.java b/activemq-server/src/main/java/org/apache/activemq/core/deployers/Deployer.java
deleted file mode 100644
index cfdc722..0000000
--- a/activemq-server/src/main/java/org/apache/activemq/core/deployers/Deployer.java
+++ /dev/null
@@ -1,57 +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.core.deployers;
-
-import java.net.URI;
-
-import org.apache.activemq.core.server.ActiveMQComponent;
-
-/**
- * abstract class that helps with deployment of messaging components.
- *
- * @author <a href="ataylor@redhat.com">Andy Taylor</a>
- */
-public interface Deployer extends ActiveMQComponent
-{
- /**
- * The name of the configuration files to look for for deployment
- *
- * @return The names of the config files
- */
- String[] getConfigFileNames();
-
- /**
- * Deploy the URL for the first time
- * @param uri The resource todeploy
- * @throws Exception
- */
- void deploy(URI uri) throws Exception;
-
- /**
- * Redeploys a URL if changed
- * @param uri The resource to redeploy
- * @throws Exception
- */
- void redeploy(URI uri) throws Exception;
-
- /**
- * Undeploys a resource that has been removed
- * @param uri The Resource that was deleted
- * @throws Exception
- */
- void undeploy(URI uri) throws Exception;
-}
\ No newline at end of file