Skip to content

Commit

Permalink
support for boolean properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan committed May 25, 2018
1 parent bd376bd commit f3ce589
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ usage: java -jar a-<version>-with-dependencies.jar [-A] [-a] [-b <arg>]
-A,--amqp Set protocol to AMQP. Defaults to OpenWire
-a,--artemis-core Set protocol to ActiveMQ Artemis Core.
Defaults to OpenWire
-B <property=value> use value for given Boolean property. Can
be used several times.
-b,--broker <arg> URL to broker. defaults to:
tcp://localhost:61616
-C,--copy-queue <arg> Copy all messages from this to target.
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/co/nordlander/a/A.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import javax.script.ScriptException;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.MessageTransformer;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.ActiveMQQueue;
Expand Down Expand Up @@ -133,6 +132,7 @@ public void output(Object... args) {
public static final String CMD_RESTORE_DUMP = "X";
public static final String CMD_WRITE_DUMP = "x";
public static final String CMD_JMS_TYPE = "y";
public static final String CMD_SET_BOOLEAN_HEADER = "B";

// Various constants
public static final long SLEEP_TIME_BETWEEN_FILE_CHECK = 1000L;
Expand Down Expand Up @@ -593,6 +593,7 @@ protected void putData(final String data, final CommandLine cmdLine) throws IOEx
Properties props = cmdLine.getOptionProperties(CMD_SET_HEADER);
Properties intProps = cmdLine.getOptionProperties(CMD_SET_INT_HEADER);
Properties longProps = cmdLine.getOptionProperties(CMD_SET_LONG_HEADER);
Properties booleanProps = cmdLine.getOptionProperties(CMD_SET_BOOLEAN_HEADER);

String type = cmdLine.getOptionValue(CMD_TYPE, DEFAULT_TYPE);
String encoding = cmdLine.getOptionValue(CMD_ENCODING, Charset
Expand Down Expand Up @@ -625,6 +626,10 @@ protected void putData(final String data, final CommandLine cmdLine) throws IOEx
outMsg.setLongProperty((String) p.getKey(), Long.parseLong((String)p.getValue()));
}

for (Entry<Object, Object> p : booleanProps.entrySet()) {
outMsg.setBooleanProperty((String) p.getKey(), Boolean.parseBoolean((String)p.getValue()));
}

if (cmdLine.hasOption("r")) {
outMsg.setJMSReplyTo(createDestination(cmdLine.getOptionValue("r")));
}
Expand Down Expand Up @@ -1129,6 +1134,17 @@ protected Options createOptions() {

opts.addOption(longProperty);

@SuppressWarnings("static-access")
Option booleanProperty = OptionBuilder
.withArgName("property=value")
.hasArgs(2)
.withValueSeparator()
.withDescription(
"use value for given Boolean property. Can be used several times.")
.create(CMD_SET_BOOLEAN_HEADER);

opts.addOption(booleanProperty);

@SuppressWarnings("static-access")
Option intProperty = OptionBuilder
.withArgName("property=value")
Expand Down

0 comments on commit f3ce589

Please sign in to comment.