@ApplicationScoped public class DynamicJaxbContext extends JAXBContext
JAXBContext instances are cached by the REST framework (and then reused
with *all* request). This means that we can not provide multiple JAXBContext
instances, but must make sure that an instance of this class is cached -- which
will then provide different (un)marshallers depending on the deploymentId used
in the request.
This means that 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 |
addOnDeploy(org.jbpm.services.api.DeploymentEvent event)
Called when the workbench/console/business-central deploys a new deployment.
|
static void |
clearDeploymentJaxbContext() |
Marshaller |
createMarshaller() |
Unmarshaller |
createUnmarshaller() |
Validator |
createValidator() |
Collection<Class<?>> |
getDeploymentClasses(String deploymentId)
Used by classes involved with de/serialzation in order to retrieve (user-defined) clases
to be used in de/serialization.
|
JAXBContext |
getDeploymentJaxbContext(String deploymentId) |
void |
removeOnUnDeploy(org.jbpm.services.api.DeploymentEvent event)
Called when the workbench/console/business-central *un*deploys (removes) a deployment.
|
static void |
setDeploymentJaxbContext(String deploymentId) |
createBinder, createBinder, createJAXBIntrospector, generateSchema, newInstance, newInstance, newInstance, newInstance, newInstancepublic static void setDeploymentJaxbContext(String deploymentId)
public static void clearDeploymentJaxbContext()
public void addOnDeploy(@Observes
org.jbpm.services.api.DeploymentEvent event)
event - public void removeOnUnDeploy(@Observes
org.jbpm.services.api.DeploymentEvent 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 Unmarshaller createUnmarshaller() throws JAXBException
createUnmarshaller in class JAXBContextJAXBExceptionpublic Marshaller createMarshaller() throws JAXBException
createMarshaller in class JAXBContextJAXBExceptionpublic Validator createValidator() throws JAXBException
createValidator in class JAXBContextJAXBExceptionpublic Collection<Class<?>> getDeploymentClasses(String deploymentId)
deploymentId - The deployment unit idpublic JAXBContext getDeploymentJaxbContext(String deploymentId)
Copyright © 2001–2016 JBoss by Red Hat. All rights reserved.