Skip to content

Commit

Permalink
Merge pull request #27 from orange-buffalo/boolean-property
Browse files Browse the repository at this point in the history
Support for boolean properties
  • Loading branch information
northlander authored May 26, 2018
2 parents 0a1c5a7 + f3ce589 commit 0f30e42
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 @@ -48,7 +48,6 @@
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
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 @@ -141,6 +140,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 @@ -626,6 +626,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 @@ -658,6 +659,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 @@ -1162,6 +1167,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 0f30e42

Please sign in to comment.