@ApplicationScoped public class DynamicJaxbContext extends JAXBContext
JAXBContext instances are cached by the REST framework. This means that we
can not provide multiple JAXBContext instances, but must make sure that an
instance of this class is cached. When the extended methods are called
(JAXBContext.createMarshaller() for example), we then look at the internal
cache to retrieve the correct JAXBContext).JAXBContext instance to deal with all deployments.
Tests have been specifically created to test this issue.JAXB_CONTEXT_FACTORY| Constructor and Description |
|---|
DynamicJaxbContext() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUpOnUndeploy(DeploymentProcessedEvent event)
Removes the cached
JAXBContext and deployment lock object
It's VERY important that the cached JAXBContext instance be removed! |
static void |
clearDeploymentJaxbContext() |
Marshaller |
createMarshaller() |
Unmarshaller |
createUnmarshaller() |
Validator |
createValidator() |
JAXBContext |
getDeploymentJaxbContext(String deploymentId) |
static void |
setDeploymentJaxbContext(String deploymentId) |
void |
setupDeploymentJaxbContext(DeploymentProcessedEvent event)
Adds a deployment lock object.
|
createBinder, createBinder, createJAXBIntrospector, generateSchema, newInstance, newInstance, newInstance, newInstance, newInstancepublic static void setDeploymentJaxbContext(String deploymentId)
public static void clearDeploymentJaxbContext()
public Unmarshaller createUnmarshaller() throws JAXBException
createUnmarshaller in class JAXBContextJAXBExceptionpublic Marshaller createMarshaller() throws JAXBException
createMarshaller in class JAXBContextJAXBExceptionpublic Validator createValidator() throws JAXBException
createValidator in class JAXBContextJAXBExceptionpublic void setupDeploymentJaxbContext(@Observes
DeploymentProcessedEvent event)
event - The DeploymentEvent fired on deploymentpublic void cleanUpOnUndeploy(@Observes
DeploymentProcessedEvent event)
JAXBContext and deployment lock object
It's VERY important that the cached JAXBContext instance be removed! The new deployment
may contain a different version of a class with the same name. Keeping the old class definition
will cause problems!event - The DeploymentEvent fired on an undeploy of a deploymentpublic JAXBContext getDeploymentJaxbContext(String deploymentId)
Copyright © 2001–2015 JBoss by Red Hat. All rights reserved.