Note that there are some explanatory texts on larger screens.

plurals
  1. POJava custom serialization with compression for low network bandwidth use
    text
    copied!<p>I am currently developing a client/server application. The application server is Glassfish v3, the communication is by remote EJBs. The main problem is the heavy network bandwidth use when serializing objects graphs. For example in the next method:</p> <pre><code>@Stateless public class MyEJB extends MyRemoteInterface { @Override public PurchaseOrder savePurchaseOrder( PurchaseOrder po ) { ... } } </code></pre> <p>this method, when invoked remotely, will receive a PurchesOrder instance which is a object graph that when is transferred over the network it will take a lot of KB, the same when it returns.</p> <p>I have manage this, for now, changing the prototype of the method like this:</p> <pre><code>... @Override public byte[] savePurchaseOrder( byte[] po ) { ... } ... </code></pre> <p>I manually de/compress and de/serialize the PurchaseOrder instance before and after transferring it over the network. But I loose type safe methods and it gets ugly.</p> <p>Is there a way to use java custom serialization for compressing the output stream in the default serialization process? for example:</p> <pre><code> @Entity public class PurchaseOrder implements Serializable { private void writeObject(ObjectOutputStream oos) throws IOException { // default serialization oos.defaultWriteObject(); // COMPRESS STREAM HERE (zip or gzip) } private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { // DECOMPRES STREAM HERE // default deserialization ois.defaultReadObject(); } } </code></pre> <p>I need the code of "DE/COMPRESS STREAM HERE" part, or another good idea.</p> <p>Thank you in advance for your advice.</p> <p>Xavier.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload