Package org.xmlBlaster.client.protocol.http.common

Examples of org.xmlBlaster.client.protocol.http.common.MsgHolder


         //ServletInputStream in = req.getInputStream();
         //int length = req.getContentLength();
     
         //System.out.println("Content-Length=" + length);
         MsgHolder msg = ObjectInputStreamMicro.readMessage(contentAsBytes);

         //System.out.println("msg: ActionType='" + actionType + "' length='" + length + "'");
         //System.out.println("    - key    : '" + msg.key + "'");
         //System.out.println("    - qos    : '" + msg.qos + "'");
         //String tmp1 = "null";
View Full Code Here


      if (xmlRequest != null) {
         xmlRequest = this.decode(xmlRequest, ENCODING);
         if (log.isLoggable(Level.FINEST)) log.finest("xmlRequest=\n'" + xmlRequest + "'");
      }

      return new MsgHolder(oid, key, qos, content);
   }
View Full Code Here

    * @param res Response of the servlet
    */
   public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
      String ME;
      // null if the message was not passed via the binary protocol
      MsgHolder binaryMsg = readBinaryProtocol(req, res);

      String actionType = req.getHeader("ActionType");
     
      if (actionType == null) {
         actionType = getParameter(req, "ActionType", "NONE");
      }   
     
      synchronized(AppletServlet.class) {
         requestCounter++;  // For logging only
         String appletInstanceCount = getParameter(req, "appletInstanceCount", "0");
         ME  = this.getClass().getName() + "-" + req.getRemoteAddr() + "-#" + appletInstanceCount + "req" + requestCounter + "-" + actionType;
      }
     
      //String appletInstanceCount = getParameter(req, "appletInstanceCount", "0");

      if (actionType.equalsIgnoreCase(I_XmlBlasterAccessRaw.CONNECT_NAME) ||
          actionType.equalsIgnoreCase(I_XmlBlasterAccessRaw.DISCONNECT_NAME) ||
          actionType.equalsIgnoreCase(I_XmlBlasterAccessRaw.PONG_NAME) ||
          actionType.equalsIgnoreCase(I_XmlBlasterAccessRaw.CREATE_SESSIONID_NAME)) { // "connect", "disconnect"
         doGetFake(ME, req, res, actionType, binaryMsg);
         return;
      }

      res.setContentType("text/plain");
      //HttpSession session = req.getSession(false);
      String sessionId = req.getRequestedSessionId();

      ME  += "-" + sessionId;
      if (log.isLoggable(Level.FINE)) log.fine("Entering servlet doPost() ...");

      Global glob = null;
      I_XmlBlasterAccess xmlBlaster = null;
      PushHandler pushHandler = null;
      Object returnObject = null;

      try {
         pushHandler = getPushHandler(req);
         xmlBlaster = pushHandler.getXmlBlasterAccess();
         glob = xmlBlaster.getGlobal();
      }
      catch (XmlBlasterException e) {
         log.warning("Caught XmlBlaster Exception: " + e.getMessage());
         writeResponse(res, I_XmlBlasterAccessRaw.EXCEPTION_NAME, e.getMessage());
         return;
      }

      try {
         // Extract the message data

         MsgHolder msg = extractMessage(ME, log, req, binaryMsg);
         String oid = msg.getOid();
         String key = msg.getKey();
         String qos = msg.getQos();
         String xmlRequest = msg.getKey(); // in case of xmlScript the request is sent as the key (all other are null)
         byte[] content = msg.getContent();
        
         if (actionType.equals(I_XmlBlasterAccessRaw.PING_NAME)) { // "ping"
            if (log.isLoggable(Level.FINE)) log.fine("ping arrived, qos=" + qos);
            Hashtable map = new Hashtable();
            if (xmlBlaster.isAlive()) {
View Full Code Here

         int size = bais.available();
         assertEquals("wrong length of bytes available", length, size);
         byte[] msg = new byte[size];
         bais.read(msg);
         MsgHolder msgHolder = ObjectInputStreamMicro.readMessage(msg);
        
         assertEquals("wrong content for the oid", oid, msgHolder.getOid());
         assertEquals("wrong content for the key", key, msgHolder.getKey());
         assertEquals("wrong content for the qos", qos, msgHolder.getQos());
         assertEquals("wrong content for the content", new String(content), new String(msgHolder.getContent()));
        
         log.info("testMessageIO successfully completed");
      }
      catch (Exception ex) {
         ex.printStackTrace();        
View Full Code Here

TOP

Related Classes of org.xmlBlaster.client.protocol.http.common.MsgHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.