Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-5982

Use custom converter adaption from ValueMap to Annotation class

    XMLWordPrintableJSON

Details

    Description

      this is about the context-aware configuration: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/contextaware-config

      currently we use the out-of-the-box functionality of the OSGi converter server to map a resource valuemap properties to an annotation class. this works very well.

      however some things need to be improved, and we need a custom conversion adapter rules for this:

      • the dynamic proxy created by the converter (see ConvertingImpl#createProxy) only knows the Map interface, not ValueMap, thus it accesses directly the "raw" type from the value map. all the conversion magic that exists in the JCR value map implementation is not applied. the converter has it's own magic, but it will not always produce the same results as the JCR mapping magic. thus we need an adaption rule from ValueMap to <any annotation class> which used the valuemap get methods with the type required for the property as second argument.
      • problem: the converter service currently supports explicit mappings from type A to B, not mapping from type A to any type. most of the rule method variants are currently not implemented in the felix converter impl. i will post a question for this issues on the felix mailing list.

      once we have this custom conversion rule in place we can do further improvements:

      • create our own sling-variant of "ConversionException" and make sure it is thrown in all relevant cases (on conversion, on property accesS) instead of the built-in one from the conversion service
      • support nested configurations and nested configuration lists - when access to a subresource is detected (does currently not work, valuemap returns null) adapt the subresource to valuemap and convert it.

      Attachments

        Activity

          People

            sseifert Stefan Seifert
            sseifert Stefan Seifert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: