示例#1
0
  public static void main(String args[]) throws Exception {
    Options opts = new Options(args);

    // first check if we should print usage
    if ((opts.isFlagSet('?') > 0) || (opts.isFlagSet('h') > 0)) printUsage();

    String username = opts.getUser();
    String password = opts.getPassword();

    HashMap connectorMap = SimpleJMSListener.createConnectorMap(opts);
    HashMap cfMap = SimpleJMSListener.createCFMap(opts);
    String destination = opts.isValueSet('d');

    // create the jms listener
    SimpleJMSListener listener =
        new SimpleJMSListener(connectorMap, cfMap, destination, username, password, false);
    listener.start();

    args = opts.getRemainingArgs();
    if (args == null || args.length == 0) printUsage();

    for (int i = 0; i < args.length; i++) {
      try {
        Float res = getQuote(args[i], username, password);
        System.out.println(args[i] + ": " + res);
      } catch (AxisFault af) {
        System.out.println(af.dumpToString());
      }
    }

    // shutdown
    listener.shutdown();

    // close all JMSConnectors whose configuration matches that of the JMS URL
    // note: this is optional, as all connectors will be closed upon exit
    JMSTransport.closeMatchingJMSConnectors(sampleJmsUrl, username, password);

    System.exit(1);
  }