ARTEMIS-3224 Removing Artemis-tools migration tool from 1.x address model
This commit is contained in:
parent
7868959b52
commit
158a94a836
|
@ -68,11 +68,6 @@
|
|||
<artifactId>artemis-jms-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>artemis-tools</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>artemis-dto</artifactId>
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.apache.activemq.artemis.cli.commands.address.UpdateAddress;
|
|||
import org.apache.activemq.artemis.cli.commands.messages.Browse;
|
||||
import org.apache.activemq.artemis.cli.commands.messages.Consumer;
|
||||
import org.apache.activemq.artemis.cli.commands.messages.Producer;
|
||||
import org.apache.activemq.artemis.cli.commands.migration1x.Migrate1X;
|
||||
import org.apache.activemq.artemis.cli.commands.queue.CreateQueue;
|
||||
import org.apache.activemq.artemis.cli.commands.queue.DeleteQueue;
|
||||
import org.apache.activemq.artemis.cli.commands.queue.HelpQueue;
|
||||
|
@ -177,7 +176,6 @@ public class Artemis {
|
|||
builder.withGroup("data").withDescription("data tools group (print) (example ./artemis data print)").
|
||||
withDefaultCommand(HelpData.class).withCommands(PrintData.class);
|
||||
builder = builder.withCommand(Create.class);
|
||||
builder = builder.withCommand(Migrate1X.class);
|
||||
}
|
||||
|
||||
return builder;
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.cli.commands.migration1x;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.airlift.airline.Arguments;
|
||||
import io.airlift.airline.Command;
|
||||
import org.apache.activemq.artemis.cli.commands.ActionAbstract;
|
||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||
import org.apache.activemq.artemis.tools.migrate.config.Main;
|
||||
|
||||
@Command(name = "migrate1x", description = "Migrates the configuration of a 1.x Artemis Broker")
|
||||
public class Migrate1X extends ActionAbstract {
|
||||
|
||||
@Arguments(description = "The instance directory to hold the broker's configuration and data. Path must be writable.", required = true)
|
||||
File directory;
|
||||
|
||||
@Override
|
||||
public Object execute(ActionContext context) throws Exception {
|
||||
if (!directory.exists()) {
|
||||
throw new RuntimeException(String.format("The path '%s' does not exist.", directory));
|
||||
}
|
||||
super.execute(context);
|
||||
return run(context);
|
||||
}
|
||||
|
||||
public Object run(ActionContext context) throws Exception {
|
||||
Main.scanAndTransform(directory);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -132,11 +132,6 @@
|
|||
<artifactId>artemis-jdbc-store</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>artemis-tools</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>artemis-website</artifactId>
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
<include>org.apache.activemq:artemis-ra</include>
|
||||
<include>org.apache.activemq:artemis-selector</include>
|
||||
<include>org.apache.activemq:artemis-server</include>
|
||||
<include>org.apache.activemq:artemis-tools</include>
|
||||
<include>org.apache.activemq:artemis-service-extensions</include>
|
||||
<include>org.apache.activemq:artemis-web</include>
|
||||
<include>org.apache.activemq.rest:artemis-rest</include>
|
||||
|
|
|
@ -1,60 +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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>artemis-pom</artifactId>
|
||||
<version>2.18.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>artemis-tools</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>ActiveMQ Artemis Tools</name>
|
||||
|
||||
<properties>
|
||||
<activemq.basedir>${project.basedir}/..</activemq.basedir>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>error_prone_core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tools.migrate.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
if (args.length == 0) {
|
||||
System.err.println("Invalid args");
|
||||
printUsage();
|
||||
} else {
|
||||
File input = new File(args[0]);
|
||||
if (input.isDirectory()) {
|
||||
System.out.println("Scanning directory: " + input.getAbsolutePath());
|
||||
scanAndTransform(input);
|
||||
} else {
|
||||
if (args.length != 2) {
|
||||
System.err.println("Invalid args");
|
||||
printUsage();
|
||||
} else {
|
||||
try {
|
||||
XMLConfigurationMigration migration = new XMLConfigurationMigration(input, new File(args[1]));
|
||||
migration.transform();
|
||||
} catch (Exception e) {
|
||||
// Unable to process file, move on.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void recursiveTransform(File root) throws Exception {
|
||||
for (File file : root.listFiles()) {
|
||||
scanAndTransform(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static void scanAndTransform(File f) throws Exception {
|
||||
try {
|
||||
if (f.isDirectory()) {
|
||||
recursiveTransform(f);
|
||||
} else {
|
||||
try {
|
||||
if (f.getName().endsWith("xml")) {
|
||||
File file = new File(f.getAbsolutePath() + ".new");
|
||||
XMLConfigurationMigration migration = new XMLConfigurationMigration(f, file);
|
||||
if (migration.transform()) {
|
||||
File r = new File(f.getAbsolutePath());
|
||||
f.renameTo(new File(f.getAbsolutePath() + ".bk"));
|
||||
file.renameTo(r);
|
||||
System.out.println(f + " converted, old file renamed as " + f.getAbsolutePath() + ".bk");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//Unable to process file, continue
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
System.out.println(f.getAbsoluteFile());
|
||||
}
|
||||
}
|
||||
|
||||
public static void printUsage() {
|
||||
System.out.println("Please specify a directory to scan, or input and output file");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,307 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tools.migrate.config;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.activemq.artemis.tools.migrate.config.addressing.Address;
|
||||
import org.apache.activemq.artemis.tools.migrate.config.addressing.Queue;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class XMLConfigurationMigration {
|
||||
|
||||
// Attributes
|
||||
private static final String xPathAttrName = "@name";
|
||||
|
||||
// JMS XPaths
|
||||
private static final String xPathJMS = "/configuration/jms";
|
||||
|
||||
private static final String xPathJMSQueues = "/configuration/jms/queue";
|
||||
|
||||
private static final String xPathJMSTopics = "/configuration/jms/topic";
|
||||
|
||||
// Core Queue XPaths
|
||||
private static final String xPathQueues = "/configuration/core/queues";
|
||||
|
||||
private static final String xPathQueue = "/configuration/core/queues/queue";
|
||||
|
||||
private static final String xPathAddress = "address";
|
||||
|
||||
private static final String xPathFilter = "filter/@string";
|
||||
|
||||
private static final String xPathSelector = "selector/@string";
|
||||
|
||||
private static final String xPathDurable = "durable";
|
||||
|
||||
private final Map<String, Address> coreAddresses = new HashMap<>();
|
||||
|
||||
private final Document document;
|
||||
|
||||
private final File input;
|
||||
|
||||
private final File output;
|
||||
|
||||
private final Node coreElement;
|
||||
|
||||
private final XPath xPath;
|
||||
|
||||
public XMLConfigurationMigration(File input, File output) throws Exception {
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
|
||||
try {
|
||||
if (!input.exists()) {
|
||||
throw new Exception("Input file not found: " + input);
|
||||
}
|
||||
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder db = factory.newDocumentBuilder();
|
||||
this.document = db.parse(this.input);
|
||||
|
||||
xPath = XPathFactory.newInstance().newXPath();
|
||||
coreElement = (Node) xPath.evaluate("/configuration/core", document, XPathConstants.NODE);
|
||||
|
||||
if (coreElement == null) {
|
||||
throw new Exception("Not a artemis config");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean transform() throws Exception {
|
||||
try {
|
||||
|
||||
boolean queuesChanged = convertQueuesToAddresses();
|
||||
boolean jmsChanged = convertJMSToAddresses();
|
||||
|
||||
writeAddressesToDocument();
|
||||
document.normalize();
|
||||
|
||||
if (queuesChanged || jmsChanged) {
|
||||
Properties properties = new Properties();
|
||||
properties.put(OutputKeys.INDENT, "yes");
|
||||
properties.put("{http://xml.apache.org/xslt}indent-amount", "3");
|
||||
properties.put(OutputKeys.ENCODING, "UTF-8");
|
||||
write(output, properties);
|
||||
return true;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error tranforming document");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean convertQueuesToAddresses() throws Exception {
|
||||
|
||||
Node coreQueuesElement = getNode(xPathQueues);
|
||||
if (coreQueuesElement == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NodeList coreQueueElements = getNodeList(xPathQueue);
|
||||
for (int i = 0; i < coreQueueElements.getLength(); i++) {
|
||||
Node queueNode = coreQueueElements.item(i);
|
||||
|
||||
Queue queue = new Queue();
|
||||
queue.setName(getString(queueNode, xPathAttrName));
|
||||
queue.setDurable(getString(queueNode, xPathDurable));
|
||||
queue.setFilter(getString(queueNode, xPathFilter));
|
||||
queue.setRoutingType("multicast");
|
||||
|
||||
String addressName = getString(queueNode, xPathAddress);
|
||||
|
||||
Address address;
|
||||
if (coreAddresses.containsKey(addressName)) {
|
||||
address = coreAddresses.get(addressName);
|
||||
} else {
|
||||
address = new Address();
|
||||
address.setName(addressName);
|
||||
coreAddresses.put(addressName, address);
|
||||
}
|
||||
address.getQueues().add(queue);
|
||||
address.getRoutingTypes().add("multicast");
|
||||
}
|
||||
|
||||
// Remove Core Queues Element from Core
|
||||
Node queues = getNode(xPathQueues);
|
||||
if (queues != null) {
|
||||
coreElement.removeChild(queues);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean convertJMSToAddresses() throws Exception {
|
||||
Node jmsElement = getNode(xPathJMS);
|
||||
if (jmsElement == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NodeList jmsQueueElements = getNodeList(xPathJMSQueues);
|
||||
for (int i = 0; i < jmsQueueElements.getLength(); i++) {
|
||||
Node jmsQueueElement = jmsQueueElements.item(i);
|
||||
String name = getString(jmsQueueElement, xPathAttrName);
|
||||
|
||||
Address address;
|
||||
if (coreAddresses.containsKey(name)) {
|
||||
address = coreAddresses.get(name);
|
||||
} else {
|
||||
address = new Address();
|
||||
address.setName(name);
|
||||
address.getRoutingTypes().add("anycast");
|
||||
coreAddresses.put(name, address);
|
||||
}
|
||||
|
||||
Queue queue = new Queue();
|
||||
queue.setName(name);
|
||||
queue.setDurable(getString(jmsQueueElement, xPathDurable));
|
||||
queue.setFilter(getString(jmsQueueElement, xPathSelector));
|
||||
queue.setRoutingType("anycast");
|
||||
address.getQueues().add(queue);
|
||||
address.getRoutingTypes().add("anycast");
|
||||
}
|
||||
|
||||
NodeList jmsTopicElements = getNodeList(xPathJMSTopics);
|
||||
for (int i = 0; i < jmsTopicElements.getLength(); i++) {
|
||||
Node jmsTopicElement = jmsTopicElements.item(i);
|
||||
String name = getString(jmsTopicElement, xPathAttrName);
|
||||
|
||||
Address address;
|
||||
if (coreAddresses.containsKey(name)) {
|
||||
address = coreAddresses.get(name);
|
||||
} else {
|
||||
address = new Address();
|
||||
address.setName(name);
|
||||
address.getRoutingTypes().add("multicast");
|
||||
coreAddresses.put(name, address);
|
||||
}
|
||||
address.getRoutingTypes().add("multicast");
|
||||
}
|
||||
|
||||
jmsElement.getParentNode().removeChild(jmsElement);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void writeAddressesToDocument() throws XPathExpressionException {
|
||||
|
||||
Element addressElement = document.createElement("addresses");
|
||||
writeAddressListToDoc(coreAddresses.values(), addressElement);
|
||||
coreElement.appendChild(addressElement);
|
||||
}
|
||||
|
||||
private void writeAddressListToDoc(Collection<Address> addresses,
|
||||
Node addressElement) throws XPathExpressionException {
|
||||
if (addresses.isEmpty())
|
||||
return;
|
||||
|
||||
for (Address addr : addresses) {
|
||||
Element eAddr = document.createElement("address");
|
||||
eAddr.setAttribute("name", addr.getName());
|
||||
|
||||
Element eMulticast = null;
|
||||
if (addr.getRoutingTypes().contains("multicast")) {
|
||||
eMulticast = (Element) eAddr.getElementsByTagName("multicast").item(0);
|
||||
if (eMulticast == null) {
|
||||
eMulticast = document.createElement("multicast");
|
||||
eAddr.appendChild(eMulticast);
|
||||
}
|
||||
}
|
||||
|
||||
Element eAnycast = null;
|
||||
if (addr.getRoutingTypes().contains("anycast")) {
|
||||
eAnycast = (Element) eAddr.getElementsByTagName("anycast").item(0);
|
||||
if (eAnycast == null) {
|
||||
eAnycast = document.createElement("anycast");
|
||||
eAddr.appendChild(eAnycast);
|
||||
}
|
||||
}
|
||||
|
||||
if (addr.getQueues().size() > 0) {
|
||||
for (Queue queue : addr.getQueues()) {
|
||||
Element eQueue = document.createElement("queue");
|
||||
eQueue.setAttribute("name", queue.getName());
|
||||
|
||||
if (queue.getDurable() != null && !queue.getDurable().isEmpty()) {
|
||||
Element eDurable = document.createElement("durable");
|
||||
eDurable.setTextContent(queue.getDurable());
|
||||
eQueue.appendChild(eDurable);
|
||||
}
|
||||
|
||||
if (queue.getFilter() != null && !queue.getFilter().isEmpty()) {
|
||||
Element eFilter = document.createElement("filter");
|
||||
eFilter.setAttribute("string", queue.getFilter());
|
||||
eQueue.appendChild(eFilter);
|
||||
}
|
||||
|
||||
if (queue.getRoutingType().equals("anycast")) {
|
||||
eAnycast.appendChild(eQueue);
|
||||
} else if (queue.getRoutingType().equals("multicast")) {
|
||||
eMulticast.appendChild(eQueue);
|
||||
} else {
|
||||
System.err.print("Unknown Routing Type Found for Queue: " + queue.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
addressElement.appendChild(eAddr);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(File output, Properties outputProperties) throws TransformerException {
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
transformer.setOutputProperties(outputProperties);
|
||||
StreamResult streamResult = new StreamResult(output);
|
||||
transformer.transform(new DOMSource(document), streamResult);
|
||||
}
|
||||
|
||||
private String getString(Node node, String xPathQuery) throws XPathExpressionException {
|
||||
return xPath.evaluate(xPathQuery, node, XPathConstants.STRING).toString();
|
||||
}
|
||||
|
||||
private NodeList getNodeList(String xPathQuery) throws XPathExpressionException {
|
||||
return (NodeList) xPath.evaluate(xPathQuery, document, XPathConstants.NODESET);
|
||||
}
|
||||
|
||||
private Node getNode(String xPathQuery) throws XPathExpressionException {
|
||||
return (Node) xPath.evaluate(xPathQuery, document, XPathConstants.NODE);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tools.migrate.config.addressing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Address {
|
||||
|
||||
private String name;
|
||||
|
||||
private Set<String> routingTypes = new HashSet<>();
|
||||
|
||||
private String defaultMaxConsumers = "-1";
|
||||
|
||||
private String defaultPurgeOnNoConsumers = "false";
|
||||
|
||||
private List<Queue> queues = new ArrayList<>();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Set<String> getRoutingTypes() {
|
||||
return routingTypes;
|
||||
}
|
||||
|
||||
public void setRoutingTypes(Set<String> routingTypes) {
|
||||
this.routingTypes = routingTypes;
|
||||
}
|
||||
|
||||
public String getDefaultMaxConsumers() {
|
||||
return defaultMaxConsumers;
|
||||
}
|
||||
|
||||
public List<Queue> getQueues() {
|
||||
return queues;
|
||||
}
|
||||
|
||||
public void setQueues(List<Queue> queues) {
|
||||
this.queues = queues;
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tools.migrate.config.addressing;
|
||||
|
||||
public class Queue {
|
||||
|
||||
String name;
|
||||
|
||||
String filter;
|
||||
|
||||
String durable;
|
||||
|
||||
String routingType;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(String filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public String getDurable() {
|
||||
return durable;
|
||||
}
|
||||
|
||||
public void setDurable(String durable) {
|
||||
this.durable = durable;
|
||||
}
|
||||
|
||||
public String getRoutingType() {
|
||||
return routingType;
|
||||
}
|
||||
|
||||
public void setRoutingType(String routingType) {
|
||||
this.routingType = routingType;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: org.apache.activemq.artemis.tools.migrate.config.Main
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tools.migrate.config;
|
||||
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class XMLConfigurationMigrationTest {
|
||||
|
||||
@Test
|
||||
public void testQueuesReplacedWithAddresses() throws Exception {
|
||||
File brokerXml = new File(this.getClass().getClassLoader().getResource("broker.xml").toURI());
|
||||
File output = new File("target/out.xml");
|
||||
|
||||
XMLConfigurationMigration tool = new XMLConfigurationMigration(brokerXml, output);
|
||||
|
||||
tool.transform();
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put(OutputKeys.INDENT, "yes");
|
||||
properties.put("{http://xml.apache.org/xslt}indent-amount", "3");
|
||||
properties.put(OutputKeys.ENCODING, "UTF-8");
|
||||
tool.write(output, properties);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scanAndReplaceTest() throws Exception {
|
||||
File dir = new File(this.getClass().getClassLoader().getResource("replace").getPath());
|
||||
Main.scanAndTransform(dir);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<xsd:schema xmlns="urn:activemq"
|
||||
targetNamespace="urn:activemq"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
attributeFormDefault="unqualified"
|
||||
elementFormDefault="qualified"
|
||||
version="1.0">
|
||||
<xsd:element name="configuration">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Root element for a document specifying the configuration
|
||||
of a single "standalone" server that does not operate
|
||||
as part of a domain.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:any namespace="##other">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>A profile declaration may include configuration
|
||||
elements from other namespaces for the subsystems that make up the profile.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:any>
|
||||
</xsd:choice>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
|
@ -1,76 +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/artemis-server.xsd">
|
||||
<jms xmlns="urn:activemq:jms">
|
||||
<queue name="queue1">
|
||||
<durable>true</durable>
|
||||
<selector string="car='red'" />
|
||||
</queue>
|
||||
|
||||
<queue name="queue2"/>
|
||||
<queue name="queue3"/>
|
||||
|
||||
<topic name="topic1"/>
|
||||
<topic name="topic2"/>
|
||||
<topic name="topic3"/>
|
||||
|
||||
<queue name="orders"/>
|
||||
<topic name="orders"/>
|
||||
</jms>
|
||||
|
||||
<core xmlns="urn:activemq:core">
|
||||
|
||||
<persistence-enabled>false</persistence-enabled>
|
||||
<!-- Connectors -->
|
||||
|
||||
<connectors>
|
||||
<connector name="in-vm">vm://0</connector>
|
||||
</connectors>
|
||||
|
||||
<acceptors>
|
||||
<acceptor name="in-vm">vm://0</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>
|
||||
|
||||
<queues>
|
||||
<queue name="foo">
|
||||
<address>bar</address>
|
||||
</queue>
|
||||
<queue name="bar">
|
||||
<address>afar</address>
|
||||
<durable>true</durable>
|
||||
<filter string="name='car'" />
|
||||
</queue>
|
||||
</queues>
|
||||
</core>
|
||||
|
||||
</configuration>
|
|
@ -1,64 +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/artemis-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">vm://0</connector>
|
||||
</connectors>
|
||||
|
||||
<acceptors>
|
||||
<acceptor name="in-vm">vm://0</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>
|
||||
|
||||
<queues>
|
||||
<queue name="foo">
|
||||
<address>bar</address>
|
||||
</queue>
|
||||
<queue name="bar">
|
||||
<address>afar</address>
|
||||
<durable>true</durable>
|
||||
<filter string="name='car'" />
|
||||
</queue>
|
||||
</queues>
|
||||
</core>
|
||||
|
||||
</configuration>
|
|
@ -1,64 +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/artemis-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">vm://0</connector>
|
||||
</connectors>
|
||||
|
||||
<acceptors>
|
||||
<acceptor name="in-vm">vm://0</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>
|
||||
|
||||
<queues>
|
||||
<queue name="foo">
|
||||
<address>bar</address>
|
||||
</queue>
|
||||
<queue name="bar">
|
||||
<address>afar</address>
|
||||
<durable>true</durable>
|
||||
<filter string="name='car'" />
|
||||
</queue>
|
||||
</queues>
|
||||
</core>
|
||||
|
||||
</configuration>
|
3
pom.xml
3
pom.xml
|
@ -62,7 +62,6 @@
|
|||
<module>artemis-hawtio</module>
|
||||
<module>integration/activemq-spring-integration</module>
|
||||
<module>artemis-distribution</module>
|
||||
<module>artemis-tools</module>
|
||||
<module>tests</module>
|
||||
<module>artemis-features</module>
|
||||
</modules>
|
||||
|
@ -1375,7 +1374,6 @@
|
|||
<fileset dir="${activemq.basedir}/artemis-server/target/classes" />
|
||||
<fileset dir="${activemq.basedir}/artemis-server-osgi/target/classes" />
|
||||
<fileset dir="${activemq.basedir}/artemis-service-extensions/target" />
|
||||
<fileset dir="${activemq.basedir}/artemis-tools/target/classes" />
|
||||
<fileset dir="${activemq.basedir}/artemis-web/target/classes" />
|
||||
</classfiles>
|
||||
<sourcefiles encoding="UTF-8">
|
||||
|
@ -1396,7 +1394,6 @@
|
|||
<fileset dir="${activemq.basedir}/artemis-server/src/main/java" />
|
||||
<fileset dir="${activemq.basedir}/artemis-server-osgi/src/main/java" />
|
||||
<fileset dir="${activemq.basedir}/artemis-service-extensions/src/main/java" />
|
||||
<fileset dir="${activemq.basedir}/artemis-tools/src/main/java" />
|
||||
<fileset dir="${activemq.basedir}/artemis-web/src/main/java" />
|
||||
</sourcefiles>
|
||||
</structure>
|
||||
|
|
Loading…
Reference in New Issue