Class JaxbUnmarshallingAspect

java.lang.Object
org.cruk.clarity.api.jaxb.JaxbUnmarshallingAspect

public class JaxbUnmarshallingAspect extends Object
Aspect that wraps the unmarshalling of responses from the Clarity API. Changes the returned value from a JAXBElement (seemingly now what is returned from Spring's Jaxb2Marshaller as of Spring 4) to the actual object and, if the reply is found to be an exception from the API, converts the reply into a Java exception and throws it.
See Also:
  • Constructor Details

    • JaxbUnmarshallingAspect

      public JaxbUnmarshallingAspect()
  • Method Details

    • objectUnmarshalled

      public Object objectUnmarshalled(ProceedingJoinPoint pjp) throws Throwable
      Join point that replaces the JAXBElement object with the real object it contains, then tests whether the reply object is an error and, if so, throws a Java exception.
      Parameters:
      pjp - The AspectJ join point object. The return value from its proceed call gives the result of unmarshalling.
      Returns:
      The real object extracted from unmarshalled (if unmarshalled is a JAXBElement).
      Throws:
      ClarityException - if unmarshalled is an error message. It is created with the fields from the XML error.
      Throwable - if there is another throwable from continuing the join point control chain.
      See Also: