List of usage examples for javax.xml.bind JAXBContext createValidator
@Deprecated public abstract Validator createValidator() throws JAXBException;
From source file:de.thorstenberger.taskmodel.complex.complextaskdef.impl.ComplexTaskDefDAOImpl.java
public void save(ComplexTaskDefRoot ctdr, OutputStream os) throws TaskApiException { BufferedOutputStream bos = new BufferedOutputStream(os); Marshaller marshaller = null; try {//from ww w . j a v a 2s.com JAXBContext jc = createJAXBContext(); marshaller = JAXBUtils.getJAXBMarshaller(jc); Validator validator = jc.createValidator(); ComplexTaskDef ctd = ((ComplexTaskDefRootImpl) ctdr).getJAXBContent(); validator.validate(ctd); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true)); marshaller.marshal(ctd, bos); } catch (JAXBException e) { throw new TaskModelPersistenceException(e); } finally { try { bos.close(); } catch (IOException e) { throw new TaskModelPersistenceException(e); } if (marshaller != null) JAXBUtils.releaseJAXBMarshaller(jc, marshaller); } }