Through the object m_adaptation an adaptor can load the right implementation class for the current environment. The member variable m_adaptation is marked as transient. Though the adaptor class is serialized for migration to another host, the m_adaptation object is dropped and recreated after de-serialization. This reduces the size of code that moves over the network.
The implementation of the interface IMemory enables the core to use the adaptor class IMemory_Adaptor like a non-adaptable conventional implementation of IMemory without any considerations about adaptation.
The member variable m_iimplementation holds a reference to an object of the implementation class, which is suitable for the current environment. It is also marked as transient, since the implementation class may become obsolete, when the mobile code leaves the current environment.
The generic part of the adaptor classes, printed in boldface
in figure ,
consists of the implementation of the interface Serializable,
the member variable m_adaptation
and the method createAdaptation().
The method createAdaptation()
recreates the dropped adaptation object after the migration
to a new environment.
The interface dependent part, printed in boldface
in figure ,
consists of the method implementations
defined in the functionality interface - in this case
the implementation of the method getPhysicalMemory() -
and the object m_implementation of implementing
the functionality interface.
The adaptor classes
provide the skeleton to delegate
the method invocations from the
core, e.g. getPhysicalMemory
(s. figure ),
to the implementation class and return the
result to the core.
Exceptions that are thrown during adaptation are caught by the adaptor class. Two kind of exceptions can be thrown because of adaptation: