javax.xml.bind.UnmarshallerHandler Java Examples
The following examples show how to use
javax.xml.bind.UnmarshallerHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiDeleteRequestUnmarshaller.java From hadoop-ozone with Apache License 2.0 | 6 votes |
@Override public MultiDeleteRequest readFrom(Class<MultiDeleteRequest> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) { try { UnmarshallerHandler unmarshallerHandler = context.createUnmarshaller().getUnmarshallerHandler(); XmlNamespaceFilter filter = new XmlNamespaceFilter("http://s3.amazonaws.com/doc/2006-03-01/"); filter.setContentHandler(unmarshallerHandler); filter.setParent(xmlReader); filter.parse(new InputSource(entityStream)); return (MultiDeleteRequest) unmarshallerHandler.getResult(); } catch (Exception e) { throw new WebApplicationException("Can't parse request body to XML.", e); } }
Example #2
Source File: CompleteMultipartUploadRequestUnmarshaller.java From hadoop-ozone with Apache License 2.0 | 6 votes |
@Override public CompleteMultipartUploadRequest readFrom( Class<CompleteMultipartUploadRequest> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException { try { UnmarshallerHandler unmarshallerHandler = context.createUnmarshaller().getUnmarshallerHandler(); XmlNamespaceFilter filter = new XmlNamespaceFilter(S3_XML_NAMESPACE); filter.setContentHandler(unmarshallerHandler); filter.setParent(xmlReader); filter.parse(new InputSource(inputStream)); return (CompleteMultipartUploadRequest) unmarshallerHandler.getResult(); } catch (Exception e) { throw new WebApplicationException("Can't parse request body to XML.", e); } }
Example #3
Source File: JAXBConfigImpl.java From rice with Educational Community License v2.0 | 6 votes |
protected org.kuali.rice.core.impl.config.property.Config unmarshal(Unmarshaller unmarshaller, InputStream in) throws SAXException, ParserConfigurationException, IOException, IllegalStateException, JAXBException { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true); XMLFilter filter = new ConfigNamespaceURIFilter(); filter.setParent(spf.newSAXParser().getXMLReader()); UnmarshallerHandler handler = unmarshaller.getUnmarshallerHandler(); filter.setContentHandler(handler); filter.parse(new InputSource(in)); return (org.kuali.rice.core.impl.config.property.Config) handler.getResult(); }
Example #4
Source File: JaxbPersistenceFactory.java From tomee with Apache License 2.0 | 6 votes |
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); }
Example #5
Source File: ParseJAXB.java From jlibs with Apache License 2.0 | 5 votes |
@Override protected void parsingCompleted(Exchange exchange, Message msg, AsyncXMLReader xmlReader){ UnmarshallerHandler handler = (UnmarshallerHandler)xmlReader.getContentHandler(); try{ String contentType = msg.getPayload().getMediaType().withCharset(IOUtil.UTF_8.name()).toString(); msg.setPayload(new JAXBPayload(contentType, handler.getResult(), jaxbContext)); }catch(Throwable thr){ exchange.resume(thr); return; } super.parsingCompleted(exchange, msg, xmlReader); }
Example #6
Source File: UnmarshallerImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public UnmarshallerHandler getUnmarshallerHandler() { return getUnmarshallerHandler(true,null); }
Example #7
Source File: UnmarshallerImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public UnmarshallerHandler getUnmarshallerHandler() { return getUnmarshallerHandler(true,null); }
Example #8
Source File: UnmarshallerImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public UnmarshallerHandler getUnmarshallerHandler() { return getUnmarshallerHandler(true,null); }
Example #9
Source File: UnmarshallerImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public UnmarshallerHandler getUnmarshallerHandler() { return getUnmarshallerHandler(true,null); }
Example #10
Source File: UnmarshallerImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public UnmarshallerHandler getUnmarshallerHandler() { return getUnmarshallerHandler(true,null); }
Example #11
Source File: UnmarshallerImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
public UnmarshallerHandler getUnmarshallerHandler() { return getUnmarshallerHandler(true,null); }
Example #12
Source File: UnmarshallerImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public UnmarshallerHandler getUnmarshallerHandler() { return getUnmarshallerHandler(true,null); }
Example #13
Source File: UnmarshallerImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public UnmarshallerHandler getUnmarshallerHandler() { return getUnmarshallerHandler(true,null); }
Example #14
Source File: PooledUnmarshaller.java From sis with Apache License 2.0 | 4 votes |
/** * Delegates to the wrapped unmarshaller. */ @Override public UnmarshallerHandler getUnmarshallerHandler() { return unmarshaller.getUnmarshallerHandler(); }