Factility for obtaining default JAXBContext and/or Marshaller/Unmarshaller
- Dominant language
- Java
- Stars
- 400
- Forks
- 143
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes there is a need to obtain the JAXBContext or the Marshaller/Unmarshaller that a JAX-RS runtime picked to marshal or unmarshal entities of requests and responses.
For example, if a resource shall apply XSLT transformation of entities it might like to use JAXBSource and JAXBResult on the entitiy. To create that, it needs either the Marshaller/Unmarshaller or at least the JAXBContext that was used. As possibly that context contains lots of root classes needed but not known to the resource programmer, the programmer might not be able to create this context on his own due to missing information about the JAXB domain.
Unfortunately JAX-RS currently does not provide a facility to obtain either the JAXBContext or the Marshaller/Unmarshaller picked by the JAX-RS runtime. Using getContextProvider of the Providers interface is not solving this problem, as it just returns **some** context resolver but not necessarily the one actually used by default: When the JAX-RS application sets an additional context, it will get returned, even if it was not used by the JAX-RS runtime actually (if this behaviour is not intended by JAX-RS, then there is a bug in Jersey, since this behaviour was noticed in Jersey 1.5).
A possible solution would be to add additional methods to get the actual default context: getRequestContext / getResponeContext and optionally additionally getRequestUnmarshaller / getResponseMarshaller.
#### Affected Versions
[1.1]
Contributor guide
Assessment
This issue has not been assessed yet.