Hessian Performance OutputStream

From Resin 4.0 Wiki

(Difference between revisions)
Jump to: navigation, search
Ferg (Talk | contribs)
(Created page with "{{Cookbook}} {{Hessian}} To speed up Hessian writing, you should use a HessianFactory and you may also set the 'unshared' property. Since HessianFactory caches the introspec...")
Newer edit →

Revision as of 00:00, 1 January 2012

Cookbook-48.pngEmail-48.png

To speed up Hessian writing, you should use a HessianFactory and you may also set the 'unshared' property.

Since HessianFactory caches the introspection of your objects, each new object can skip the overhead of the reflection. And, since Hessian2Output objects can be reused, you can save the garbage-collection time.

The 'unshared' property can speed Hessian when your object graphs do not share sub-objects and are not circular. For specifically designed message, this is generally true.

private HessianFactory _hFactory = new HessianFactory();
...
 
Hessian2Output hOut = hFactory.createHessian2Output();

for ( ... ) {
  OutputStream myOs = ...
  hOut.init(myOs);
  hOut.setUnshared(true);

  hOut.writeObject(myObj);
  hOut.close();
}

The setUnshared tells Hessian that none of the objects will be shared, which will save some HashMap lookups. Using the HessianFactory also saves time by saving the reflection information and also the Hessian2Output objects.

The Input processing performance can also be performed in the same say

Hessian2Input hIn = hFactory.createHessian2Input();

for (...) {
   InputStream myIs = ...
   hIn.init(myIs);
 
  Object myObj = hIn.readObject();
  hIn.close();
}
Personal tools
TOOLBOX
LANGUAGES