Package javax.xml.bind

Examples of javax.xml.bind.UnmarshallerHandler


                final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
                SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
                Schema schema = schemaFactory.newSchema(
                        ClassLoaderUtils.getResource("schemas/security-config.xsd", Init.class));
                unmarshaller.setSchema(schema);
                final UnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler();

                SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
                saxParserFactory.setXIncludeAware(false);
                saxParserFactory.setNamespaceAware(true);
                SAXParser saxParser = saxParserFactory.newSAXParser();
                if (uri == null) {
                    URL resource = ClassLoaderUtils.getResource("security-config.xml", Init.class);
                    if (resource == null) {
                        //kind of chicken-egg problem here
                        I18n.init("en", "US");
                        throw new XMLSecurityConfigurationException("empty", "security-config.xml not found in classpath");
                    }
                    uri = resource.toURI();
                }
                saxParser.parse(uri.toURL().toExternalForm(), new XIncludeHandler(unmarshallerHandler));
                JAXBElement<ConfigurationType> configurationTypeJAXBElement = (JAXBElement<ConfigurationType>) unmarshallerHandler.getResult();

                ConfigurationProperties.init(configurationTypeJAXBElement.getValue().getProperties(), callingClass);
                SecurityHeaderHandlerMapper.init(configurationTypeJAXBElement.getValue().getSecurityHeaderHandlers(), callingClass);
                JCEAlgorithmMapper.init(configurationTypeJAXBElement.getValue().getJCEAlgorithmMappings());
                TransformerAlgorithmMapper.init(configurationTypeJAXBElement.getValue().getTransformAlgorithms(), callingClass);
View Full Code Here


                // The InputSource neither has a stream nor a system ID set; this means that
                // we are dealing with a custom SAXSource that is not backed by a SAX parser
                // but that generates a sequence of SAX events in some other way.
                // In this case, we need to use a ContentHandler to feed the SAX events into
                // the unmarshaller.
                UnmarshallerHandler handler = unmarshaller.getUnmarshallerHandler();
                reader.setContentHandler(handler);
                reader.parse(inputSource);
                result = handler.getResult();
            } else {
                // If a stream or system ID is set, we assume that the SAXSource is backed
                // by a SAX parser and we only pass the InputSource to the unmarshaller.
                // This effectively ignores the SAX parser and lets the unmarshaller take
                // care of the parsing (in a potentially more efficient way).
View Full Code Here

    }

    public static Object unmarshal(Unmarshaller unmarshaller, Reader reader) throws IOException {
        Object result = null;
        try {
            UnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler();
            AtomUnmarshallingListener.AtomUnmarshallerHandler handler =
                new AtomUnmarshallingListener.AtomUnmarshallerHandler(unmarshallerHandler);
            AtomUnmarshallingListener listener = new AtomUnmarshallingListener(handler);
            unmarshaller.setListener(listener);
            // here is where the magic begins.
View Full Code Here

            persistenceDescriptor = url.openStream();

            JAXBContext jc = JAXBContextFactory.newInstance(Persistence.class);
            Unmarshaller u = jc.createUnmarshaller();
            UnmarshallerHandler uh = u.getUnmarshallerHandler();

            // create a new XML parser
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(true);
View Full Code Here

     *      JAXB unmarshalling errors. Before this exception is thrown,
     *      it is reported to the {@link javax.xml.bind.ValidationEventHandler}
     *      of the unmarshaller first.
     */
    public Object unmarshalSubTree( XmlPullParser parser ) throws IllegalStateException, JAXBException {
        UnmarshallerHandler handler = unmarshaller.getUnmarshallerHandler();
       
        try {
            new Worker(parser,handler).parse();
        } catch( XmlPullParserException e ) {
            throw new JAXBException(e);
        } catch( SAXException e ) {
            // forward the error  TODO:report to the error handler
            throw new JAXBException(e);
        } catch( IOException e ) {
            // forward the error  TODO:report to the error handler
            throw new JAXBException(e);
        }
       
        return handler.getResult();
    }
View Full Code Here

            persistenceDescriptor = url.openStream();

            JAXBContext jc = JAXBContext.newInstance(Persistence.class);
            Unmarshaller u = jc.createUnmarshaller();
            UnmarshallerHandler uh = u.getUnmarshallerHandler();

            // create a new XML parser
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(true);
View Full Code Here

            persistenceDescriptor = url.openStream();

            JAXBContext jc = JAXBContextFactory.newInstance(Persistence.class);
            Unmarshaller u = jc.createUnmarshaller();
            UnmarshallerHandler uh = u.getUnmarshallerHandler();

            // create a new XML parser
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(true);
View Full Code Here

    }
    return uh.getResult();
  }

  public Object unmarshal(Node pNode) throws JAXBException {
    UnmarshallerHandler uh = getUnmarshallerHandler();
    DOMSerializer ds = new DOMSerializer();
    try {
      ds.serialize(pNode, uh);
    } catch (SAXException e) {
      if (e.getException() != null) {
        throw new UnmarshalException(e.getException());
      } else {
        throw new UnmarshalException(e);
      }
    }
    return uh.getResult();
  }
View Full Code Here

      }
      XMLReader xr = ss.getXMLReader();
      if (xr == null) {
        return unmarshal(is);
      } else {
        UnmarshallerHandler uh = getUnmarshallerHandler();
        xr.setContentHandler(uh);
        try {
          xr.parse(is);
        } catch (IOException e) {
          throw new JAXBException(e);
        } catch (SAXException e) {
          if (e.getException() != null) {
            throw new JAXBException(e.getException());
          } else {
            throw new JAXBException(e);
          }
        }
        return uh.getResult();
      }
    } else if (pSource instanceof StreamSource) {
      StreamSource ss = (StreamSource) pSource;
      InputSource iSource = new InputSource();
      iSource.setPublicId(ss.getPublicId());
View Full Code Here

            persistenceDescriptor = url.openStream();

            JAXBContext jc = JAXBContextFactory.newInstance(clazz);
            Unmarshaller u = jc.createUnmarshaller();
            UnmarshallerHandler uh = u.getUnmarshallerHandler();

            // create a new XML parser
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(true);
View Full Code Here

TOP

Related Classes of javax.xml.bind.UnmarshallerHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.