ObjectMessage m = createObjectMessage ();
Serializable content = ((ObjectMessage) message).getObject ();
m.setObject ( content );
ret = m;
} else if ( message instanceof StreamMessage ) {
StreamMessage m = createStreamMessage ();
StreamMessage src = (StreamMessage) message;
Object lastRead = null;
do {
lastRead = null;
try {
lastRead = src.readObject ();
if ( lastRead != null ) {
m.writeObject ( lastRead );
// System.out.println ( "Copied object: " + lastRead );
// System.out.println ( "to message: " + m );
}
} catch ( MessageEOFException noMoreData ) {
}
} while ( lastRead != null );
ret = m;
} else if ( message instanceof BytesMessage ) {
BytesMessage m = createBytesMessage ();
BytesMessage src = (BytesMessage) message;
final int LEN = 100;
byte[] buf = new byte[LEN];
int bytesRead = src.readBytes ( buf );
while ( bytesRead >= 0 ) {
m.writeBytes ( buf, 0, bytesRead );
bytesRead = src.readBytes ( buf );
}
ret = m;
} else {
// no known subinterface of Message