|
Page Edited :
FELIX :
How to use iPOJO Manipulation Metadata
How to use iPOJO Manipulation Metadata has been edited by Clement Escoffier (May 20, 2007). Content:During the manipulation process, iPOJO gathers information about the manipulated classes. These metadata are stored inside the bundle manifest and are used to avoid reflection on the manipulated class. By using these metadata, your handler can check that the implementation class contains required fields, methods, interface ... Contained informationManipulation metadata contains:
Field Metadata contains field name and type. Method Metadata contains method name, the sorted list of argument types and return type. Building Manipulation MetadataManipulation can be obtained from the component metadata. Component Metadata are obtained in argument of the 'configure' method of your handler. public void configure(InstanceManager im, Element metadata, Dictionary configuration) { ... ManipulationMetadata manip = new ManipulationMetadata(metadata); ... }
From a Field Metadata object, you can obtain the field name, type, and 'reflective' type. From a Method Metadata object, you can obtain the method name, the argument type array, and the returned type ('void' for void method). Creating Callback from Manipulation MetadataYou often need to invoke method on the POJO objects. iPOJO provides an helper class, named Callback, allow you to manage this invocation easily. You can obtain a Callback object from the Method Metadata. By this way, you are sure that the method exists in the implementation. To create the callback, use the following code: ManipulationMetadata manip = new ManipulationMetadata(metadata); MethodMetadata method = manip.getMethod("your_method_name"); Callback cb = new Callback(method, im); Then you can directly invoke your method: ...
Object[] args = ...; // Build your argument array
cb.call(args);
...
Types & Reflective TypesWhen querying field (or a method argument) type, the API will return following code identifier:
Array types are different from Java internal/reflective array types. To get the internal/reflective array type for field type you can use the getReflectiveType method. |
Unsubscribe or edit your notifications preferences
