org.objectweb.perseus.distribution.api
Interface DistResSerializer
- BasicSerializer
public interface DistResSerializer
This interface is used to specify the serializer of resource identifier
to be used when sending messages. The rationale of specifying a serializer
instead of having resource indentifier implementing Serializable is that
the serialization may be specific to the application context. For example,
if multiple applications share the service but identifies their resources
using specific classes known only in their respective class paths,
it will be necessary to retrieve the right class loader so as to be able
to load the right class on the receiver of a message. In this case a specific
serializer being aware of application should be specified and should return
someting like a byte array. Note that a basic serializer for simple cases
is provided and used by default.
The second reason is that the serialized form of the id may suffice
the coordinator side of the protocol (this is the case if we only need to
compare them, having the real class is not required). In this case we can
spare the deserialization when receiving messages and the serialization when
sending some by turing off the serialization process (on the coordinator
side). This could not be possible if we had chosen to have identifier
implement the Serializable interface.
Note that the penalty of such approach is that we must obtain a serialized
form of the id before sending them on the stream (w/ the Serializable
approach, the id would be sent on the stream while being serialized).
However it is unlikely that the serialized form of id is big since it
is not recommended.
BasicSerializer
, DistResServiceManager
Object | deserialize(Serializable serializedResId) - Deserialize a resource identifier.
|
Serializable | serialize(Object resId) - Serialize a resource identifier.
|
deserialize
public Object deserialize(Serializable serializedResId)
Deserialize a resource identifier.
serializedResId
- the serialized form of the identifier
- the natural form (of the right class) of the identifier
serialize
public Serializable serialize(Object resId)
Serialize a resource identifier.
Note that it is possible to confine the serialization in the
serializer by returning an byte array.
resId
- the unserialized form of the identifier
- the serialized form of the identifier
Copyright © 2000-2002 France Telecom S.A., INRIA, IMAG-LSR All Rights Reserved.