use of org.jpos.iso.ISOException in project jPOS by jpos.
the class NativePackager method unpack.
@Override
public void unpack(ISOComponent m, InputStream in) throws IOException, ISOException {
try {
if (m instanceof Externalizable) {
ObjectInputStream is = new ObjectInputStream(in);
((Externalizable) m).readExternal(is);
}
} catch (Exception e) {
throw new ISOException(e);
}
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class NativePackager method pack.
@Override
public byte[] pack(ISOComponent c) throws ISOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
if (c instanceof ISOMsg) {
ISOMsg m = (ISOMsg) c;
ISOPackager p = m.getPackager();
m.setPackager(null);
ObjectOutputStream os = new ObjectOutputStream(baos);
((Externalizable) c).writeExternal(os);
os.flush();
m.setPackager(p);
}
} catch (IOException e) {
throw new ISOException(e);
}
return baos.toByteArray();
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class ProtectedLogListener method log.
public LogEvent log(LogEvent ev) {
synchronized (ev.getPayLoad()) {
final List<Object> payLoad = ev.getPayLoad();
int size = payLoad.size();
for (int i = 0; i < size; i++) {
Object obj = payLoad.get(i);
if (obj instanceof ISOMsg) {
ISOMsg m = (ISOMsg) ((ISOMsg) obj).clone();
try {
checkProtected(m);
checkHidden(m);
} catch (ISOException e) {
ev.addMessage(e);
}
payLoad.set(i, m);
} else if (obj instanceof SimpleMsg) {
try {
checkProtected((SimpleMsg) obj);
} catch (ISOException e) {
ev.addMessage(e);
}
}
}
}
return ev;
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class QServer method notify.
/*
* This method will be invoked through the SpaceListener interface we registered once
* we noticed we had an 'in' queue.
*/
@Override
public void notify(Object key, Object value) {
Object obj = sp.inp(key);
if (obj instanceof ISOMsg) {
ISOMsg m = (ISOMsg) obj;
if ("LAST".equals(sendMethod)) {
try {
ISOChannel c = server.getLastConnectedISOChannel();
if (c == null) {
throw new ISOException("Server has no active connections");
}
if (!c.isConnected()) {
throw new ISOException("Client disconnected");
}
c.send(m);
} catch (Exception e) {
getLog().warn("notify", e);
}
} else if ("ALL".equals(sendMethod)) {
String channelNames = getISOChannelNames();
if (channelNames != null) {
StringTokenizer tok = new StringTokenizer(channelNames, " ");
while (tok.hasMoreTokens()) {
try {
ISOChannel c = server.getISOChannel(tok.nextToken());
if (c == null) {
throw new ISOException("Server has no active connections");
}
if (!c.isConnected()) {
throw new ISOException("Client disconnected");
}
c.send(m);
} catch (Exception e) {
getLog().warn("notify", e);
}
}
}
}
}
}
use of org.jpos.iso.ISOException in project jPOS by jpos.
the class LoopbackChannel method send.
public void send(ISOMsg m) throws IOException, ISOException {
if (!isConnected())
throw new ISOException("unconnected ISOChannel");
LogEvent evt = new LogEvent(this, "loopback-send", m);
m = applyOutgoingFilters(m, evt);
queue.enqueue(m);
cnt[TX]++;
notifyObservers();
Logger.log(evt);
}
Aggregations