/** * The XML bindings metadata will be loaded from an XMLEventReader. */ public XMLMetadataSource(XMLEventReader xmlBindings) { if(xmlBindings == null) { throw new IllegalArgumentException(); } try { xmlBindingsSource = new StAXSource(xmlBindings); } catch (XMLStreamException e) { org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(e); } }
/** * The XML bindings metadata will be loaded from an XMLEventReader. */ public XMLMetadataSource(XMLEventReader xmlBindings) { if(xmlBindings == null) { throw new IllegalArgumentException(); } try { xmlBindingsSource = new StAXSource(xmlBindings); } catch (XMLStreamException e) { org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(e); } }
/** * Convenience method for creating an XmlElement object based on a given * Element. The method will load the eclipselink metadata model and * unmarshal the Element. This assumes that the Element represents an * xml-element to be unmarshalled. * * @param xmlElementNode * @param classLoader * @return */ static org.eclipse.persistence.jaxb.xmlmodel.XmlElement getXmlElement(org.w3c.dom.Element xmlElementNode, ClassLoader classLoader) { try { Unmarshaller unmarshaller = CompilerHelper.getXmlBindingsModelContext().createUnmarshaller(); JAXBElement<org.eclipse.persistence.jaxb.xmlmodel.XmlElement> jelt = unmarshaller.unmarshal(xmlElementNode, org.eclipse.persistence.jaxb.xmlmodel.XmlElement.class); return jelt.getValue(); } catch (javax.xml.bind.JAXBException jaxbEx) { throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(jaxbEx); } }
/** * Convenience method for creating an XmlElement object based on a given * Element. The method will load the eclipselink metadata model and * unmarshal the Element. This assumes that the Element represents an * xml-element to be unmarshalled. * * @param xmlElementNode * @param classLoader * @return */ static org.eclipse.persistence.jaxb.xmlmodel.XmlElement getXmlElement(org.w3c.dom.Element xmlElementNode, ClassLoader classLoader) { try { Unmarshaller unmarshaller = CompilerHelper.getXmlBindingsModelContext().createUnmarshaller(); JAXBElement<org.eclipse.persistence.jaxb.xmlmodel.XmlElement> jelt = unmarshaller.unmarshal(xmlElementNode, org.eclipse.persistence.jaxb.xmlmodel.XmlElement.class); return jelt.getValue(); } catch (javax.xml.bind.JAXBException jaxbEx) { throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(jaxbEx); } }
@Override public XmlBindings getXmlBindings(Map<String, ?> properties, ClassLoader classLoader) { try { JAXBContext jaxbContext = CompilerHelper.getXmlBindingsModelContext(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); if(null != xmlBindingsSource) { return (XmlBindings) unmarshaller.unmarshal(xmlBindingsSource); } if(null != xmlBindingsURL) { return (XmlBindings) unmarshaller.unmarshal(xmlBindingsURL); } if(null != xmlBindingsLocation) { URL url = classLoader.getResource(xmlBindingsLocation); if(url == null) { // throw exception throw org.eclipse.persistence.exceptions.JAXBException.unableToLoadMetadataFromLocation(xmlBindingsLocation); } return (XmlBindings) unmarshaller.unmarshal(url); } } catch(JAXBException e) { throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(e); } return null; }
@Override public XmlBindings getXmlBindings(Map<String, ?> properties, ClassLoader classLoader) { try { JAXBContext jaxbContext = CompilerHelper.getXmlBindingsModelContext(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); if(null != xmlBindingsSource) { return (XmlBindings) unmarshaller.unmarshal(xmlBindingsSource); } if(null != xmlBindingsURL) { return (XmlBindings) unmarshaller.unmarshal(xmlBindingsURL); } if(null != xmlBindingsLocation) { URL url = classLoader.getResource(xmlBindingsLocation); if(url == null) { // throw exception throw org.eclipse.persistence.exceptions.JAXBException.unableToLoadMetadataFromLocation(xmlBindingsLocation); } return (XmlBindings) unmarshaller.unmarshal(url); } } catch(JAXBException e) { throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(e); } return null; }
bindingsJaxbElement = unmarshaller.unmarshal(new StreamSource(openedStream), XmlBindings.class); }else{ throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(e); throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(ex); }catch(IOException ioException){ throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(ioException); }finally{ if(openedStream != null){ openedStream.close(); } catch (IOException e) { throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(e);
bindingsJaxbElement = unmarshaller.unmarshal(new StreamSource(openedStream), XmlBindings.class); }else{ throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(e); throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(ex); }catch(IOException ioException){ throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(ioException); }finally{ if(openedStream != null){ openedStream.close(); } catch (IOException e) { throw org.eclipse.persistence.exceptions.JAXBException.couldNotUnmarshalMetadata(e);