use of javax.xml.bind.JAXBException in project spring-framework by spring-projects.
the class Jaxb2Marshaller method createUnmarshaller.
/**
* Return a newly created JAXB unmarshaller.
* Note: JAXB unmarshallers are not necessarily thread-safe.
*/
protected Unmarshaller createUnmarshaller() {
try {
Unmarshaller unmarshaller = getJaxbContext().createUnmarshaller();
initJaxbUnmarshaller(unmarshaller);
return unmarshaller;
} catch (JAXBException ex) {
throw convertJaxbException(ex);
}
}
use of javax.xml.bind.JAXBException in project spring-framework by spring-projects.
the class Jaxb2Marshaller method createMarshaller.
/**
* Return a newly created JAXB marshaller. JAXB marshallers are not necessarily thread safe.
*/
protected Marshaller createMarshaller() {
try {
Marshaller marshaller = getJaxbContext().createMarshaller();
initJaxbMarshaller(marshaller);
return marshaller;
} catch (JAXBException ex) {
throw convertJaxbException(ex);
}
}
use of javax.xml.bind.JAXBException in project play-cookbook by spinscale.
the class ApiPlugin method onApplicationStart.
@Override
public void onApplicationStart() {
try {
List<ApplicationClass> applicationClasses = Play.classes.getAnnotatedClasses(XmlRootElement.class);
List<Class> classes = new ArrayList<Class>();
for (ApplicationClass applicationClass : applicationClasses) {
classes.add(applicationClass.javaClass);
}
jc = JAXBContext.newInstance(classes.toArray(new Class[] {}));
} catch (JAXBException e) {
Logger.error(e, "Problem initializing jaxb context: %s", e.getMessage());
}
gson = new GsonBuilder().create();
Logger.info("ApiPlugin loaded");
}
use of javax.xml.bind.JAXBException in project play-cookbook by spinscale.
the class ApiPlugin method onApplicationStart.
public void onApplicationStart() {
Logger.info("ApiPlugin loaded");
try {
List<ApplicationClass> applicationClasses = Play.classes.getAnnotatedClasses(XmlRootElement.class);
List<Class> classes = new ArrayList<Class>();
for (ApplicationClass applicationClass : applicationClasses) {
classes.add(applicationClass.javaClass);
}
jc = JAXBContext.newInstance(classes.toArray(new Class[] {}));
} catch (JAXBException e) {
Logger.error(e, "Problem initializing jaxb context: %s", e.getMessage());
}
gson = new GsonBuilder().create();
}
use of javax.xml.bind.JAXBException in project play-cookbook by spinscale.
the class ApiPlugin method getXml.
private Object getXml(Class clazz) {
try {
if (clazz.getAnnotation(XmlRootElement.class) != null) {
Unmarshaller um = jc.createUnmarshaller();
StringReader sr = new StringReader(Request.current().params.get("body"));
return um.unmarshal(sr);
}
} catch (JAXBException e) {
Logger.error("Problem rendering XML: %s", e.getMessage());
}
return null;
}
Aggregations