Support for distributed environments

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Henrik Nydell

Support for distributed environments

Post by Henrik Nydell » Thu Oct 10, 2002 1:06 pm

Is there a good reason for why the various DataSet's (and their sub components as TimeSeries e t c) doesn't implement java.io.Serializable?

Dave Gilbert

Re: Support for distributed environments

Post by Dave Gilbert » Thu Oct 10, 2002 5:08 pm

The only reason is that serialisation is something I haven't looked closely at, so I don't know what issues are involved. I'll do some reading on it when I get a chance, or take advice from any experts out there...

Regards,

DG.

Brad Baker

Re: Support for distributed environments

Post by Brad Baker » Tue Feb 25, 2003 2:31 am

Can I also add a comment.

Many Servlet 2.2 engines use serialisation to support "distributed" sessions across multiple machines, or load balancing efforts.

Therefore if you use the JFreeChart classes in a servlet and stick it in the servlet session you can get exceptions very easily.

From much of what I have seen in the JFreeChart classes, adding

implements java.io.Serializable to each class would be simple and would not require custom readObject/writeObject methods. Especially the model classes.

David Gilbert

Re: Support for distributed environments

Post by David Gilbert » Wed Feb 26, 2003 12:57 am

Thanks for the info Brad...I still haven't had a chance to read up about Serialization, unfortunately!

Regards,

Dave Gilbert

Brad Baker

Re: Support for distributed environments

Post by Brad Baker » Fri Feb 28, 2003 1:01 am

I have done a prelimenary examination of adding Serilisation support to JFreeChart.

In short it is a pretty basic exercise. Most classes simply need

..... implements java.io.Serializable

add to them to work. Java Serialzation can easily read and write simple dasta types and objects with simple data types. Therefore most of the plot "models" can easily be made Seriazable.

And because it is "inherited" only the base classes need be marked.

UI based classes that have java.awt.geom classes in them need some more work. The java.awt.geom classes are not serializable.

Hence the member variables need to be marked as "transient" and "recreated" during Serialization readObject()/writeObject() methods.

In fact they might not even need this they can be created dynamically when used from other data.


For more info see:

http://java.sun.com/docs/books/tutorial ... ation.html


The reason I need such support is that my Servlet project http://echopoint.sourceforge.net has support for JFreeChart as well as providing a Servlet based component wrapper for the Meter classes.

And as I said in the previous post, the Servlet 2.2 spec says that objects in the servlet session can be "Serialised" at any time.

Therefore to save the state of my JFreeChart component, I need to be able to Serilaise it, or at least its data models and then recreate it on readObject().

Cheers
Brad

Locked