public Object read(InputStream in, Map map) throws IOException, ClassNotFoundException
{
if (trace) { log.trace("Reading"); }
DataInputStream dis;
if (in instanceof DataInputStream)
{
//For non HTTP transports - we should ALWAYS be passed a DataInputStream
//We do this by specifying socket wrapper classes on the locator uri
dis = (DataInputStream)in;
if (trace) { log.trace("Stream is already DataInputStream :)"); }
}
else
{
// Further sanity check
if (in instanceof ObjectInputStream)
{
throw new IllegalArgumentException("Invalid stream - are you sure you have " +
"configured socket wrappers?");
}
// This would be the case for the HTTP transport for example. Wrap the stream
//FIXME Ideally remoting would let us wrap this before invoking the marshaller
// but this does not appear to be possible
dis = new DataInputStream(in);
if (trace) { log.trace("Stream is NOT DataInputStream - must be using HTTP transport"); }
}
int id = dis.readInt();
PacketSupport packet = PacketSupport.createPacket(id);
if (trace) { log.trace("Created packet " + packet); }