You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Helper method to parse the args[] from the command line.
251
+
*
252
+
* @param args the list of argument passed to the main method
253
+
*
254
+
*/
255
+
privatestaticvoidparseArgs(Stringargs[]) {
256
+
System.out.println(""); // Presentation padding on console
257
+
// Sanity check main() arguments and warn user
258
+
if (args.length > 0) {
259
+
logOutput(WARNING,
260
+
"You have provided arguments to the Java main() function. JVM arguments (such as -Djavax.net.ssl.trustStore) must be passed before the main class or .jar you wish to run.\n\n");
261
+
262
+
// Parse command line arguments, assuming name value pairs
263
+
Stringoption = null;
264
+
Stringvalue = null;
265
+
for (inti = 0; i < args.length; i += 2) { // iterate 2: name,value
266
+
option = args[i].toLowerCase(); // force lower case
267
+
268
+
// Check the option and cast the value as needed
269
+
switch (option) {
270
+
case"-host": // hostname
271
+
HOST = getValue(option, args, i);
272
+
logOutput(INFO, "Host [" + HOST + "]");
273
+
break;
274
+
case"-p": // port number
275
+
try {
276
+
PORT = Integer.parseInt(getValue(option, args, i));
277
+
} catch (NumberFormatExceptionnfe) {
278
+
status = -1;
279
+
logOutput(ERROR, "Unabale to parse value \"" + value + "\" specified for option \""
280
+
+ option + "\"");
281
+
System.exit(status);
282
+
}
283
+
logOutput(INFO, "Port [" + PORT + "]");
284
+
break;
285
+
case"-c": // channel name
286
+
CHANNEL = getValue(option, args, i);
287
+
logOutput(INFO, "Channel [" + CHANNEL + "]");
288
+
break;
289
+
case"-qm":
290
+
QMGR = getValue(option, args, i);
291
+
logOutput(INFO, "Queue Manager [" + QMGR + "]");
292
+
break;
293
+
case"-u":
294
+
APP_USER = getValue(option, args, i);
295
+
logOutput(INFO, "App User [" + APP_USER + "]");
296
+
break;
297
+
case"-pw":
298
+
APP_PASSWORD = getValue(option, args, i);
299
+
logOutput(INFO, "Password [" + "******" + "]");
300
+
break;
301
+
case"-q":
302
+
QUEUE_NAME = getValue(option, args, i);
303
+
logOutput(INFO, "Queue [" + QUEUE_NAME + "]");
304
+
break;
305
+
case"-t":
306
+
i--; // no value for boolean flags, so realign
307
+
doTls = true;
308
+
logOutput(INFO, "TLS enabled");
309
+
break;
310
+
case"-put":
311
+
i--; // no value for boolean flags, so realign
312
+
doGet = false;
313
+
logOutput(INFO, "put only mode");
314
+
break;
315
+
case"-get":
316
+
i--; // no value for boolean flags, so realign
317
+
doPut = false;
318
+
logOutput(INFO, "get only mode");
319
+
break;
320
+
default:
321
+
status = -1;
322
+
if (!(option.equals("-h") || option.equals("-help"))) {
logOutput(MSG, "Welcome to " + JmsPutGetInteractive.class.getSimpleName());
328
+
logOutput(MSG, "A JMS Put and Get utility for the IBM MQ Developer Essential Workshop.");
329
+
logOutput(MSG,
330
+
"The default bahavior is to generate a random number and add this number to a new message payload. The message is then produced and then consumed from the specified queue. The following command line options are available. ");
331
+
logOutput(MSG, ""); // Padding
332
+
logOutput(MSG, "Options:");
333
+
logOutput(MSG, "-help | -h Displays this message.");
0 commit comments