Package javax.xml.bind

Examples of javax.xml.bind.UnmarshallerHandler


    public static final String PERSISTENCE_SCHEMA = "http://java.sun.com/xml/ns/persistence";

    public static <T> T getPersistence(final Class<T> clazz, final InputStream persistenceDescriptor) throws Exception {
        final JAXBContext jc = 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);
View Full Code Here


        JAXBContext jc = getJAXBContextImpl();
        Marshaller m = jc.createMarshaller();
        Unmarshaller u = jc.createUnmarshaller();
        MyEventHandler eh = new MyEventHandler();
        u.setEventHandler(eh);
        UnmarshallerHandler uh = u.getUnmarshallerHandler();
        m.marshal(pObject, uh);
        return !eh.invalid;
    }
View Full Code Here

    public Object unmarshal(InputStream pStream) throws JAXBException {
        return unmarshal(new InputSource(pStream));
    }
   
    public Object unmarshal(InputSource pSource) throws JAXBException {
        UnmarshallerHandler uh = getUnmarshallerHandler();
        try {
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            xr.setContentHandler(uh);
            xr.parse(pSource);
        } catch (SAXException e) {
            if (e.getException() != null) {
                throw new UnmarshalException(e.getException());
            } else {
                throw new UnmarshalException(e);
            }
        } catch (IOException e) {
            throw new UnmarshalException(e);
        } catch (ParserConfigurationException e) {
            throw new UnmarshalException(e);
        }
        return uh.getResult();
    }
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

                JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
                final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
                SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
                Schema schema = schemaFactory.newSchema(Init.class.getClassLoader().getResource("schemas/security-config.xsd"));
                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 = Init.class.getClassLoader().getResource("security-config.xml");
                    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());
                SecurityHeaderHandlerMapper.init(configurationTypeJAXBElement.getValue().getSecurityHeaderHandlers());
                JCEAlgorithmMapper.init(configurationTypeJAXBElement.getValue().getJCEAlgorithmMappings());
                TransformerAlgorithmMapper.init(configurationTypeJAXBElement.getValue().getTransformAlgorithms());
View Full Code Here

    public static final String PERSISTENCE_SCHEMA = "http://java.sun.com/xml/ns/persistence";

    public static <T> T getPersistence(Class<T> clazz, InputStream persistenceDescriptor) throws Exception {
        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

    }
   
    public final Object unmarshal( Node node ) throws JAXBException {
        try {
            DOMScanner scanner = new DOMScanner();
            UnmarshallerHandler handler = new InterningUnmarshallerHandler(
                createUnmarshallerHandler(new DOMLocator(scanner)));
           
            if(node instanceof Element)
                scanner.parse((Element)node,handler);
            else
            if(node instanceof Document)
                scanner.parse(((Document)node).getDocumentElement(),handler);
            else
                // no other type of input is supported
                throw new IllegalArgumentException();
           
            return handler.getResult();
        } catch( SAXException e ) {
            throw createUnmarshalException(e);
        }
    }
View Full Code Here

    public static final String PERSISTENCE_SCHEMA = "http://java.sun.com/xml/ns/persistence";

    public static <T> T getPersistence(Class<T> clazz, InputStream persistenceDescriptor) throws Exception {
        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

    public static final String PERSISTENCE_SCHEMA = "http://java.sun.com/xml/ns/persistence";

    public static <T> T getPersistence(final Class<T> clazz, final InputStream persistenceDescriptor) throws Exception {
        final JAXBContext jc = 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);
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.