use of org.jpos.transaction.Context in project jPOS by jpos.
the class SendResponse method prepare.
public int prepare(long id, Serializable context) {
Context ctx = (Context) context;
ISOSource source = (ISOSource) ctx.get(this.source);
if (source == null || !source.isConnected())
return ABORTED | READONLY | NO_JOIN;
return PREPARED | READONLY;
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class Switch method select.
public String select(long id, Serializable ser) {
Context ctx = (Context) ser;
String type = ctx.getString(txnNameEntry);
String groups = null;
if (type != null)
groups = cfg.get(type, null);
if (groups == null)
groups = cfg.get("unknown", "");
ctx.log("SWITCH " + type + " (" + groups + ")");
return groups;
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class Trace method prepare.
public int prepare(long id, Serializable o) {
Context ctx = (Context) o;
ctx.checkPoint("prepare:" + trace);
return PREPARED | READONLY;
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class IncomingListener method process.
public boolean process(ISOSource src, ISOMsg m) {
final Context ctx = new Context();
if (remote)
src = new SpaceSource((LocalSpace) sp, src, timeout);
ctx.put(timestamp, new Date(), remote);
ctx.put(source, src, remote);
ctx.put(request, m, remote);
if (additionalContextEntries != null) {
additionalContextEntries.entrySet().forEach(e -> ctx.put(e.getKey(), e.getValue(), remote));
}
sp.out(queue, ctx, timeout);
return true;
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class IncomingListener method setConfiguration.
@SuppressWarnings("unchecked")
public void setConfiguration(Configuration cfg) throws ConfigurationException {
timeout = cfg.getLong("timeout", 15000L);
sp = (Space<String, Context>) SpaceFactory.getSpace(cfg.get("space"));
queue = cfg.get("queue", null);
if (queue == null)
throw new ConfigurationException("queue property not specified");
source = cfg.get("source", ContextConstants.SOURCE.toString());
request = cfg.get("request", ContextConstants.REQUEST.toString());
timestamp = cfg.get("timestamp", ContextConstants.TIMESTAMP.toString());
remote = cfg.getBoolean("remote") || cfg.get("space").startsWith("rspace:");
Map<String, String> m = new HashMap<>();
cfg.keySet().stream().filter(s -> s.startsWith("ctx.")).forEach(s -> m.put(s.substring(4), cfg.get(s)));
if (m.size() > 0)
additionalContextEntries = m;
}
Aggregations