new InvocationRequest(null, JMSRemotingConnection.JMS_CALLBACK_SUBSYSTEM,
new InvocationRequest(null, CallbackServerFactory.JMS_CALLBACK_SUBSYSTEM,
   public Object read(InputStream in, Map map) throws IOException, ClassNotFoundException   {      // Sanity check      if (!(in instanceof ObjectInputStream))      {         log.error("in is a " + in.getClass());         throw new IllegalStateException("InputStream must be an ObjectInputStream");      }      ObjectInputStream ois = (ObjectInputStream)in;      if (ois instanceof JBossObjectInputStream)      {         // Need to explicitly set the classloader         ((JBossObjectInputStream)ois).            setClassLoader(Thread.currentThread().getContextClassLoader());      }      // First byte read is always version      byte version = ois.readByte();      byte formatType = (byte)ois.read();      if (trace) { log.trace("reading, format type is " + 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(ois);            byte messageType = ois.readByte();            JBossMessage m = (JBossMessage)MessageFactory.createMessage(messageType);            m.readExternal(ois);            Object[] args = new Object[] {m};            mi.setArguments(args);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read send()"); }            return request;         }         case ACTIVATE:         {            MethodInvocation mi = readHeader(ois);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read activate()"); }            return request;         }         case DEACTIVATE:         {            MethodInvocation mi = readHeader(ois);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read deactivate()"); }            return request;         }         case GETMESSAGENOW:         {            MethodInvocation mi = readHeader(ois);            boolean wait = ois.readBoolean();            Object[] args = new Object[] {Boolean.valueOf(wait)};            mi.setArguments(args);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read getMessageNow()"); }            return request;         }         case SEND_TRANSACTION:         {            MethodInvocation mi = readHeader(ois);            TransactionRequest tr = new TransactionRequest();            tr.readExternal(ois);            Object[] args = new Object[] {tr};            mi.setArguments(args);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read sendTransaction()"); }            return request;         }         case GET_ID_BLOCK:         {            MethodInvocation mi = readHeader(ois);            int size = ois.readInt();            Object[] args = new Object[] {new Integer(size)};            mi.setArguments(args);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read getIdBlock()"); }            return request;         }         case ACKNOWLEDGE:         {            MethodInvocation mi = readHeader(ois);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read acknowledge()"); }            return request;         }         case CANCEL_DELIVERY:         {            MethodInvocation mi = readHeader(ois);            long id = ois.readLong();            Object[] args = new Object[] {new Long(id)};            mi.setArguments(args);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read cancelDelivery()"); }            return request;         }         case CANCEL_DELIVERIES:         {            MethodInvocation mi = readHeader(ois);            int size = ois.readInt();            List ids = new ArrayList(size);            for (int i = 0; i < size; i++)            {               long id = ois.readLong();               ids.add(new Long(id));            }            Object[] args = new Object[] {ids};            mi.setArguments(args);            InvocationRequest request =               new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,                                     new MessagingMarshallable(version, mi), null, null, null);            if (trace) { log.trace("read cancelDeliveries()"); }            return request;         }         case MESSAGE_RESPONSE:         {            byte type = ois.readByte();            int deliveryCount = ois.readInt();            JBossMessage m = (JBossMessage)MessageFactory.createMessage(type);            m.readExternal(ois);            MessageProxy md = JBossMessage.createThinDelegate(m, deliveryCount);            InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, md), false, null);            if (trace) { log.trace("read message response"); }            return resp;         }         case ID_BLOCK_RESPONSE:         {            IdBlock block = new IdBlock();            block.readExternal(ois);            InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, block), false, null);            if (trace) { log.trace("read message response"); }            return resp;         }         case DEACTIVATE_RESPONSE:         {            long id = ois.readLong();            InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, new Long(id)), false, null);            if (trace) { log.trace("read deactivate response"); }            return resp;         }         case NULL_RESPONSE:         {            InvocationResponse resp =               new InvocationResponse(null, new MessagingMarshallable(version, null), false, null);            if (trace) { log.trace("read null response"); }            return resp;         }         case CALLBACK:         {            int consumerID = ois.readInt();            byte type = ois.readByte();            int deliveryCount = ois.readInt();            JBossMessage m = (JBossMessage)MessageFactory.createMessage(type);            m.readExternal(ois);            MessageProxy md = JBossMessage.createThinDelegate(m, deliveryCount);            DeliveryRunnable dr = new DeliveryRunnable(md, consumerID, null, trace);            InvocationRequest request =               new InvocationRequest(null, JMSRemotingConnection.JMS_CALLBACK_SUBSYSTEM,                                     new MessagingMarshallable(version, dr), null, null, null);            if (trace) { log.trace("read callback()"); }            return request;         }         default:         {            throw new IllegalStateException("Invalid format type " + formatType);         }      }   }