use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.
the class NotificationsTest method unmarshall.
public NotificationPermission unmarshall(Reader reader) {
try {
JAXBContext context = JAXBContext.newInstance(NotificationPermission.class.getPackage().getName());
Unmarshaller unmarshaller = context.createUnmarshaller();
return (NotificationPermission) unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new RuntimeException("Unable to unmarshall orcid message" + e);
}
}
use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.
the class NotificationsTest method unmarshall.
public NotificationPermission unmarshall(Reader reader) {
try {
JAXBContext context = JAXBContext.newInstance(NotificationPermission.class.getPackage().getName());
Unmarshaller unmarshaller = context.createUnmarshaller();
return (NotificationPermission) unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new RuntimeException("Unable to unmarshall orcid message" + e);
}
}
use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.
the class ValidateV2RC4Identifiers method unmarshall.
private Object unmarshall(Reader reader, Class<?> type) {
try {
JAXBContext context = JAXBContext.newInstance(type);
Unmarshaller unmarshaller = context.createUnmarshaller();
return unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new RuntimeException("Unable to unmarshall orcid message" + e);
}
}
use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.
the class BaseControllerTest method getOrcidProfile.
protected static OrcidProfile getOrcidProfile() {
try {
JAXBContext context = JAXBContext.newInstance(OrcidMessage.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
OrcidMessage orcidMessage = (OrcidMessage) unmarshaller.unmarshal(BaseControllerTest.class.getResourceAsStream("/orcid-internal-full-message-latest.xml"));
return orcidMessage.getOrcidProfile();
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
use of javax.xml.bind.Unmarshaller in project opennms by OpenNMS.
the class JaxbUtilsUnmarshalProcessor method process.
/**
* Make sure that this method is fast because it is used to deserialize
* JMS messages.
*/
@Override
public void process(final Exchange exchange) throws Exception {
Unmarshaller unmarshaller = m_unmarshaller.get();
if (unmarshaller == null) {
unmarshaller = JaxbUtils.getUnmarshallerFor(m_class, null, false);
m_unmarshaller.set(unmarshaller);
}
// Super slow
//final String object = exchange.getIn().getBody(String.class);
//exchange.getIn().setBody(JaxbUtils.unmarshal(m_class, object), m_class);
// Faster
//final InputStream object = exchange.getIn().getBody(InputStream.class);
//exchange.getIn().setBody(unmarshaller.unmarshal(new StreamSource(object)));
// Somehow, using String is marginally faster than using InputStream ¯\_(ツ)_/¯
final String object = exchange.getIn().getBody(String.class);
exchange.getIn().setBody(m_class.cast(unmarshaller.unmarshal(new StringReader(object))));
}
Aggregations