Search in sources :

Example 1 with TransactionManager

use of org.jpos.transaction.TransactionManager in project jPOS by jpos.

the class TMMON method showTMs.

private void showTMs(CLIContext cli) {
    NameRegistrar nr = NameRegistrar.getInstance();
    int maxw = 0;
    Iterator iter = NameRegistrar.getAsMap().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());
}
Also used : NameRegistrar(org.jpos.util.NameRegistrar) TransactionManager(org.jpos.transaction.TransactionManager) Iterator(java.util.Iterator) Map(java.util.Map)

Example 2 with TransactionManager

use of org.jpos.transaction.TransactionManager in project jPOS by jpos.

the class TMMON method exec.

public void exec(CLIContext cli, String[] args) throws Exception {
    this.p = new PrintStream(cli.getReader().getTerminal().output());
    this.cli = cli;
    // cli.getReader().getTerminal()
    this.ansi = false;
    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.getReader().readLine();
    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) {
        // NOPMD ok to happen
        }
    }
}
Also used : PrintStream(java.io.PrintStream) NameRegistrar(org.jpos.util.NameRegistrar) TransactionManager(org.jpos.transaction.TransactionManager)

Aggregations

TransactionManager (org.jpos.transaction.TransactionManager)2 NameRegistrar (org.jpos.util.NameRegistrar)2 PrintStream (java.io.PrintStream)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1