GeoTools : SerializableFeatures

Created by Trevor Stone, last modified on Mar 29, 2005

Serializable Features: How to Transfer Feature Objects

The following classes provide Serializable wrappers around Feature and type objects. There are some comments in Geotools data classes like "// TODO consider serialization". But just marking Feature Serializable would require a fair amount of work and might cause some problems. A Feature references a FeatureType, which references many AttributeTypes, which contain things like GeometryFactories. And do we really want to send a GeometryFactory object when we just want to transfer a Feature? The following classes crystalize what's important about each of these objects to make serialization nearly pain-free. (Note: GisException is a subclass of RuntimeException which allows the to ignore the particulars of failure. You can write one yourself or you can handle the various catch blocks however you like.)

Usage

Suppose you have two programs which communicate via serialization (RMI, for instance). To transfer data from one to the other, all you have to do (assuming sendSerializedObject() serializes and sends to a receiveSerializedObject() method which calls receiveFeatures and assuming processFeatureCollection does something interesting) is: