File size: 3,432 Bytes
c574d3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
package com.thomsonreuters.upa.valueadd.examples.provider;
import com.thomsonreuters.upa.valueadd.examples.common.CommandLineParser;
class ProviderCmdLineParser implements CommandLineParser
{
private String portNo;
private String interfaceName;
private String serviceName;
private int serviceId;
private int runtime = 1200; // default runtime is 1200 seconds
private boolean enableXmlTracing;
private boolean cacheOption;
private boolean supportView;
private int openWindow=0; // 0 will not set
@Override
public boolean parseArgs(String[] args)
{
try
{
int argsCount = 0;
while (argsCount < args.length)
{
if ("-p".equals(args[argsCount]))
{
portNo = args[++argsCount];
++argsCount;
}
else if ("-i".equals(args[argsCount]))
{
interfaceName = args[++argsCount];
++argsCount;
}
else if ("-s".equals(args[argsCount]))
{
serviceName = args[++argsCount];
++argsCount;
}
else if ("-id".equals(args[argsCount]))
{
serviceId = Integer.parseInt(args[++argsCount]);
++argsCount;
}
else if ("-runtime".equals(args[argsCount]))
{
runtime = Integer.parseInt(args[++argsCount]);
++argsCount;
}
else if ("-x".equals(args[argsCount]))
{
enableXmlTracing = true;
++argsCount;
}
else if ("-cache".equals(args[argsCount]))
{
cacheOption = true;
++argsCount;
}
else if ("-supportView".equals(args[argsCount]))
{
supportView = true;
++argsCount;
}
else if ("-openWindow".equals(args[argsCount]))
{
openWindow = Integer.parseInt(args[++argsCount]);
++argsCount;
}
else // unrecognized command line argument
{
System.out.println("\nUnrecognized command line argument...\n");
return false;
}
}
}
catch (Exception e)
{
System.out.println("\nInvalid command line arguments...");
return false;
}
return true;
}
@Override
public void printUsage()
{
System.out.println("Usage: Provider or\nProvider [-p <port number>] [-i <interface name>] [-s <service name>] [-id <service ID>] [-supportView <false>] [-openWindow <openWindow>] [-runtime <seconds>]" +
"\n -p server port number (defaults to 14002)\n" +
"\n -i interface name (defaults to null)\n" +
"\n -s service name (defaults to DIRECT_FEED)\n" +
"\n -id service id (defaults to 1)\n" +
"\n -x provides an XML trace of messages\n" +
"\n -cache turn on the cache feature of the application\n" +
"\n -supportView sets supportView on Login Response\n" +
"\n -openWindow sets value of openWindows on Directory Response\n" +
"\n -runtime application runtime in seconds (default is 1200)");
}
String portNo()
{
return portNo;
}
String interfaceName()
{
return interfaceName;
}
String serviceName()
{
return serviceName;
}
int serviceId()
{
return serviceId;
}
int runtime()
{
return runtime;
}
boolean enableXmlTracing()
{
return enableXmlTracing;
}
boolean cacheOption()
{
return cacheOption;
}
boolean supportView()
{
return supportView;
}
int openWindow()
{
return openWindow;
}
}
|