ARTEMIS-1651 Allow custom etc and data directories to be used

initial support for custom etc location

fixing windows distribution

fixing StreamClassPathTest

ARTEMIS-1651 fix tests and add docs


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/88f43e93
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/88f43e93
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/88f43e93

Branch: refs/heads/master
Commit: 88f43e93425547150aae4b21b48b78ec8200f400
Parents: 9b10493
Author: Dejan Bosanac <de...@nighttale.net>
Authored: Fri Jan 26 15:26:47 2018 +0100
Committer: Justin Bertram <jbert...@apache.org>
Committed: Wed Feb 14 09:17:08 2018 -0600

----------------------------------------------------------------------
 .../apache/activemq/artemis/cli/Artemis.java    |  1 -
 .../artemis/cli/commands/ActionAbstract.java    | 15 ++++
 .../artemis/cli/commands/Configurable.java      |  4 +-
 .../activemq/artemis/cli/commands/Create.java   | 86 +++++++++++++-------
 .../artemis/cli/commands/user/UserAction.java   |  2 +-
 .../activemq/artemis/cli/commands/bin/artemis   |  9 +-
 .../cli/commands/bin/artemis-service.xml        | 11 ++-
 .../artemis/cli/commands/bin/artemis.cmd        |  7 +-
 .../artemis/cli/commands/etc/artemis.profile    |  4 +-
 .../cli/commands/etc/artemis.profile.cmd        |  5 +-
 .../artemis/cli/commands/etc/bootstrap.xml      |  2 +-
 .../apache/activemq/cli/test/CliTestBase.java   |  1 +
 .../activemq/cli/test/StreamClassPathTest.java  | 18 ++--
 .../core/config/impl/ConfigurationImplTest.java |  3 +
 docs/user-manual/en/using-server.md             | 10 ++-
 15 files changed, 118 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
