use of org.jpos.iso.ISOException in project jPOS by jpos.
the class LoopbackChannel method receive.
public ISOMsg receive() throws IOException, ISOException {
if (!isConnected())
throw new ISOException("unconnected ISOChannel");
try {
ISOMsg m = (ISOMsg) ((ISOMsg) queue.dequeue()).clone();
LogEvent evt = new LogEvent(this, "loopback-receive", m);
m = applyIncomingFilters(m, evt);
cnt[RX]++;
notifyObservers();
Logger.log(evt);
return m;
} catch (InterruptedException e) {
throw new IOException(e.toString());
} catch (BlockingQueue.Closed e) {
throw new IOException(e.toString());
}
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class SpaceMUX method notify.
public void notify(Object k, Object value) {
Object obj = sp.inp(k);
if (obj instanceof ISOMsg) {
ISOMsg m = (ISOMsg) obj;
try {
String key = getKey(m);
String req = key + ".req";
if (sp.inp(req) != null) {
sp.out(key, m);
return;
}
} catch (ISOException e) {
Logger.log(new LogEvent(this, "notify", e));
}
if (unhandled != null)
sp.out(unhandled, m, 120000);
}
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class ISOMultiFieldPackager method unpack.
/**
* @param m - the ISOComponent to receive the value consumed from ...
* @param b - the byte[] holding the raw message
* @param offset - the current position within b.
*/
public int unpack(ISOComponent m, byte[] b, int offset) throws ISOException {
ListIterator i = possibles.listIterator();
while (i.hasNext()) {
try {
current = (ISOFieldPackager) i.next();
ISOField f = new ISOField();
int consumed = current.unpack(f, b, offset);
m.setValue(f.getValue());
return consumed;
} catch (ISOException eok) {
current = null;
}
}
throw new ISOException("unpack failed in List process!");
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class ISOMultiFieldPackager method unpack.
/**
* Unpack the passed InputStream into an ISOComponent from our list of possibles.
* The InputStream *must* support mark!
*/
public void unpack(ISOComponent c, InputStream in) throws IOException, ISOException {
if (!in.markSupported()) {
throw new ISOException("InputStream passed to ISOMultFieldPackager *must* support the mark method.");
}
ListIterator i = possibles.listIterator();
// Save our position in the InputStream
in.mark(1024);
while (i.hasNext()) {
in.reset();
try {
// One of our possibles will succeed in it's unpack from this Stream.
current = (ISOFieldPackager) i.next();
current.unpack(c, in);
return;
} catch (ISOException eok) {
// This one failed.
current = null;
} catch (IOException eok) {
// This one failed.
current = null;
}
}
throw new ISOException("unpack failed to find a match in the possible List!");
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class VISA1PackagerTest method testPackThrowsISOException.
public void testPackThrowsISOException() throws Throwable {
int[] sequence = new int[0];
try {
new VISA1Packager(sequence, 100, "testVISA1PackagerBadResultCode", "testVISA1PackagerOkPattern").pack(new ISOField());
fail("Expected ISOException to be thrown");
} catch (ISOException ex) {
assertEquals("ex.getMessage()", "Can't call VISA1 packager on non ISOMsg", ex.getMessage());
assertNull("ex.getNested()", ex.getNested());
}
}
Aggregations