2 Replies Latest reply on Mar 22, 2003 5:22 AM by Dietmar Scheidl

    HTTP Invoker

    Dietmar Scheidl Newbie

       

      "Didi1976" wrote:
      Hi,

      is there any reason why http invoker does not compress the transferred data?

      I have added two small methods.

      public static byte[] toGZipByteArray(Object obj)
      {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();

      try
      {
      GZIPOutputStream gzos = new GZIPOutputStream(bos);
      ObjectOutputStream os = new ObjectOutputStream(gzos);
      os.writeObject(obj);
      os.flush();
      os.close();
      }
      catch( Exception e )
      {
      log.error("exception creating byte array", e);
      }

      return bos.toByteArray();
      }

      public static Object fromGZipByteArray(Object srcObj)
      {
      Object obj = null;

      try
      {
      byte[] bytes = (byte[])srcObj;
      ByteArrayInputStream bis = new ByteArrayInputStream(bytes);

      GZIPInputStream gzis = new GZIPInputStream(bis);
      ObjectInputStream is = new ObjectInputStream(gzis);
      obj = is.readObject();
      }
      catch( Exception e )
      {
      log.error("exception reading byte array", e);
      }

      return obj;
      }

      Then you have to change Util.java, HttpInvokerProxy.java, HttpNamingContextFactory.java, NamingFactoryServlet.java and InvokerServlet.java to use these methods to compress and decompress the data.

      Regards,
      Didi


        • 1. Re: HTTP Invoker
          Archimedes Trajano Newbie

           

          "trajano" wrote:
          There should be some code to check if gzip is an acceptable encoding before sending the data, not all browsers would support it.


          • 2. Re: HTTP Invoker
            Dietmar Scheidl Newbie

             

            "Didi1976" wrote:
            These Servlets are not called by the Browser. They are used to communicate between an application client and the server.

            If you set the Context Factory to org.jboss.naming.HttpContextNamingFactory you set the provider URL to the JNDIFactory servlet. You also setup an container configuration which uses the JMXInvokerServlet to invoke methods on the server.

            My problem was the size of the objects transfered because the clients may also connect using a 56K modem. These objects have just been serialized without any compression. After using GZip the size reduced to an acceptable value.