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());
}
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
}
}
}
Aggregations