From 9d1c59cdff5c0084964611147a0433a165c8d989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Andr=C3=A9=20Pearce?= Date: Mon, 26 Feb 2018 09:31:21 +0000 Subject: [PATCH] ARTEMIS-1661 Support splitting of broker.xml Support XML standard XInclude thus allowing splitting of the broker.xml Added test cases with split out config using include. --- .../artemis/cli/commands/etc/broker.xml | 1 + .../activemq/artemis/utils/XMLUtil.java | 1 + .../schema/artemis-configuration.xsd | 71 ++++- .../config/impl/FileConfigurationTest.java | 8 +- .../impl/FileXIncludeConfigurationTest.java | 25 ++ ...nTest-xinclude-config-address-settings.xml | 66 ++++ ...gurationTest-xinclude-config-addresses.xml | 50 +++ ...Test-xinclude-config-security-settings.xml | 24 ++ .../ConfigurationTest-xinclude-config.xml | 294 ++++++++++++++++++ .../test/resources/artemis-configuration.xsd | 65 +++- docs/user-manual/en/configuration-index.md | 37 +++ 11 files changed, 636 insertions(+), 6 deletions(-) create mode 100644 artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileXIncludeConfigurationTest.java create mode 100644 artemis-server/src/test/resources/ConfigurationTest-xinclude-config-address-settings.xml create mode 100644 artemis-server/src/test/resources/ConfigurationTest-xinclude-config-addresses.xml create mode 100644 artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml create mode 100644 artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml index 8e906256de..772c7bd801 100644 --- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml @@ -20,6 +20,7 @@ under the License. + + @@ -397,6 +399,7 @@ + @@ -410,6 +413,7 @@ + @@ -423,6 +427,7 @@ + @@ -442,6 +447,7 @@ + @@ -455,6 +461,7 @@ + @@ -504,9 +511,11 @@ + + @@ -520,6 +529,7 @@ + @@ -850,6 +860,7 @@ + @@ -860,6 +871,7 @@ + @@ -886,6 +898,7 @@ + @@ -896,6 +909,7 @@ + @@ -915,9 +929,11 @@ + + @@ -952,9 +968,11 @@ + + @@ -968,6 +986,7 @@ + @@ -981,6 +1000,7 @@ + @@ -990,6 +1010,7 @@ + @@ -1059,6 +1080,7 @@ + @@ -1134,7 +1156,7 @@ - + @@ -1200,12 +1222,14 @@ + + @@ -1224,6 +1248,7 @@ + @@ -1241,6 +1266,7 @@ + @@ -1419,6 +1445,7 @@ + @@ -1430,6 +1457,7 @@ + @@ -1442,6 +1470,7 @@ + @@ -1462,6 +1491,7 @@ + @@ -1480,6 +1510,7 @@ + @@ -1494,6 +1525,7 @@ + @@ -1511,6 +1543,7 @@ + @@ -1709,6 +1742,7 @@ + @@ -1720,6 +1754,7 @@ + @@ -1738,6 +1773,7 @@ + @@ -1756,6 +1792,7 @@ + @@ -1827,7 +1864,7 @@ - + @@ -1847,9 +1884,11 @@ + + @@ -1925,6 +1964,7 @@ + @@ -1951,6 +1991,7 @@ + @@ -1977,6 +2018,7 @@ + @@ -2028,6 +2070,7 @@ + @@ -2045,6 +2088,7 @@ + @@ -2099,6 +2143,7 @@ + @@ -2125,6 +2170,7 @@ + @@ -2137,6 +2183,7 @@ + @@ -2207,6 +2254,7 @@ + @@ -2309,6 +2357,7 @@ + @@ -2353,6 +2402,7 @@ + @@ -2378,6 +2428,7 @@ + @@ -2420,6 +2471,7 @@ + @@ -2459,6 +2511,7 @@ + @@ -2489,6 +2542,7 @@ + @@ -2503,10 +2557,12 @@ + + @@ -2563,6 +2619,7 @@ + @@ -2916,6 +2973,7 @@ + @@ -2951,6 +3009,7 @@ + @@ -2968,6 +3027,7 @@ + @@ -2989,6 +3049,7 @@ + @@ -3029,6 +3090,7 @@ + @@ -3043,6 +3105,7 @@ + @@ -3055,6 +3118,7 @@ + @@ -3065,12 +3129,14 @@ + + @@ -3116,6 +3182,7 @@ + diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java index df6a4ded67..af48c62c97 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java @@ -59,7 +59,9 @@ import org.junit.Test; public class FileConfigurationTest extends ConfigurationImplTest { - private final String fullConfigurationName = "ConfigurationTest-full-config.xml"; + protected String getConfigurationName() { + return "ConfigurationTest-full-config.xml"; + } @Override @Test @@ -588,7 +590,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { try { // copy working configuration to a location where the standard classloader cannot find it - final Path workingConfiguration = new File(getClass().getResource("/" + fullConfigurationName).toURI()).toPath(); + final Path workingConfiguration = new File(getClass().getResource("/" + getConfigurationName()).toURI()).toPath(); final Path targetFile = customConfiguration.toPath(); Files.copy(workingConfiguration, targetFile, StandardCopyOption.REPLACE_EXISTING); @@ -663,7 +665,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { @Override protected Configuration createConfiguration() throws Exception { FileConfiguration fc = new FileConfiguration(); - FileDeploymentManager deploymentManager = new FileDeploymentManager(fullConfigurationName); + FileDeploymentManager deploymentManager = new FileDeploymentManager(getConfigurationName()); deploymentManager.addDeployable(fc); deploymentManager.readConfiguration(); return fc; diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileXIncludeConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileXIncludeConfigurationTest.java new file mode 100644 index 0000000000..dd7e88acee --- /dev/null +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileXIncludeConfigurationTest.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.artemis.core.config.impl; + +public class FileXIncludeConfigurationTest extends FileConfigurationTest { + + @Override + protected String getConfigurationName() { + return "ConfigurationTest-xinclude-config.xml"; + } +} \ No newline at end of file diff --git a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-address-settings.xml b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-address-settings.xml new file mode 100644 index 0000000000..9e1ca40944 --- /dev/null +++ b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-address-settings.xml @@ -0,0 +1,66 @@ + + + + a1.1 + a1.2 + 1 + 817M + 81738173872337 + 10 + 4 + 10 + 5 + NOTIFY + true + true + true + true + true + true + true + true + false + 5 + ANYCAST + MULTICAST + + + a2.1 + a2.2 + 5 + 932489234928324 + 7126716262626 + 20 + 8 + 20 + 15 + KILL + false + false + false + false + false + false + false + false + true + 15 + MULTICAST + ANYCAST + + \ No newline at end of file diff --git a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-addresses.xml b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-addresses.xml new file mode 100644 index 0000000000..377b048431 --- /dev/null +++ b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-addresses.xml @@ -0,0 +1,50 @@ + + +
+ + + false + + + + true + + + +
+
+ + + + + + true + + +
+
+ + + + + + + + +
+
\ No newline at end of file diff --git a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml new file mode 100644 index 0000000000..e22784c986 --- /dev/null +++ b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config-security-settings.xml @@ -0,0 +1,24 @@ + + + + + + + + + \ No newline at end of file diff --git a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml new file mode 100644 index 0000000000..526d005e75 --- /dev/null +++ b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml @@ -0,0 +1,294 @@ + + + + SomeNameForUseOnTheApplicationServer + false + false + 12345 + 54321 + false + true + 12345 + 5423 + 123 + true + Giraffe + Whatever + Frog + 32a10275cf4ab4e9 + org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec + true + com.foo + false + gro.qtenroh + true + 123456 + 5 + 12345 + false + 98765 + 56789 + 10111213 + 8 + 127 + false + true + true + 98765 + 1234567 + 1234567 + 37 + 123 + HALT + 333 + 777 + false + + org.apache.activemq.artemis.tests.unit.core.config.impl.TestInterceptor1 + org.apache.activemq.artemis.tests.unit.core.config.impl.TestInterceptor2 + + + org.apache.activemq.artemis.tests.unit.core.config.impl.TestInterceptor1 + org.apache.activemq.artemis.tests.unit.core.config.impl.TestInterceptor2 + + true + + tcp://localhost1:5678?localAddress=mylocal;localPort=99 + vm://5 + + + tcp://0.0.0.0:61616?tcpNoDelay=456;connectionTtl=44;connectionsAllowed=92 + vm://0?e1=z1;e2=567;connectionsAllowed=87 + + + + 10999 + 192.168.0.120 + 11999 + 12345 + connector1 + + + 12999 + 192.168.0.121 + 13999 + 23456 + connector2 + + + + + 172.16.8.10 + 192.168.0.120 + 11999 + 12345 + + + 172.16.8.11 + 192.168.0.121 + 12999 + 23456 + + + + + routing-name1 +
address1
+ forwarding-address1 + + org.foo.Transformer + true +
+ + routing-name2 +
address2
+ forwarding-address2 + + org.foo.Transformer2 + false +
+ + routing-name2 +
address2
+ forwarding-address2 + + + org.foo.DivertTransformer3 + + + + false +
+
+ true + + +
address1
+ + false +
+ +
address2
+ + false +
+
+ + + queue1 + bridge-forwarding-address1 + + org.foo.BridgeTransformer + 4M + 31 + 370 + 3 + 0.2 + 10002 + 2 + false + true + 1G + 444 + + connector1 + + + + queue2 + bridge-forwarding-address2 + 555k + + + + queue3 + bridge-forwarding-address2 + + org.foo.BridgeTransformer3 + + + + 555k + + + + + + + + + + boo! + + + + + + + + +
queues1
+ connector1 + 331 + 3370 + 321 + 123 + 3 + 0.25 + 10000 + 72 + true + ON_DEMAND + 1 + 222 + 123 + + connector1 + connector2 + +
+ +
queues2
+ connector2 + 456 + 4 + false + STRICT + 2 + 333 + 456 + +
+
+ + LOCAL +
jms
+
+ pagingdir + somedir + false + 17 + somedir2 + false + NIO + 1000 + 10000 + false + true + true + 12345678 + 100 + 33 + 123 + 56546 + 9876 + 5000 + 95 + 54321 + largemessagesdir + 127.0.0.1 + some-nick + 123 + 321 + www.apache.org + ping-four + ping-six + + + + + + + + 104 + 13 + + + + + org.foo + + + + +
+
diff --git a/artemis-tools/src/test/resources/artemis-configuration.xsd b/artemis-tools/src/test/resources/artemis-configuration.xsd index cb579a8f3d..84221dee8c 100644 --- a/artemis-tools/src/test/resources/artemis-configuration.xsd +++ b/artemis-tools/src/test/resources/artemis-configuration.xsd @@ -379,6 +379,7 @@ + @@ -392,6 +393,7 @@ + @@ -405,6 +407,7 @@ + @@ -424,6 +427,7 @@ + @@ -437,6 +441,7 @@ + @@ -486,9 +491,11 @@ + + @@ -502,6 +509,7 @@ + @@ -782,6 +790,7 @@ + @@ -792,6 +801,7 @@ + @@ -818,6 +828,7 @@ + @@ -828,9 +839,11 @@ + + @@ -844,6 +857,7 @@ + @@ -857,6 +871,7 @@ + @@ -866,6 +881,7 @@ + @@ -879,6 +895,7 @@ + @@ -955,6 +972,7 @@ + @@ -1020,12 +1038,14 @@ + + @@ -1044,6 +1064,7 @@ + @@ -1061,6 +1082,7 @@ + @@ -1238,6 +1260,7 @@ + @@ -1249,6 +1272,7 @@ + @@ -1261,6 +1285,7 @@ + @@ -1281,6 +1306,7 @@ + @@ -1299,6 +1325,7 @@ + @@ -1313,6 +1340,7 @@ + @@ -1330,6 +1358,7 @@ + @@ -1526,6 +1555,7 @@ + @@ -1537,6 +1567,7 @@ + @@ -1555,6 +1586,7 @@ + @@ -1573,6 +1605,7 @@ + @@ -1652,7 +1685,7 @@ - + @@ -1672,9 +1705,11 @@ + + @@ -1722,6 +1757,7 @@ + @@ -1748,6 +1784,7 @@ + @@ -1774,6 +1811,7 @@ + @@ -1825,6 +1863,7 @@ + @@ -1842,6 +1881,7 @@ + @@ -1896,6 +1936,7 @@ + @@ -1922,6 +1963,7 @@ + @@ -1934,6 +1976,7 @@ + @@ -1974,6 +2017,7 @@ + @@ -2046,6 +2090,7 @@ + @@ -2090,6 +2135,7 @@ + @@ -2108,6 +2154,7 @@ + @@ -2150,6 +2197,7 @@ + @@ -2189,6 +2237,7 @@ + @@ -2219,6 +2268,7 @@ + @@ -2233,10 +2283,12 @@ + + @@ -2293,6 +2345,7 @@ + @@ -2613,6 +2666,7 @@ + @@ -2648,6 +2702,7 @@ + @@ -2665,6 +2720,7 @@ + @@ -2686,6 +2742,7 @@ + @@ -2712,6 +2769,7 @@ + @@ -2726,6 +2784,7 @@ + @@ -2738,6 +2797,7 @@ + @@ -2748,12 +2808,14 @@ + + @@ -2799,5 +2861,6 @@ + diff --git a/docs/user-manual/en/configuration-index.md b/docs/user-manual/en/configuration-index.md index 13112def75..4b45de9d43 100644 --- a/docs/user-manual/en/configuration-index.md +++ b/docs/user-manual/en/configuration-index.md @@ -32,6 +32,43 @@ You can also change the prefix through the broker.xml by setting: This is to help you customize artemis on embedded systems. +# Modularising config into separate files. + +XML XInclude support is provided in the configuration as such if you wish to break your configuration out into separate files you can. + +To do this ensure the following is defined at the root configuration element. + +``` + xmlns:xi="http://www.w3.org/2001/XInclude" +``` + +You can now define include tag's where you want to bring in xml configuration from another file: + +``` + +``` + +You should ensure xml elements in separated files should be namespaced correctly for example if address-settings element was separated, it should have the element namespace defined: + +``` + +``` + +An example can of this feature can be seen in the test suites: +``` + ./artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml +``` +N.B. if you use xmllint to validate xml's against schema you should enable xinclude flag when running. + +``` + --xinclude +``` + +For further information on XInclude see: + +[https://www.w3.org/TR/xinclude/](https://www.w3.org/TR/xinclude/) + + # The core configuration This describes the root of the XML configuration. You will see here also multiple sub-types listed.