/** @param serviceID */ public AUDataModelProviderWithEvents() { super(); // Initialise JAXB context for these classes. Make provider behave better against race // conditions. JAXBUtils.initCtx(getMultiObjectClassInfo().getObjectType()); JAXBUtils.initCtx(getSingleObjectClassInfo().getObjectType()); }
/* (non-Javadoc) * @see sif3.infra.common.conversion.UnmarshalFactory#unmarshalFromJSON(java.lang.String, java.lang.Class) */ @Override public Object unmarshalFromJSON(String payload, Class<?> clazz) throws UnmarshalException, UnsupportedMediaTypeException { Object result = null; try { result = JAXBUtils.unmarshalFromJSONIntoObject(payload, clazz); } catch (Exception e) { logger.error("An error occurred unmarshalling object from XML", e); throw new UnmarshalException("An error occurred unmarshalling object from XML", e); } return result; }
@Override public String marshalToJSON(Object obj) throws MarshalException, UnsupportedMediaTypeException { String result = null; try { Method method = findCreateMethod(obj); if (method != null) { JAXBElement<?> element = (JAXBElement<?>) method.invoke(objFactory, obj); if (element != null) { result = JAXBUtils.marshalToJSON(element); } } } catch (Exception e) { logger.error("An error occurred marshalling object to JSON", e); throw new MarshalException("An error occurred marshalling object to JSON", e); } return result; }