How to set up jaxb generation?

I have a series of xml posts, all with their own schemas and namespaces. Messages are currently sorted using JAXB (we still live in Java 1.4) and we have a lot of legacy code using this JAXB code, so any solution should be minimally intrusive.

My problem is that although each message has a set of common header tags, the namespace covers the entire message and therefore makes the header for each message unique. As a result, the “general” header sections are loaded in a version with a limited namespace using a generic class that is implemented using very ugly proxy classes and dynamic reflection code. This general class has been identified as the source of some performance issues.

Ideally, I want to implement a replacement using the following:

  • Use Maven2 to replace the current jaxb build process manually.
  • Create one-time JAXB classes for the "regular" headers that will be reused in every post.
  • Convert current dynamic / proxy classes to use the specific header classes above.
  • Create JAXB classes for the unqiue section of each message.

Unfortunately, I have no control over the message structure, otherwise I would look at creating a separate header namespace. I was thinking of starting an XSLT transform to “rename” the header namespace after sorting and before canceling the search, but I would prefer to avoid extra loading if possible, even if it means more complex assembly.

Is this what I want to make feasible or am I missing something fundamental? Are there any hints on how to implement? Plugin versions, etc.

1: javaType , , .

2: , , , .

+3
1

JAXB 2.x @XmlJavaTypeAdapter, (. this Kohsuke Kawaguchi).

, , XmlAdapter<XMLHeaderFromNamespaceX, CommonHeader> XmlJavaTypeAdapter.

.

+1

Source: https://habr.com/ru/post/1717115/


All Articles