Clement Escoffier wrote:



A cool feature could be a general-purpose parser to parser the value string and instanciate from it Object or array of Object
For instance (108.16.10.2, 108.16.10.10 and many others),

<property
    field="m_myProducerFlavor"
    name="wireadmin.producer.flavors"
    value="{org.osgi.util.measurement.Measurement, java.lang.Double}"
    parser="fr.imag.osgi.ipojo.wireadmin.ClassArrayParser"
/>

public class ClassArrayParser { public ClassArrayParser(String value) { ... } public Class[] newInstance() { ... }
}


This is possible but it is not simple.
At packaging time, attribute does not have any semantic, so iPOJO plugin cannot know that your parser attribute contains a class name and that it needs to add the import to the bundle manifest.



You may add a directive element in the iPOJO component manifest.
to add  import in the bundle manifest
such as
<import package="fr.imag.osgi.ipojo.wireadmin"/>
or
<dynamic-import package="fr.imag.osgi.ipojo.*"/>


More generally, you may add a general-purpose mecanism to custom directives elements in the iPOJO component manifest.
Each directive could reference a iPOJODirectiveProcessor

For instance
<import package="fr.imag.osgi.ipojo.wireadmin"/>
<dynamic-import package="fr.imag.osgi.ipojo.*"/>
become
<ipojo:directive name="org.apache.felix.ipojo.directive.ImportDirectiveProcessor" value="fr.imag.osgi.ipojo.wireadmin"/> <ipojo:directive name="org.apache.felix.ipojo.directive.DynamicImportDirectiveProcessor" value="fr.imag.osgi.ipojo.*"/>

This is similar to the PI (Processing Instruction) defined in XML 1.0

Best regards

Didier

So, you need to ensure that your class is inside the bundle. If you do this assumption, the handler managing properties could at runtime interpret the attribute (the handler know the semantic of the attribute), load the class, and create your array.

Clément



--
---------------------------------------------------------
Didier DONSEZ
Laboratoire LSR, Institut Imag, Universite Joseph Fourier
Bat. C, 220 rue de la Chimie, Domaine Universitaire
BP 53, 38041 Grenoble Cedex 9, France
GPS : lat 45°11'38.3"N, lon 05°46'14.7"E, alt 223m
Tel : +33 4 76 63 55 49           Fax : +33 4 76 63 55 50
mailto:[EMAIL PROTECTED]
URL: http://www-adele.imag.fr/~donsez
---------------------------------------------------------



Reply via email to