Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for boolean properties #27

Merged
merged 1 commit into from
May 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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