Uploaded image for project: 'Pluto'
  1. Pluto
  2. PLUTO-509

JAXB portlet descriptor model handling broken with respect to the different namespace handling for portlet API 1.0 and 2.0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.0-refactoring, 2.0.0
    • 2.0-refactoring, 2.0.0-M1, 2.0.0
    • descriptor
    • None

    Description

      The current Portlet 1.0 and Portlet 2.0 JAXB descriptor api is an ackward merge of both namespaces in one object model.
      While this did seem to "work" more or less correct, when testing it more thoroughly it complete blew to pieces ...

      JAXB really cannot properly handle two namespaces blended on top of a single object model, it uses java packaging to map namespaces.
      And while you can have multiple fields mapped to multiple namespaces in one bean, one cannot do the same with one class: you really need to duplicate the classes to support multiple namespaces.
      This really becomes clear as soon as you try to actually write out an JAXB managed object tree.
      Using the current Pluto descriptor mapping this simply isn't possible to do without a corrupting the output or just exceptions thrown all over the place.

      So, as we do need to have this managed properly, I have started out rewriting the whole JAXB mapping mostly from scratch again, now properly using two implementation packages for the two namespaces (portlet10 and portlet20).

      As we already had extracted the descriptor api interfaces, the two new implementation packages both implement the most common denominator (e.g. portlet20) interface, where the portlet10 implementations throw an UnsupportedOperationException when trying to use portlet20 specific features (write and read methods).

      As the JAXB jxc compiler generates classes based on the xsd type definitions, all *DD classes ended up to be called *Type now. I've kept it that way as the *DD classes are no longer directly used anyway (or at least shouldn't).

      Finally, to be able to modify an JAXB loaded portlet10 or portlet20 descriptor model, while only dealing with the interfaces, a solution is needed for creating new instances of objects managed through lists, e.g. portletApp.getPortlets().add(Portlet).
      For this purpose, I've created a new ElementFactoryList<E> extending ArrayList<E> which provides a factory method for creating new elements for itself: E ElementFactoryList<E>.newElement().
      So, like for a org.apache.pluto.om.portlet.Portlet interface, you have to use: portletApp.getPortlets().add(portletApp.getPortlets().newElement()).

      Attachments

        Activity

          People

            ate Ate Douma
            ate Ate Douma
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: