Figure shows the different phases of the adaptor generator and the representation of the functionality interface respective the adaptor class. The functionality interface must be available as class file. The generator loads the functionality interface and obtains a representation of the functionality interface as a Java Class object.
The structure of the functionality interface can then be inspected by Java Reflection [#!Fla1997!#]. This allows to pick up information that has already been processed by the normal Java compiler and avoids complicated parsing. In order to create the adaptor class following information is read out of the Class object:
The interface name is mapped to <interface name>_Adaptor. The method definitions are mapped to method implementations. The method implementations invoke the adaptation mechanism in order to load and instantiate the implementation class, if necessary and delegate the method invocation to the loaded instance of the implementation class.
In addition to the mapping the generic part is added, which contains the member variable for the instance of the adaptation mechanism and the method createAdaptation() in order to instantiate the adaptation mechanism.