jaxb
  1. jaxb
  2. JAXB-698

There should be a possibility to specify "post-construct" code.

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0 FCS
    • Fix Version/s: not determined
    • Component/s: spec
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      698

      Description

      There should be a possibility to specify code, which JAXB would call after an
      object was unmarshalled (after all fields were set, so that method could use
      them). It is not possible to achieve this using the ctor.

      This functionality could be made available either by a new annotation
      (@XmlPostConstruct or something).

      Please see this resource for a possible workaround:
      http://stackoverflow.com/questions/1545478/is-there-something-like-postconstruct-for-jaxb-annnotated-classes/1545867#1545867

        Activity

        Hide
        Pavel Bucek added a comment -

        You don't need to write Listener class when you use (JAXB) life cycle methods,
        they are discovered automatically..

        Show
        Pavel Bucek added a comment - You don't need to write Listener class when you use (JAXB) life cycle methods, they are discovered automatically..
        Hide
        converginglight added a comment -

        I couldn't find usable information about JAXB's "life cycle methods". Could you
        tell more specific, what you mean?

        Show
        converginglight added a comment - I couldn't find usable information about JAXB's "life cycle methods". Could you tell more specific, what you mean?
        Hide
        Pavel Bucek added a comment -

        It's defined in jsr222:

        http://jcp.org/en/jsr/detail?id=222

        Show
        Pavel Bucek added a comment - It's defined in jsr222: http://jcp.org/en/jsr/detail?id=222
        Hide
        converginglight added a comment -

        I read the PDF of that JSR.
        Could not find a word about life cycle methods.
        (Perhaps some synonym is used?)

        Please, explain what you mean.

        Show
        converginglight added a comment - I read the PDF of that JSR. Could not find a word about life cycle methods. (Perhaps some synonym is used?) Please, explain what you mean.
        Hide
        flb_at_ll added a comment -

        If I understand things correctly, afterUnmarshal will be called after the
        document has been fully unmarshalled.

        What I think is needed is the ability to operate on objects as they are created.
        More important to me would be able to transform an object into a child wrapper
        class before the bind/resolve call. Unfortunately, bind is called before the
        object members have been fully populated, so all re-wrapping must occur after
        unmarshal which means having to walk the entire document tree and update all
        references to a re-wrapped object.

        Show
        flb_at_ll added a comment - If I understand things correctly, afterUnmarshal will be called after the document has been fully unmarshalled. What I think is needed is the ability to operate on objects as they are created. More important to me would be able to transform an object into a child wrapper class before the bind/resolve call. Unfortunately, bind is called before the object members have been fully populated, so all re-wrapping must occur after unmarshal which means having to walk the entire document tree and update all references to a re-wrapped object.

          People

          • Assignee:
            Martin Grebac
            Reporter:
            converginglight
          • Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: