bmsg.readBytes(data, len);
return NIOConverter.toByteBuffer(data);
}
if (message instanceof StreamMessage) {
final StreamMessage msg = (StreamMessage)message;
final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
final DataOutputStream dataOut = new DataOutputStream(bytesOut);
try {
while (true) {
final Object obj = msg.readObject();
writeData(dataOut, obj);
}
} catch (MessageEOFException e) {
// we have no other way of knowing the end of the message
} finally {
dataOut.close();
}
return NIOConverter.toByteBuffer(bytesOut.toByteArray());
}
if (message instanceof MapMessage) {
final MapMessage msg = (MapMessage)message;
final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
final DataOutputStream dataOut = new DataOutputStream(bytesOut);
for (final Enumeration en = msg.getMapNames(); en.hasMoreElements();) {
final Object obj = msg.getObject(en.nextElement().toString());
writeData(dataOut, obj);
}
dataOut.close();
return NIOConverter.toByteBuffer(bytesOut.toByteArray());
}