@SuppressWarnings({ "unchecked", "rawtypes" })
public Object unmarshalEntity(Class type, MediaType acceptedMedia, InputStream in) throws JAXBException {
Unmarshaller unmarshaller = getJAXBContext().createUnmarshaller();
unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, Boolean.FALSE);
unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, acceptedMedia.toString());
unmarshaller.setAdapter(new LinkAdapter(getBaseURI().toString(), this));
unmarshaller.setEventHandler(new ValidationEventHandler() {
@Override
/*
* ReferenceAdaptor unmarshal throws exception if the object referred by a link
* doesn't exist, and this handler is required to interrupt the unmarshal