示例#1
0
文件: TAIL.java 项目: juanibdn/jPOS
 public void exec(CLIContext cli, String[] args) throws Exception {
   this.p = cli.getOutputStream();
   this.cli = cli;
   this.ansi = cli.getConsoleReader().getTerminal().isANSISupported();
   if (args.length == 1) {
     usage(cli);
     return;
   }
   for (int i = 1; i < args.length; i++) {
     try {
       Logger logger = (Logger) NameRegistrar.get("logger." + args[i]);
       logger.addListener(this);
     } catch (NameRegistrar.NotFoundException e) {
       cli.println("Logger " + args[i] + " not found -- ignored.");
     }
   }
   cli.getConsoleReader().readCharacter(new char[] {'q', 'Q'});
   for (int i = 1; i < args.length; i++) {
     try {
       Logger logger = (Logger) NameRegistrar.get("logger." + args[i]);
       logger.removeListener(this);
     } catch (NameRegistrar.NotFoundException e) {
     }
   }
 }
示例#2
0
文件: TMMON.java 项目: Zengwn/jPOS
 private void showTMs(CLIContext cli) {
   NameRegistrar nr = NameRegistrar.getInstance();
   int maxw = 0;
   Iterator iter = NameRegistrar.getMap().entrySet().iterator();
   StringBuilder sb = new StringBuilder("available transaction managers:");
   while (iter.hasNext()) {
     Map.Entry entry = (Map.Entry) iter.next();
     String key = (String) entry.getKey();
     if (entry.getValue() instanceof TransactionManager) {
       sb.append(' ');
       sb.append(key);
     }
   }
   cli.println(sb.toString());
 }
示例#3
0
文件: TMMON.java 项目: Zengwn/jPOS
 public void exec(CLIContext cli, String[] args) throws Exception {
   this.p = cli.getOutputStream();
   this.cli = cli;
   this.ansi = cli.getConsoleReader().getTerminal().isANSISupported();
   if (args.length == 1) {
     usage(cli);
     return;
   }
   for (int i = 1; i < args.length; i++) {
     try {
       Object obj = NameRegistrar.get(args[i]);
       if (obj instanceof TransactionManager) {
         ((TransactionManager) obj).addListener(this);
       } else {
         cli.println(
             "Object '"
                 + args[i]
                 + "' is not an instance of TransactionManager ("
                 + obj.toString()
                 + ")");
       }
     } catch (NameRegistrar.NotFoundException e) {
       cli.println("TransactionManager '" + args[i] + "' not found -- ignored.");
     }
   }
   cli.getConsoleReader().readCharacter(new char[] {'q', 'Q'});
   for (int i = 1; i < args.length; i++) {
     try {
       Object obj = NameRegistrar.get(args[i]);
       if (obj instanceof TransactionManager) {
         ((TransactionManager) obj).removeListener(this);
       }
     } catch (NameRegistrar.NotFoundException ignored) {
     }
   }
 }
示例#4
0
文件: TAIL.java 项目: juanibdn/jPOS
 private void showLoggers(CLIContext cli) {
   NameRegistrar nr = NameRegistrar.getInstance();
   int maxw = 0;
   Iterator iter = NameRegistrar.getAsMap().entrySet().iterator();
   StringBuilder sb = new StringBuilder("available loggers:");
   while (iter.hasNext()) {
     Map.Entry entry = (Map.Entry) iter.next();
     String key = (String) entry.getKey();
     if (key.startsWith("logger.") && entry.getValue() instanceof Logger) {
       sb.append(' ');
       sb.append(key.substring(7));
     }
   }
   cli.println(sb.toString());
 }
示例#5
0
文件: TAIL.java 项目: juanibdn/jPOS
 public synchronized LogEvent log(LogEvent ev) {
   if (p != null) {
     Date d = new Date(System.currentTimeMillis());
     ANSIBuffer ab = new ANSIBuffer();
     ab.setAnsiEnabled(ansi);
     cli.println(
         ab.bold(
                 ev.getSource().getLogger().getName()
                     + ": "
                     + ev.getRealm()
                     + " "
                     + d.toString()
                     + "."
                     + d.getTime() % 1000)
             .toString(ansi));
     ev.dump(p, " ");
     p.flush();
   }
   return ev;
 }
示例#6
0
文件: DATE.java 项目: krauz0/jPOS
 public void exec(CLIContext ctx, String[] args) {
   ctx.println(new Date().toString());
 }
示例#7
0
文件: TMMON.java 项目: Zengwn/jPOS
 public void update(TransactionStatusEvent e) {
   cli.println(e.toString());
 }
示例#8
0
文件: TMMON.java 项目: Zengwn/jPOS
 public void usage(CLIContext cli) {
   cli.println("Usage: tmmon [tm-name] [tm-name] ...");
   showTMs(cli);
 }
示例#9
0
文件: TAIL.java 项目: juanibdn/jPOS
 public void usage(CLIContext cli) {
   cli.println("Usage: tail [log-name] [log-name] ...");
   showLoggers(cli);
 }