@Override public void run() { try { JaxbJavaee.getContext(type); } catch (JAXBException e) { } } }
public static <T> void marshal(final Class<T> type, final Object object, final OutputStream out) throws JAXBException { final JAXBContext ctx2 = JaxbJavaee.getContext(type); final Marshaller marshaller = ctx2.createMarshaller(); marshaller.setProperty("jaxb.formatted.output", true); marshaller.marshal(object, out); }
public static <T> void marshal(final Class<T> type, final Object object, final OutputStream out) throws JAXBException { final JAXBContext ctx2 = JaxbJavaee.getContext(type); final Marshaller marshaller = ctx2.createMarshaller(); marshaller.setProperty("jaxb.formatted.output", true); marshaller.marshal(object, out); }
public static <T>void marshal(Class<T> type, Object object, OutputStream out) throws JAXBException { JAXBContext ctx2 = JaxbJavaee.getContext(type); Marshaller marshaller = ctx2.createMarshaller(); marshaller.setProperty("jaxb.formatted.output", true); marshaller.marshal(object, out); }
public static <T> T getPersistence(final Class<T> clazz, final InputStream persistenceDescriptor) throws Exception { final JAXBContext jc = clazz.getClassLoader() == JaxbPersistenceFactory.class.getClassLoader() ? JaxbJavaee.getContext(clazz) : JAXBContextFactory.newInstance(clazz); final Unmarshaller u = jc.createUnmarshaller(); final UnmarshallerHandler uh = u.getUnmarshallerHandler(); // create a new XML parser final SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); final SAXParser parser = factory.newSAXParser(); final XMLReader xmlReader = parser.getXMLReader(); // Create a filter to intercept events final PersistenceFilter xmlFilter = new PersistenceFilter(xmlReader); // Be sure the filter has the JAXB content handler set (or it wont work) xmlFilter.setContentHandler(uh); final SAXSource source = new SAXSource(xmlFilter, new InputSource(persistenceDescriptor)); return (T) u.unmarshal(source); }
public static <T>Object unmarshal(Class<T> type, InputStream in) throws ParserConfigurationException, SAXException, JAXBException { InputSource inputSource = new InputSource(in); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(false); SAXParser parser = factory.newSAXParser(); JAXBContext ctx = JaxbJavaee.getContext(type); Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler(){ public boolean handleEvent(ValidationEvent validationEvent) { System.out.println(validationEvent); return false; } }); JaxbJavaee.NamespaceFilter xmlFilter = new JaxbJavaee.NamespaceFilter(parser.getXMLReader()); xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler()); SAXSource source = new SAXSource(xmlFilter, inputSource); currentPublicId.set(new TreeSet<String>()); try { return unmarshaller.unmarshal(source); } finally { currentPublicId.set(null); } }
final SAXParser parser = factory.newSAXParser(); final JAXBContext ctx = JaxbJavaee.getContext(type); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() {
final SAXParser parser = factory.newSAXParser(); final JAXBContext ctx = JaxbJavaee.getContext(type); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() {
final SAXParser parser = factory.newSAXParser(); final JAXBContext ctx = JaxbJavaee.getContext(type); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() {
final JAXBContext ctx = JaxbJavaee.getContext(type); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() {
final SAXParser parser = factory.newSAXParser(); final JAXBContext ctx = JaxbJavaee.getContext(type); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() {
final JAXBContext ctx = JaxbJavaee.getContext(type); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() {
final SAXParser parser = factory.newSAXParser(); final JAXBContext ctx = JaxbJavaee.getContext(type); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() {
final SAXParser parser = factory.newSAXParser(); final JAXBContext ctx = JaxbJavaee.getContext(type); final Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller.setEventHandler(new ValidationEventHandler() {