Exemple #1
0
 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) {
     }
   }
 }
Exemple #2
0
 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) {
     }
   }
 }