org.kie.remote.services.rest.jaxb
Class DynamicJaxbContext
java.lang.Object
javax.xml.bind.JAXBContext
org.kie.remote.services.rest.jaxb.DynamicJaxbContext
@ApplicationScoped
public class DynamicJaxbContext
- extends JAXBContext
READ THIS BEFORE WORKING ON THIS CLASS!
There are a couple of hidden issues that this class deals this:
-
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).
- Different deployments may have different version of the same class. This means that
We can not use 1
JAXBContext instance to deal with all deployments.
Tests have been specifically created to test this issue.
- Concurrency: this is an application scoped class that is being acted on by multiple
REST request threads. Fortunately, we just handle normal REST requests (no comet, for
example), so the requests themselves (with regards to the serializaiton logic) are all
handled in one thread.
Regardless, please preserve existing tests when modifying this class!
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DynamicJaxbContext
public DynamicJaxbContext()
setDeploymentJaxbContext
public static void setDeploymentJaxbContext(String deploymentId)
clearDeploymentJaxbContext
public static void clearDeploymentJaxbContext()
createUnmarshaller
public Unmarshaller createUnmarshaller()
throws JAXBException
- Specified by:
createUnmarshaller in class JAXBContext
- Throws:
JAXBException
createMarshaller
public Marshaller createMarshaller()
throws JAXBException
- Specified by:
createMarshaller in class JAXBContext
- Throws:
JAXBException
createValidator
public Validator createValidator()
throws JAXBException
- Specified by:
createValidator in class JAXBContext
- Throws:
JAXBException
setupDeploymentJaxbContext
public void setupDeploymentJaxbContext(@Observes
DeploymentProcessedEvent event)
- Adds a deployment lock object.
- Parameters:
event - The DeploymentEvent fired on deployment
cleanUpOnUndeploy
public void cleanUpOnUndeploy(@Observes
DeploymentProcessedEvent event)
- Removes the cached
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!
- Parameters:
event - The DeploymentEvent fired on an undeploy of a deployment
Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.