MethodInvocation mi = readHeader(dis);
MethodInvocation mi = readHeader(ois);
   public Object read(InputStream in, Map map) throws IOException, ClassNotFoundException   {      //Sanity check      if (!(in instanceof JMSObjectInputStream))      {         throw new IllegalStateException("InputStream must be an JMSObjectInputStream");      }            JMSObjectInputStream ois = (JMSObjectInputStream)in;      DataInputStream dis = ois.getDataInputStream();            byte formatType = (byte)dis.read();            if (trace) { log.trace("Reading, format type=" + formatType); }             switch (formatType)      {         case SERIALIZED:                     {                        //Delegate to serialization            Object ret = serializableUnMarshaller.read(ois, map);                                    if (trace) { log.trace("Read using standard serialization"); }                        return ret;                     }                     case SEND:         {                        MethodInvocation mi = readHeader(dis);                        byte messageType = dis.readByte();                        JBossMessage m = (JBossMessage)MessageFactory.createMessage(messageType);                        m.readExternal(ois);                                    Object[] args = new Object[] {m};                        mi.setArguments(args);                        InvocationRequest request = new InvocationRequest(null, null, mi, null, null, null);                        if (trace) { log.trace("Read send"); }                        return request;          }                     case ACTIVATE:                     {            MethodInvocation mi = readHeader(dis);                                        InvocationRequest request = new InvocationRequest(null, null, mi, null, null, null);                        if (trace) { log.trace("Read activate"); }                        return request;               }         case DEACTIVATE:                     {            MethodInvocation mi = readHeader(dis);                        InvocationRequest request = new InvocationRequest(null, null, mi, null, null, null);                        if (trace) { log.trace("Read deactivate"); }                        return request;               }         case GETMESSAGENOW:                     {             MethodInvocation mi = readHeader(dis);                        boolean wait = dis.readBoolean();                                                            Object[] args = new Object[] {Boolean.valueOf(wait)};                        mi.setArguments(args);                            InvocationRequest request = new InvocationRequest(null, null, mi, null, null, null);                        if (trace) { log.trace("Read getMessageNow"); }                        return request;               }         case ACKNOWLEDGE:         {            MethodInvocation mi = readHeader(dis);                             InvocationRequest request = new InvocationRequest(null, null, mi, null, null, null);                        if (trace) { log.trace("Read acknowledge"); }                        return request;         }                  case CALLBACK:         {            int consumerID = dis.readInt();                        byte type = dis.readByte();                        int deliveryCount = dis.readInt();            JBossMessage m = (JBossMessage)MessageFactory.createMessage(type);                        m.readExternal(ois);                        MessageDelegate md = JBossMessage.createThinDelegate(m, deliveryCount);                        DeliveryRunnable dr = new DeliveryRunnable(md, null, consumerID, trace);                        InvocationRequest request = new InvocationRequest(null, null, dr, null, null, null);                        if (trace) { log.trace("Read callback"); }                        return request;                     }         case MESSAGE_RESPONSE:         {            byte type = dis.readByte();                        int deliveryCount = dis.readInt();            JBossMessage m = (JBossMessage)MessageFactory.createMessage(type);                        m.readExternal(ois);                        MessageDelegate md = JBossMessage.createThinDelegate(m, deliveryCount);                                    InvocationResponse resp = new InvocationResponse(null, md, false, null);                        if (trace) { log.trace("Read message response"); }                        return resp;                     }         case NULL_RESPONSE:         {            InvocationResponse resp = new InvocationResponse(null, null, false, null);                        if (trace) { log.trace("Read null response"); }                        return resp;         }         default:         {            throw new IllegalStateException("Invalid format type " + formatType);         }                 }         }  