Search in sources :

Example 41 with Context

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;
}
Also used : Context(org.jpos.transaction.Context) ISOSource(org.jpos.iso.ISOSource)

Example 42 with Context

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;
}
Also used : Context(org.jpos.transaction.Context)

Example 43 with Context

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;
}
Also used : Context(org.jpos.transaction.Context)

Example 44 with Context

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;
}
Also used : Context(org.jpos.transaction.Context) SpaceSource(org.jpos.space.SpaceSource) Date(java.util.Date)

Example 45 with Context

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;
}
Also used : Context(org.jpos.transaction.Context) Context(org.jpos.transaction.Context) SpaceFactory(org.jpos.space.SpaceFactory) ConfigurationException(org.jpos.core.ConfigurationException) Date(java.util.Date) SpaceSource(org.jpos.space.SpaceSource) LocalSpace(org.jpos.space.LocalSpace) Log(org.jpos.util.Log) HashMap(java.util.HashMap) Configurable(org.jpos.core.Configurable) ContextConstants(org.jpos.transaction.ContextConstants) Space(org.jpos.space.Space) Configuration(org.jpos.core.Configuration) Map(java.util.Map) ConfigurationException(org.jpos.core.ConfigurationException) HashMap(java.util.HashMap)

Aggregations

Context (org.jpos.transaction.Context)45 Test (org.junit.Test)29 Result (org.jpos.rc.Result)26 ISOMsg (org.jpos.iso.ISOMsg)20 Date (java.util.Date)5 ISODate (org.jpos.iso.ISODate)3 SpaceSource (org.jpos.space.SpaceSource)2 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Element (org.jdom2.Element)1 Configurable (org.jpos.core.Configurable)1 Configuration (org.jpos.core.Configuration)1 ConfigurationException (org.jpos.core.ConfigurationException)1 ISOAmount (org.jpos.iso.ISOAmount)1 ISOSource (org.jpos.iso.ISOSource)1 LocalSpace (org.jpos.space.LocalSpace)1 Space (org.jpos.space.Space)1 SpaceFactory (org.jpos.space.SpaceFactory)1