merge PR #242 - A few fixes that I found from my work on examples
diff --git a/README.md b/README.md
index e42b119..65155f3 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
## Source
For details about the modifying the code, building the project, running tests, IDE integration, etc. see
-our [Hacking Guide](./docs/hacking-guide/en/README.md).
+our [Hacking Guide](./docs/hacking-guide/en/SUMMARY.md).
## Examples
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 6b3b3a6..d00f4ac 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
@@ -16,86 +16,15 @@
*/
package org.apache.activemq.artemis.cli.commands;
-import java.util.Scanner;
-
public abstract class ActionAbstract implements Action
{
protected ActionContext context;
- private Scanner scanner;
-
- private boolean noInput = false;
-
- protected void disableInputs()
- {
- noInput = true;
-
- }
-
- protected String input(String propertyName, String prompt, String silentDefault)
- {
- if (noInput)
- {
- return silentDefault;
- }
- String inputStr;
- boolean valid = false;
- System.out.println();
- do
- {
- context.out.println(propertyName + ": is mandatory with this configuration:");
- context.out.println(prompt);
- inputStr = scanner.nextLine();
- if (inputStr.trim().equals(""))
- {
- System.out.println("Invalid Entry!");
- }
- else
- {
- valid = true;
- }
- }
- while (!valid);
-
- return inputStr.trim();
- }
-
- protected String inputPassword(String propertyName, String prompt, String silentDefault)
- {
- if (noInput)
- {
- return silentDefault;
- }
- String inputStr;
- boolean valid = false;
- System.out.println();
- do
- {
- context.out.println(propertyName + ": is mandatory with this configuration:");
- context.out.println(prompt);
- inputStr = new String(System.console().readPassword());
-
- if (inputStr.trim().equals(""))
- {
- System.out.println("Invalid Entry!");
- }
- else
- {
- valid = true;
- }
- }
- while (!valid);
-
- return inputStr.trim();
- }
-
public Object execute(ActionContext context) throws Exception
{
this.context = context;
- scanner = new Scanner(context.in);
-
return null;
}
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 d99f287..bfffa32 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
@@ -51,7 +51,7 @@
* CLI action that creates a broker instance directory.
*/
@Command(name = "create", description = "creates a new broker instance")
-public class Create extends ActionAbstract
+public class Create extends InputAbstract
{
private static final Integer DEFAULT_PORT = 61616;
@@ -80,6 +80,7 @@
public static final String ETC_CLUSTER_SECURITY_SETTINGS_TXT = "etc/cluster-security-settings.txt";
public static final String ETC_CLUSTER_SETTINGS_TXT = "etc/cluster-settings.txt";
public static final String ETC_CONNECTOR_SETTINGS_TXT = "etc/connector-settings.txt";
+ public static final String ETC_BOOTSTRAP_WEB_SETTINGS_TXT = "etc/bootstrap-web-settings.txt";
@Arguments(description = "The instance directory to hold the broker's configuration and data", required = true)
File directory;
@@ -102,6 +103,9 @@
@Option(name = "--clustered", description = "Enable clustering")
boolean clustered = false;
+ @Option(name = "--max-hops", description = "Number of hops on the cluster configuration")
+ int maxHops = 0;
+
@Option(name = "--replicated", description = "Enable broker replication")
boolean replicated = false;
@@ -132,13 +136,33 @@
@Option(name = "--role", description = "The name for the role created (Default: amq)")
String role;
- @Option(name = "--silent-input", description = "It will disable all the inputs, and it would make a best guess for any required input")
- boolean silentInput;
+ @Option(name = "--no-web", description = "This will remove the web server definition from bootstrap.xml")
+ boolean noWeb;
boolean IS_WINDOWS;
boolean IS_CYGWIN;
+ public int getMaxHops()
+ {
+ return maxHops;
+ }
+
+ public void setMaxHops(int maxHops)
+ {
+ this.maxHops = maxHops;
+ }
+
+ public boolean isNoWeb()
+ {
+ return noWeb;
+ }
+
+ public void setNoWeb(boolean noWeb)
+ {
+ this.noWeb = noWeb;
+ }
+
public int getPortOffset()
{
return portOffset;
@@ -359,11 +383,6 @@
{
super.execute(context);
- if (silentInput)
- {
- this.disableInputs();
- }
-
try
{
return run(context);
@@ -428,7 +447,7 @@
filters.put("${hq.port}", String.valueOf(HQ_PORT + portOffset));
filters.put("${http.port}", String.valueOf(HTTP_PORT + portOffset));
filters.put("${data.dir}", data);
-
+ filters.put("${max-hops}", String.valueOf(maxHops));
filters.put("${user}", getUser());
filters.put("${password}", getPassword());
filters.put("${role}", getRole());
@@ -442,7 +461,7 @@
filters.put("${connector-config.settings}", connectorSettings);
filters.put("${cluster-security.settings}", readTextFile(ETC_CLUSTER_SECURITY_SETTINGS_TXT));
- filters.put("${cluster.settings}", readTextFile(ETC_CLUSTER_SETTINGS_TXT));
+ filters.put("${cluster.settings}", applyFilters(readTextFile(ETC_CLUSTER_SETTINGS_TXT), filters));
filters.put("${cluster-user}", getClusterUser());
filters.put("${cluster-password}", getClusterPassword());
}
@@ -508,6 +527,18 @@
filters.put("${bootstrap.guest}", "");
}
+
+ if (noWeb)
+ {
+ filters.put("${bootstrap-web-settings}", "");
+ }
+ else
+ {
+ filters.put("${bootstrap-web-settings}", applyFilters(readTextFile(ETC_BOOTSTRAP_WEB_SETTINGS_TXT), filters));
+ }
+
+
+
write(ETC_BOOTSTRAP_XML, filters, false);
write(ETC_BROKER_XML, filters, false);
write(ETC_ARTEMIS_ROLES_PROPERTIES, filters, false);
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java
new file mode 100644
index 0000000..7578aad
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java
@@ -0,0 +1,111 @@
+/**
+ * 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;
+
+import java.util.Scanner;
+
+import io.airlift.airline.Option;
+
+public class InputAbstract extends ActionAbstract
+{
+
+ private Scanner scanner;
+
+ @Option(name = "--silent-input", description = "It will disable all the inputs, and it would make a best guess for any required input")
+ private boolean silentInput = false;
+
+ public boolean isSilentInput()
+ {
+ return silentInput;
+ }
+
+ public void setSilentInput(boolean silentInput)
+ {
+ this.silentInput = silentInput;
+ }
+
+ protected String input(String propertyName, String prompt, String silentDefault)
+ {
+ if (silentInput)
+ {
+ return silentDefault;
+ }
+
+ String inputStr;
+ boolean valid = false;
+ System.out.println();
+ do
+ {
+ context.out.println(propertyName + ": is mandatory with this configuration:");
+ context.out.println(prompt);
+ inputStr = scanner.nextLine();
+ if (inputStr.trim().equals(""))
+ {
+ System.out.println("Invalid Entry!");
+ }
+ else
+ {
+ valid = true;
+ }
+ }
+ while (!valid);
+
+ return inputStr.trim();
+ }
+
+ protected String inputPassword(String propertyName, String prompt, String silentDefault)
+ {
+ if (silentInput)
+ {
+ return silentDefault;
+ }
+
+ String inputStr;
+ boolean valid = false;
+ System.out.println();
+ do
+ {
+ context.out.println(propertyName + ": is mandatory with this configuration:");
+ context.out.println(prompt);
+ inputStr = new String(System.console().readPassword());
+
+ if (inputStr.trim().equals(""))
+ {
+ System.out.println("Invalid Entry!");
+ }
+ else
+ {
+ valid = true;
+ }
+ }
+ while (!valid);
+
+ return inputStr.trim();
+ }
+
+ @Override
+ public Object execute(ActionContext context) throws Exception
+ {
+ super.execute(context);
+
+ this.scanner = new Scanner(context.in);
+
+ return null;
+ }
+
+}
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap-web-settings.txt b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap-web-settings.txt
new file mode 100644
index 0000000..790cda3
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap-web-settings.txt
@@ -0,0 +1,4 @@
+ <!-- The web server is only bound to loalhost by default -->
+ <web bind="http://localhost:${http.port}" path="web">
+ <app url="jolokia" war="jolokia-war-1.2.3.war"/>
+ </web>
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 b4164d8..be51734 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
@@ -25,10 +25,7 @@
<server configuration="file:${artemis.instance}/etc/broker.xml"/>
- <!-- The web server is only bound to loalhost by default -->
- <web bind="http://localhost:${http.port}" path="web">
- <app url="jolokia" war="jolokia-war-1.2.3.war"/>
- </web>
+${bootstrap-web-settings}
</broker>
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/cluster-settings.txt b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/cluster-settings.txt
index 18460ed..2b9c48e 100644
--- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/cluster-settings.txt
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/cluster-settings.txt
@@ -19,7 +19,9 @@
<cluster-connections>
<cluster-connection name="my-cluster">
<address>jms</address>
- <connector-ref>activemq</connector-ref>
+ <connector-ref>artemis</connector-ref>
+ <max-hops>${max-hops}</max-hops>
<discovery-group-ref discovery-group-name="dg-group1"/>
</cluster-connection>
</cluster-connections>
+
diff --git a/artemis-cli/src/test/java/org/apache/activemq/artemis/test/StreamClassPathTest.java b/artemis-cli/src/test/java/org/apache/activemq/artemis/test/StreamClassPathTest.java
index c9f7771..8a6764c 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/artemis/test/StreamClassPathTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/artemis/test/StreamClassPathTest.java
@@ -48,6 +48,7 @@
openStream(Create.ETC_CLUSTER_SECURITY_SETTINGS_TXT);
openStream(Create.ETC_CLUSTER_SETTINGS_TXT);
openStream(Create.ETC_CONNECTOR_SETTINGS_TXT);
+ openStream(Create.ETC_BOOTSTRAP_WEB_SETTINGS_TXT);
}
diff --git a/artemis-distribution/src/main/resources/README.html b/artemis-distribution/src/main/resources/README.html
index 082b453..3114718 100644
--- a/artemis-distribution/src/main/resources/README.html
+++ b/artemis-distribution/src/main/resources/README.html
@@ -44,23 +44,23 @@
The create process will input for any required property not specified. Example:
<PRE>
---user: is mandatory at the current context:
+--user: is mandatory with this configuration:
Please provide the default username:
admin
---password: is mandatory at the current context:
+--password: is mandatory with this configuration:
Please provide the default password:
---allow-anonymous: is mandatory at the current context:
+--allow-anonymous: is mandatory with this configuration:
Allow anonymous access? (Y/N):
-Y
+y
+
</PRE>
For a full list of availble options for the create process you may use:
$ ./artemis help create
-
<PRE>
NAME
artemis create - creates a new broker instance