index e41e629..556bcd8 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
@@ -133,7 +133,6 @@ public class Artemis {
    }
 
    public static Object internalExecute(File artemisHome, File 
artemisInstance, String[] args, ActionContext context) throws Exception {
-
       Action action = builder(artemisInstance).build().parse(args);
       action.setHomeValues(artemisHome, artemisInstance);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/ActionAbstract.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/ActionAbstract.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/ActionAbstract.java
index 2037d01..d2cb8ba 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/ActionAbstract.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/ActionAbstract.java
@@ -30,6 +30,8 @@ public abstract class ActionAbstract implements Action {
 
    private String brokerHome;
 
+   private String brokerEtc;
+
    private URI brokerInstanceURI;
 
    protected ActionContext context;
@@ -65,6 +67,19 @@ public abstract class ActionAbstract implements Action {
       return brokerInstance;
    }
 
+   public String getBrokerEtc() {
+      if (brokerEtc == null) {
+         brokerEtc = System.getProperty("artemis.instance.etc");
+         if (brokerEtc != null) {
+            brokerEtc = brokerEtc.replace("\\", "/");
+         } else {
+            brokerEtc = getBrokerInstance() + "/etc";
+         }
+         System.setProperty("artemis.instance.etc", brokerEtc);
+      }
+      return brokerEtc;
+   }
+
 
    public URI getBrokerURIInstance() {
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
index 99fb52d..686f042 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Configurable.java
@@ -136,7 +136,7 @@ public abstract class Configurable extends ActionAbstract {
 
    protected String getConfiguration() {
       if (configuration == null) {
-         File xmlFile = new File(new File(new File(getBrokerInstance()), 
"etc"), "bootstrap.xml");
+         File xmlFile = new File(new File(getBrokerEtc()), "bootstrap.xml");
          configuration = "xml:" + 
xmlFile.toURI().toString().substring("file:".length());
 
          // To support Windows paths as explained above.
@@ -149,7 +149,7 @@ public abstract class Configurable extends ActionAbstract {
    }
 
    protected String getManagementConfiguration() {
-      File xmlFile = new File(new File(new File(getBrokerInstance()), "etc"), 
"management.xml");
+      File xmlFile = new File(new File(getBrokerEtc()), "management.xml");
       String configuration = "xml:" + 
xmlFile.toURI().toString().substring("file:".length());
 
       // To support Windows paths as explained above.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
index 5fe281e..dfa8c0d 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
@@ -76,18 +76,18 @@ public class Create extends InputAbstract {
    public static final String BIN_ARTEMIS_CMD = "bin/artemis.cmd";
    public static final String BIN_ARTEMIS_SERVICE_EXE = 
"bin/artemis-service.exe";
    public static final String BIN_ARTEMIS_SERVICE_XML = 
"bin/artemis-service.xml";
-   public static final String ETC_ARTEMIS_PROFILE_CMD = 
"etc/artemis.profile.cmd";
+   public static final String ETC_ARTEMIS_PROFILE_CMD = "artemis.profile.cmd";
    public static final String BIN_ARTEMIS = "bin/artemis";
    public static final String BIN_ARTEMIS_SERVICE = "bin/artemis-service";
-   public static final String ETC_ARTEMIS_PROFILE = "etc/artemis.profile";
-   public static final String ETC_LOGGING_PROPERTIES = 
"etc/logging.properties";
-   public static final String ETC_BOOTSTRAP_XML = "etc/bootstrap.xml";
-   public static final String ETC_MANAGEMENT_XML = "etc/management.xml";
-   public static final String ETC_BROKER_XML = "etc/broker.xml";
-
-   public static final String ETC_ARTEMIS_ROLES_PROPERTIES = 
"etc/artemis-roles.properties";
-   public static final String ETC_ARTEMIS_USERS_PROPERTIES = 
"etc/artemis-users.properties";
-   private static final String ETC_LOGIN_CONFIG = "etc/login.config";
+   public static final String ETC_ARTEMIS_PROFILE = "artemis.profile";
+   public static final String ETC_LOGGING_PROPERTIES = "logging.properties";
+   public static final String ETC_BOOTSTRAP_XML = "bootstrap.xml";
+   public static final String ETC_MANAGEMENT_XML = "management.xml";
+   public static final String ETC_BROKER_XML = "broker.xml";
+
+   public static final String ETC_ARTEMIS_ROLES_PROPERTIES = 
"artemis-roles.properties";
+   public static final String ETC_ARTEMIS_USERS_PROPERTIES = 
"artemis-users.properties";
+   private static final String ETC_LOGIN_CONFIG = "login.config";
    private static final String ETC_LOGIN_CONFIG_WITH_GUEST = 
"etc/login-with-guest.config";
    private static final String ETC_LOGIN_CONFIG_WITHOUT_GUEST = 
"etc/login-without-guest.config";
    public static final String ETC_REPLICATED_SETTINGS_TXT = 
"etc/replicated-settings.txt";
@@ -107,7 +107,7 @@ public class Create extends InputAbstract {
 
    public static final String ETC_GLOBAL_MAX_SPECIFIED_TXT = 
"etc/global-max-specified.txt";
    public static final String ETC_GLOBAL_MAX_DEFAULT_TXT = 
"etc/global-max-default.txt";
-   public static final String ETC_JOLOKIA_ACCESS_XML = 
"etc/jolokia-access.xml";
+   public static final String ETC_JOLOKIA_ACCESS_XML = "jolokia-access.xml";
 
    @Arguments(description = "The instance directory to hold the broker's 
configuration and data.  Path must be writable.", required = true)
    private File directory;
@@ -154,8 +154,11 @@ public class Create extends InputAbstract {
    @Option(name = "--home", description = "Directory where ActiveMQ Artemis is 
installed")
    private File home;
 
-   @Option(name = "--data", description = "Directory where ActiveMQ Data is 
used. Paths are relative to artemis.instance")
-   private String data = "./data";
+   @Option(name = "--data", description = "Directory where ActiveMQ data are 
stored. Paths can be absolute or relative to artemis.instance directory ('data' 
by default)")
+   private String data = "data";
+
+   @Option(name = "--etc", description = "Directory where ActiveMQ 
configuration is located. Paths can be absolute or relative to artemis.instance 
directory ('etc' by default)")
+   private String etc = "etc";
 
    @Option(name = "--clustered", description = "Enable clustering")
    private boolean clustered = false;
@@ -387,6 +390,14 @@ public class Create extends InputAbstract {
       this.data = data;
    }
 
+   public String getEtc() {
+      return etc;
+   }
+
+   public void setEtc(String etc) {
+      this.etc = etc;
+   }
+
    private String getClusterUser() {
       if (clusterUser == null) {
          clusterUser = input("--cluster-user", "Please provide the username:", 
"cluster-admin");
@@ -508,6 +519,15 @@ public class Create extends InputAbstract {
       }
    }
 
+   private File createDirectory(String name, File root) {
+      File directory = new File(name);
+      if (!directory.isAbsolute()) {
+         directory = new File(root, name);
+      }
+      directory.mkdirs();
+      return directory;
+   }
+
    public Object run(ActionContext context) throws Exception {
 
       IS_WINDOWS = 
System.getProperty("os.name").toLowerCase().trim().startsWith("win");
@@ -651,12 +671,15 @@ public class Create extends InputAbstract {
       filters.put("${java.home}", path(System.getProperty("java.home")));
 
       new File(directory, "bin").mkdirs();
-      new File(directory, "etc").mkdirs();
+      File etcFolder = createDirectory(etc, directory);
+      filters.put("${artemis.instance.etc.uri}", etcFolder.toURI().toString());
+      filters.put("${artemis.instance.etc.uri.windows}", 
etcFolder.toURI().toString().replaceAll("%", "%%"));
+      filters.put("${artemis.instance.etc}", path(etcFolder));
       new File(directory, "log").mkdirs();
       new File(directory, "tmp").mkdirs();
       new File(directory, "lib").mkdirs();
-      File dataFolder = new File(directory, "data");
-      dataFolder.mkdirs();
+      File dataFolder = createDirectory(data, directory);
+      filters.put("${artemis.instance.data}", path(dataFolder));
 
       filters.put("${logmanager}", getLogManager());
 
@@ -667,20 +690,18 @@ public class Create extends InputAbstract {
       filters.put("${java-opts}", javaOptions);
 
       if (isAllowAnonymous()) {
-         write(ETC_LOGIN_CONFIG_WITH_GUEST, filters, false);
-         new File(directory, ETC_LOGIN_CONFIG_WITH_GUEST).renameTo(new 
File(directory, ETC_LOGIN_CONFIG));
+         write(ETC_LOGIN_CONFIG_WITH_GUEST, new File(etcFolder, 
ETC_LOGIN_CONFIG), filters, false);
       } else {
-         write(ETC_LOGIN_CONFIG_WITHOUT_GUEST, filters, false);
-         new File(directory, ETC_LOGIN_CONFIG_WITHOUT_GUEST).renameTo(new 
File(directory, ETC_LOGIN_CONFIG));
+         write(ETC_LOGIN_CONFIG_WITHOUT_GUEST, new File(etcFolder, 
ETC_LOGIN_CONFIG), filters, false);
       }
 
-      write(ETC_ARTEMIS_ROLES_PROPERTIES, filters, false);
+      writeEtc(ETC_ARTEMIS_ROLES_PROPERTIES, etcFolder, filters, false);
 
       if (IS_WINDOWS) {
-         write(BIN_ARTEMIS_CMD, null, false);
+         write(BIN_ARTEMIS_CMD, filters, false);
          write(BIN_ARTEMIS_SERVICE_EXE);
          write(BIN_ARTEMIS_SERVICE_XML, filters, false);
-         write(ETC_ARTEMIS_PROFILE_CMD, filters, false);
+         writeEtc(ETC_ARTEMIS_PROFILE_CMD, etcFolder, filters, false);
       }
 
       if (!IS_WINDOWS || IS_CYGWIN) {
@@ -688,10 +709,10 @@ public class Create extends InputAbstract {
          makeExec(BIN_ARTEMIS);
          write(BIN_ARTEMIS_SERVICE, filters, true);
          makeExec(BIN_ARTEMIS_SERVICE);
-         write(ETC_ARTEMIS_PROFILE, filters, true);
+         writeEtc(ETC_ARTEMIS_PROFILE, etcFolder, filters, true);
       }
 
-      write(ETC_LOGGING_PROPERTIES, null, false);
+      writeEtc(ETC_LOGGING_PROPERTIES, etcFolder, null, false);
 
       if (noWeb) {
          filters.put("${bootstrap-web-settings}", "");
@@ -745,14 +766,14 @@ public class Create extends InputAbstract {
 
       performAutoTune(filters, journalType, dataFolder);
 
-      write(ETC_BROKER_XML, filters, false);
-      write(ETC_ARTEMIS_USERS_PROPERTIES, filters, false);
+      writeEtc(ETC_BROKER_XML, etcFolder, filters, false);
+      writeEtc(ETC_ARTEMIS_USERS_PROPERTIES, etcFolder, filters, false);
 
       // we want this variable to remain unchanged so that it will use the 
value set in the profile
       filters.remove("${artemis.instance}");
-      write(ETC_BOOTSTRAP_XML, filters, false);
-      write(ETC_MANAGEMENT_XML, filters, false);
-      write(ETC_JOLOKIA_ACCESS_XML, filters, false);
+      writeEtc(ETC_BOOTSTRAP_XML, etcFolder, filters, false);
+      writeEtc(ETC_MANAGEMENT_XML, etcFolder, filters, false);
+      writeEtc(ETC_JOLOKIA_ACCESS_XML, etcFolder, filters, false);
 
       context.out.println("");
       context.out.println("You can now start the broker by executing:  ");
@@ -984,6 +1005,10 @@ public class Create extends InputAbstract {
       write(source, new File(directory, source), filters, unixTarget);
    }
 
+   private void writeEtc(String source, File etcFolder, HashMap<String, 
String> filters, boolean unixTarget) throws Exception {
+      write("etc/" + source, new File(etcFolder, source), filters, unixTarget);
+   }
+
    private void write(String source,
                       File target,
                       HashMap<String, String> filters,
@@ -999,7 +1024,6 @@ public class Create extends InputAbstract {
       String separator = unixTarget && IS_CYGWIN ? "\n" : 
System.getProperty("line.separator");
       content = content.replaceAll("\\r?\\n", 
Matcher.quoteReplacement(separator));
       ByteArrayInputStream in = new 
ByteArrayInputStream(content.getBytes(encoding));
-
       try (FileOutputStream fout = new FileOutputStream(target)) {
          copy(in, fout);
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/UserAction.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/UserAction.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/UserAction.java
index 2a23fa6..e4a2e45 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/UserAction.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/UserAction.java
@@ -60,7 +60,7 @@ public abstract class UserAction extends InputAbstract {
             String userFileName = (String) 
entry.getOptions().get(USER_FILE_PROP_NAME);
             String roleFileName = (String) 
entry.getOptions().get(ROLE_FILE_PROP_NAME);
 
-            File etcDir = new File(getBrokerInstance(), "etc");
+            File etcDir = new File(getBrokerEtc());
             File userFile = new File(etcDir, userFileName);
             File roleFile = new File(etcDir, roleFileName);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
index b66141a..758713c 100755
--- 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
+++ 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis
@@ -45,11 +45,11 @@ if [ -z "$ARTEMIS_INSTANCE" ] ; then
 fi
 
 # Load Profile Data
-. "$ARTEMIS_INSTANCE/etc/artemis.profile"
+ARTEMIS_INSTANCE_ETC='${artemis.instance.etc}'
+. "$ARTEMIS_INSTANCE_ETC/artemis.profile"
 
 # Set Defaults Properties
-ARTEMIS_LOGGING_CONF="$ARTEMIS_INSTANCE_URI/etc/logging.properties"
-ARTEMIS_DATA_DIR="$ARTEMIS_INSTANCE/data"
+ARTEMIS_LOGGING_CONF="$ARTEMIS_INSTANCE_ETC_URI/logging.properties"
 ARTEMIS_LOG_MANAGER=org.jboss.logmanager.LogManager
 
 
@@ -109,7 +109,7 @@ fi
 exec "$JAVACMD" \
     $JAVA_ARGS \
     -Xbootclasspath/a:"$LOG_MANAGER" \
-    -Djava.security.auth.login.config="$ARTEMIS_INSTANCE/etc/login.config" \
+    -Djava.security.auth.login.config="$ARTEMIS_INSTANCE_ETC_URI/login.config" 
\
     $ARTEMIS_CLUSTER_PROPS \
     -classpath "$CLASSPATH" \
     -Dartemis.home="$ARTEMIS_HOME" \
@@ -117,6 +117,7 @@ exec "$JAVACMD" \
     -Djava.library.path="$ARTEMIS_HOME/bin/lib/linux-$(uname -m)" \
     -Djava.io.tmpdir="$ARTEMIS_INSTANCE/tmp" \
     -Ddata.dir="$ARTEMIS_DATA_DIR" \
+    -Dartemis.instance.etc="$ARTEMIS_INSTANCE_ETC" \
     -Djava.util.logging.manager="$ARTEMIS_LOG_MANAGER" \
     -Dlogging.configuration="$ARTEMIS_LOGGING_CONF" \
     $DEBUG_ARGS \

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml
 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml
index cb98364..395e041 100644
--- 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml
+++ 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml
@@ -24,7 +24,10 @@
 
    <env name="ARTEMIS_HOME" value="${artemis.home}"/>
    <env name="ARTEMIS_INSTANCE" value="${artemis.instance}"/>
+   <env name="ARTEMIS_INSTANCE_ETC" value="${artemis.instance.etc}"/>
    <env name="ARTEMIS_INSTANCE_URI" value="${artemis.instance.uri}"/>
+   <env name="ARTEMIS_INSTANCE_ETC_URI" 
value="${artemis.instance.etc.uri.windows}"/>
+   <env name="ARTEMIS_DATA_DIR" value="${artemis.instance.data}"/>
 
    <logpath>${artemis.instance}\log</logpath>
    <logmode>roll</logmode>
@@ -55,14 +58,16 @@
    <argument>%ARTEMIS_HOME%\lib\artemis-boot.jar</argument>
    <argument>-Dartemis.home=%ARTEMIS_HOME%</argument>
    <argument>-Dartemis.instance=%ARTEMIS_INSTANCE%</argument>
+   <argument>-Ddata.dir=%ARTEMIS_DATA_DIR%</argument>
+   <argument>-Dartemis.instance.etc="%ARTEMIS_INSTANCE_ETC%"</argument>
    
<argument>-Djava.util.logging.manager=org.jboss.logmanager.LogManager</argument>
-   
<argument>-Dlogging.configuration=%ARTEMIS_INSTANCE_URI%/etc/logging.properties</argument>
-   
<argument>-Djava.security.auth.login.config=%ARTEMIS_INSTANCE%\etc\login.config</argument>
+   
<argument>-Dlogging.configuration=%ARTEMIS_INSTANCE_ETC_URI%/logging.properties</argument>
+   
<argument>-Djava.security.auth.login.config=%ARTEMIS_INSTANCE_ETC%\login.config</argument>
    <argument>-Dhawtio.realm=activemq</argument>
    <argument>-Dhawtio.offline="true"</argument>
    <argument>-Dhawtio.role=${role}</argument>
    
<argument>-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal</argument>
-   
<argument>-Djolokia.policyLocation=%ARTEMIS_INSTANCE_URI%/etc/jolokia-access.xml</argument>
+   
<argument>-Djolokia.policyLocation=%ARTEMIS_INSTANCE_ETC_URI%/jolokia-access.xml</argument>
 
    <!-- Debug args: Uncomment to enable debug
    
<argument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005</argument>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
index c9d12b5..6057a51 100644
--- 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
+++ 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
@@ -45,11 +45,11 @@ echo.
 :RUN_JAVA
 
 rem "Load Profile Config"
-call %ARTEMIS_INSTANCE%\etc\artemis.profile.cmd %*
+set ARTEMIS_INSTANCE_ETC="${artemis.instance.etc}"
+call %ARTEMIS_INSTANCE_ETC%\artemis.profile.cmd %*
 
 rem "Set Defaults."
-set ARTEMIS_LOGGING_CONF=%ARTEMIS_INSTANCE_URI%/etc/logging.properties
-set ARTEMIS_DATA_DIR=%ARTEMIS_INSTANCE%\data
+set ARTEMIS_LOGGING_CONF=%ARTEMIS_INSTANCE_ETC_URI%/logging.properties
 set ARTEMIS_LOG_MANAGER=org.jboss.logmanager.LogManager
 
 rem "Create full JVM Args"
@@ -59,6 +59,7 @@ set JVM_ARGS=%JVM_ARGS% -classpath 
%ARTEMIS_HOME%\lib\artemis-boot.jar
 set JVM_ARGS=%JVM_ARGS% -Dartemis.home=%ARTEMIS_HOME%
 set JVM_ARGS=%JVM_ARGS% -Dartemis.instance=%ARTEMIS_INSTANCE%
 set JVM_ARGS=%JVM_ARGS% -Ddata.dir=%ARTEMIS_DATA_DIR%
+set JVM_ARGS=%JVM_ARGS% -Dartemis.instance.etc="%ARTEMIS_INSTANCE_ETC%"
 set JVM_ARGS=%JVM_ARGS% -Djava.util.logging.manager=%ARTEMIS_LOG_MANAGER%
 set JVM_ARGS=%JVM_ARGS% -Dlogging.configuration=%ARTEMIS_LOGGING_CONF%
 if not "%DEBUG_ARGS%"=="" set JVM_ARGS=%JVM_ARGS% %DEBUG_ARGS%

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
index 19df253..7f53c99 100644
--- 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
+++ 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
@@ -17,18 +17,20 @@
 
 ARTEMIS_HOME='${artemis.home}'
 ARTEMIS_INSTANCE='${artemis.instance}'
+ARTEMIS_DATA_DIR='${artemis.instance.data}'
 
 # The logging config will need an URI
 # this will be encoded in case you use spaces or special characters
 # on your directory structure
 ARTEMIS_INSTANCE_URI='${artemis.instance.uri}'
+ARTEMIS_INSTANCE_ETC_URI='${artemis.instance.etc.uri}'
 
 # Cluster Properties: Used to pass arguments to ActiveMQ Artemis which can be 
referenced in broker.xml
 #ARTEMIS_CLUSTER_PROPS="-Dactivemq.remoting.default.port=61617 
-Dactivemq.remoting.amqp.port=5673 -Dactivemq.remoting.stomp.port=61614 
-Dactivemq.remoting.hornetq.port=5446"
 
 
 # Java Opts
-JAVA_ARGS="${java-opts} -XX:+PrintClassHistogram -XX:+UseG1GC 
-XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx2G 
-Dhawtio.realm=activemq  -Dhawtio.offline="true" -Dhawtio.role=${role} 
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
 -Djolokia.policyLocation=${ARTEMIS_INSTANCE_URI}/etc/jolokia-access.xml"
+JAVA_ARGS="${java-opts} -XX:+PrintClassHistogram -XX:+UseG1GC 
-XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx2G 
-Dhawtio.realm=activemq  -Dhawtio.offline="true" -Dhawtio.role=${role} 
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
 -Djolokia.policyLocation=${ARTEMIS_INSTANCE_ETC_URI}jolokia-access.xml"
 
 #
 # There might be options that you only want to enable on specifc commands, 
like setting a JMX port

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
index 0ed593e..92747f7 100644
--- 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
+++ 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
@@ -18,17 +18,20 @@ rem under the License.
 
 set ARTEMIS_HOME="${artemis.home}"
 set ARTEMIS_INSTANCE="${artemis.instance}"
+set ARTEMIS_DATA_DIR='${artemis.instance.data}'
+
 
 rem The logging config will need an URI
 rem this will be encoded in case you use spaces or special characters
 rem on your directory structure
 set ARTEMIS_INSTANCE_URI="${artemis.instance.uri.windows}"
+set ARTEMIS_INSTANCE_ETC_URI="${artemis.instance.etc.uri.windows}"
 
 rem Cluster Properties: Used to pass arguments to ActiveMQ Artemis which can 
be referenced in broker.xml
 rem set ARTEMIS_CLUSTER_PROPS=-Dactivemq.remoting.default.port=61617 
-Dactivemq.remoting.amqp.port=5673 -Dactivemq.remoting.stomp.port=61614 
-Dactivemq.remoting.hornetq.port=5446
 
 rem Java Opts
-set JAVA_ARGS=${java-opts} -XX:+PrintClassHistogram -XX:+UseG1GC 
-XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M 
-Xbootclasspath/a:%ARTEMIS_HOME%\lib\${logmanager} 
-Djava.security.auth.login.config=%ARTEMIS_INSTANCE%\etc\login.config 
-Dhawtio.offline="true" -Dhawtio.realm=activemq -Dhawtio.role=${role} 
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
 -Djolokia.policyLocation=%ARTEMIS_INSTANCE_URI%\etc\jolokia-access.xml 
-Dartemis.instance=%ARTEMIS_INSTANCE%
+set JAVA_ARGS=${java-opts} -XX:+PrintClassHistogram -XX:+UseG1GC 
-XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M 
-Xbootclasspath/a:%ARTEMIS_HOME%\lib\${logmanager} 
-Djava.security.auth.login.config=%ARTEMIS_ETC_INSTANCE%\login.config 
-Dhawtio.offline="true" -Dhawtio.realm=activemq -Dhawtio.role=${role} 
-Dhawtio.rolePrincipalClasses=org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal
 -Djolokia.policyLocation=%ARTEMIS_INSTANCE_ETC_URI%\jolokia-access.xml 
-Dartemis.instance=%ARTEMIS_INSTANCE%
 
 rem There might be options that you only want to enable on specifc commands, 
like setting a JMX port
 rem See https://issues.apache.org/jira/browse/ARTEMIS-318

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml
 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml
index d359c25..f919428 100644
--- 
a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml
+++ 
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml
@@ -22,7 +22,7 @@
 
    <!-- artemis.URI.instance is parsed from artemis.instance by the CLI 
startup.
         This is to avoid situations where you could have spaces or special 
characters on this URI -->
-   <server configuration="${artemis.URI.instance}/etc/broker.xml"/>
+   <server configuration="${artemis.instance.etc.uri}/broker.xml"/>
 
 ${bootstrap-web-settings}
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliTestBase.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliTestBase.java 
b/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliTestBase.java
index 970adbc..76d6939 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliTestBase.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliTestBase.java
@@ -54,6 +54,7 @@ public class CliTestBase {
    public void tearDown() throws Exception {
       ActiveMQClient.clearThreadPools();
       System.clearProperty("artemis.instance");
+      System.clearProperty("artemis.instance.etc");
       Run.setEmbedded(false);
 
       if (original == null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java
----------------------------------------------------------------------
diff --git 
a/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java
 
b/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java
index f965c77..a11e094 100644
--- 
a/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java
+++ 
b/artemis-cli/src/test/java/org/apache/activemq/cli/test/StreamClassPathTest.java
@@ -33,16 +33,16 @@ public class StreamClassPathTest {
       openStream(Create.BIN_ARTEMIS_CMD);
       openStream(Create.BIN_ARTEMIS_SERVICE_EXE);
       openStream(Create.BIN_ARTEMIS_SERVICE_XML);
-      openStream(Create.ETC_ARTEMIS_PROFILE_CMD);
+      openStream("etc/" + Create.ETC_ARTEMIS_PROFILE_CMD);
       openStream(Create.BIN_ARTEMIS);
       openStream(Create.BIN_ARTEMIS_SERVICE);
-      openStream(Create.ETC_ARTEMIS_PROFILE);
-      openStream(Create.ETC_LOGGING_PROPERTIES);
-      openStream(Create.ETC_BOOTSTRAP_XML);
-      openStream(Create.ETC_MANAGEMENT_XML);
-      openStream(Create.ETC_BROKER_XML);
-      openStream(Create.ETC_ARTEMIS_ROLES_PROPERTIES);
-      openStream(Create.ETC_ARTEMIS_USERS_PROPERTIES);
+      openStream("etc/" + Create.ETC_ARTEMIS_PROFILE);
+      openStream("etc/" + Create.ETC_LOGGING_PROPERTIES);
+      openStream("etc/" + Create.ETC_BOOTSTRAP_XML);
+      openStream("etc/" + Create.ETC_MANAGEMENT_XML);
+      openStream("etc/" + Create.ETC_BROKER_XML);
+      openStream("etc/" + Create.ETC_ARTEMIS_ROLES_PROPERTIES);
+      openStream("etc/" + Create.ETC_ARTEMIS_USERS_PROPERTIES);
       openStream(Create.ETC_REPLICATED_SETTINGS_TXT);
       openStream(Create.ETC_REPLICATED_SETTINGS_TXT);
       openStream(Create.ETC_SHARED_STORE_SETTINGS_TXT);
@@ -59,7 +59,7 @@ public class StreamClassPathTest {
       openStream(Create.ETC_COMMENTED_PING_TXT);
       openStream(Create.ETC_GLOBAL_MAX_SPECIFIED_TXT);
       openStream(Create.ETC_GLOBAL_MAX_DEFAULT_TXT);
-      openStream(Create.ETC_JOLOKIA_ACCESS_XML);
+      openStream("etc/" + Create.ETC_JOLOKIA_ACCESS_XML);
       openStream(Create.ETC_DATABASE_STORE_TXT);
 
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
index 847c0bf..58283b3 100644
--- 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
+++ 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
@@ -506,6 +506,7 @@ public class ConfigurationImplTest extends ActiveMQTestBase 
{
       // Validate that the resolve method will work even with artemis.instance 
doesn't exist
 
       String oldProperty = System.getProperty("artemis.instance");
+      String oldEtc = System.getProperty("artemis.instance.etc");
 
       File tempFolder = null;
       try {
@@ -526,8 +527,10 @@ public class ConfigurationImplTest extends 
ActiveMQTestBase {
       } finally {
          if (oldProperty == null) {
             System.clearProperty("artemis.instance");
+            System.clearProperty("artemis.instance.etc");
          } else {
             System.setProperty("artemis.instance", oldProperty);
+            System.setProperty("artemis.instance.etc", oldEtc);
          }
 
          if (tempFolder != null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/88f43e93/docs/user-manual/en/using-server.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/using-server.md 
b/docs/user-manual/en/using-server.md
index b0b8ac9..691d73e 100644
--- a/docs/user-manual/en/using-server.md
+++ b/docs/user-manual/en/using-server.md
@@ -92,7 +92,7 @@ For a full list of updated properties always use:
                 [--autocreate] [--blocking] [--cluster-password 
<clusterPassword>]
                 [--cluster-user <clusterUser>] [--clustered] [--data <data>]
                 [--default-port <defaultPort>] [--disable-persistence]
-                [--encoding <encoding>] [--failover-on-shutdown] [--force]
+                [--encoding <encoding>] [--etc <etc>] [--failover-on-shutdown] 
[--force]
                 [--global-max-size <globalMaxSize>] [--home <home>] [--host 
<host>]
                 [--http-host <httpHost>] [--http-port <httpPort>]
                 [--java-options <javaOptions>] [--mapped] [--max-hops 
<maxHops>]
@@ -135,8 +135,8 @@ For a full list of updated properties always use:
              Enable clustering
 
          --data <data>
-             Directory where ActiveMQ Data is used. Paths are relative to
-             artemis.instance
+             Directory where ActiveMQ data are stored. Paths can be absolute or
+             relative to artemis.instance directory ('data' by default)
 
          --default-port <defaultPort>
              The port number to use for the main 'artemis' acceptor (Default:
@@ -148,6 +148,10 @@ For a full list of updated properties always use:
          --encoding <encoding>
              The encoding that text files should use
 
+         --etc <etc>
+             Directory where ActiveMQ configuration is located. Paths can be 
absolute or
+             relative to artemis.instance directory ('etc' by default)
+
          --failover-on-shutdown
              Valid for shared store: will shutdown trigger a failover? 
(Default:
              false)

Reply via email to