public XMLMarshaller getXmlMarshaller() { XMLMarshaller marshaller = xmlMarshallerMap.get(Thread.currentThread()); if (marshaller == null) { marshaller = getXmlContext().createMarshaller(); marshaller.setMarshalListener(new SDOMarshalListener(marshaller, (SDOTypeHelper) aHelperContext.getTypeHelper())); xmlMarshallerMap.put(Thread.currentThread(), marshaller); } XMLContext context = getXmlContext(); if (marshaller.getXMLContext() != context) { marshaller.setXMLContext(context); } return marshaller; }
public XMLMarshaller getXmlMarshaller() { XMLMarshaller marshaller = xmlMarshallerMap.get(Thread.currentThread()); if (marshaller == null) { marshaller = getXmlContext().createMarshaller(); marshaller.setMarshalListener(new SDOMarshalListener(marshaller, (SDOTypeHelper) aHelperContext.getTypeHelper())); xmlMarshallerMap.put(Thread.currentThread(), marshaller); } XMLContext context = getXmlContext(); if (marshaller.getXMLContext() != context) { marshaller.setXMLContext(context); } return marshaller; }
/** * INTENAL: */ public static void write(XMLEntityMappings entityMappings, Writer writer) { XMLContext context = XMLEntityMappingsReader.getEclipseLinkOrmProject(); XMLMarshaller marshaller = context.createMarshaller(); marshaller.setSchemaLocation(XMLEntityMappingsReader.ECLIPSELINK_ORM_NAMESPACE + " " + XMLEntityMappingsReader.ECLIPSELINK_ORM_XSD); marshaller.marshal(entityMappings, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } } }
public XMLBinder(XMLContext context) { marshaller = context.createMarshaller(); unmarshaller = context.createUnmarshaller(); saxUnmarshaller = new SAXUnmarshaller(unmarshaller, null); this.context = context; documentPreservationPolicy = new XMLBinderPolicy(); reader = new DOMReader(); }
public XMLBinder(XMLContext context) { this.context = new XMLContext(context.getXMLContextState()); marshaller = this.context.createMarshaller(); unmarshaller = this.context.createUnmarshaller(); initialize(); }
public XMLBinder(XMLContext context) { this.context = new XMLContext(context.getXMLContextState()); marshaller = this.context.createMarshaller(); unmarshaller = this.context.createUnmarshaller(); initialize(); }
/** * Given the writer, and a SessionConfigs, * this writes out the session XML file. * * @param writer writer to writer to * @param eclipseLinkSessions the SessionConfigs instance to write */ public static void write(SessionConfigs toplinkSessions, Writer writer) { XMLContext context = new XMLContext(new XMLSessionConfigProject_11_1_1()); XMLMarshaller marshaller = context.createMarshaller(); // this is throwing a null pointer exception right now, bug entered //marshaller.setNoNamespaceSchemaLocation("eclipse_persistence_sessions_1_0.xsd"); marshaller.marshal(toplinkSessions, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } } }
/** * Given the writer, and a SessionConfigs, * this writes out the session XML file. * * @param writer writer to writer to * @param eclipseLinkSessions the SessionConfigs instance to write */ public static void write(SessionConfigs toplinkSessions, Writer writer) { XMLContext context = new XMLContext(new XMLSessionConfigProject_11_1_1()); XMLMarshaller marshaller = context.createMarshaller(); // this is throwing a null pointer exception right now, bug entered //marshaller.setNoNamespaceSchemaLocation("eclipse_persistence_sessions_1_0.xsd"); marshaller.marshal(toplinkSessions, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } } }
/** * Given the writer, and a SessionConfigs, * this writes out the session XML file. * * @param writer writer to writer to * @param eclipseLinkSessions the SessionConfigs instance to write */ public static void write(SessionConfigs toplinkSessions, Writer writer) { XMLContext context = new XMLContext(new XMLSessionConfigProject_11_1_1()); XMLMarshaller marshaller = context.createMarshaller(); // this is throwing a null pointer exception right now, bug entered //marshaller.setNoNamespaceSchemaLocation("eclipse_persistence_sessions_1_0.xsd"); marshaller.marshal(toplinkSessions, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } } }
public JAXBBinder createBinder(JAXBContext context) { XMLMarshaller marshaller = null; XMLUnmarshaller unmarshaller = null; try { marshaller = createMarshaller(context).getXMLMarshaller(); unmarshaller = createUnmarshaller(context).getXMLUnmarshaller(); } catch (javax.xml.bind.JAXBException e) { // log something marshaller = context.getXMLContext().createMarshaller(); unmarshaller = context.getXMLContext().createUnmarshaller(); } return new JAXBBinder(context, marshaller, unmarshaller); }
/** * PUBLIC: * Given the writer, and a project, * this writes out the deployment XML file storing the project's descriptor and mapping information. * * @param writer writer to writer to * @param project the project instance to write */ public static void write(Project project, Writer writer) { XMLContext context = new XMLContext(new ObjectPersistenceWorkbenchXMLProject()); context.getSession(project).getEventManager().addListener(new MissingDescriptorListener()); XMLMarshaller marshaller = context.createMarshaller(); marshaller.marshal(project, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } }
/** * PUBLIC: * Given the writer, and a project, * this writes out the deployment XML file storing the project's descriptor and mapping information. * * @param writer writer to writer to * @param project the project instance to write */ public static void write(Project project, Writer writer) { XMLContext context = new XMLContext(new ObjectPersistenceWorkbenchXMLProject()); context.getSession(project).getEventManager().addListener(new MissingDescriptorListener()); XMLMarshaller marshaller = context.createMarshaller(); marshaller.marshal(project, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } }
/** * PUBLIC: * Given the writer, and a project, * this writes out the deployment XML file storing the project's descriptor and mapping information. * * @param writer writer to writer to * @param project the project instance to write */ public static void write(Project project, Writer writer) { XMLContext context = new XMLContext(new ObjectPersistenceWorkbenchXMLProject()); context.getSession(project).getEventManager().addListener(new MissingDescriptorListener()); XMLMarshaller marshaller = context.createMarshaller(); marshaller.marshal(project, writer); try { writer.flush(); } catch (IOException exception) { throw ValidationException.fileError(exception); } }
public JAXBBinder createBinder(JAXBContext context) { XMLMarshaller marshaller = null; XMLUnmarshaller unmarshaller = null; try { marshaller = createMarshaller(context).getXMLMarshaller(); unmarshaller = createUnmarshaller(context).getXMLUnmarshaller(); } catch (javax.xml.bind.JAXBException e) { // log something marshaller = context.getXMLContext().createMarshaller(); unmarshaller = context.getXMLContext().createUnmarshaller(); } return new JAXBBinder(context, marshaller, unmarshaller); }
private Object buildFragment(Property property, SDODataObject parentObject, SDODataObject value) { //build an XML Fragment from this SDO XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); XMLMarshaller xmlMarshaller = ((SDOXMLHelper)helperContext.getXMLHelper()).getXmlContext().createMarshaller(); Document doc = xmlPlatform.createDocument(); XMLRoot root = new XMLRoot(); root.setObject(value); root.setLocalName(property.getName()); if(((SDOProperty)property).isNamespaceQualified()){ root.setNamespaceURI(parentObject.getType().getURI()); } xmlMarshaller.marshal(root, doc); return doc.getDocumentElement(); } }
public Map<String, SchemaTypeInfo> generateSchemaFiles(String schemaPath, Map<QName, Type> additionalGlobalElements) throws FileNotFoundException { // process any additional global elements processAdditionalElements(additionalGlobalElements, annotationsProcessor); schemaGenerator.generateSchema(annotationsProcessor.getTypeInfoClasses(), annotationsProcessor.getTypeInfos(), annotationsProcessor.getUserDefinedSchemaTypes(), annotationsProcessor.getPackageToPackageInfoMappings(), annotationsProcessor.getGlobalElements(), annotationsProcessor.getArrayClassesToGeneratedClasses()); CoreProject proj = new SchemaModelProject(); XMLContext context = new XMLContext((Project)proj); XMLMarshaller marshaller = context.createMarshaller(); Descriptor schemaDescriptor = (Descriptor)proj.getDescriptor(Schema.class); java.util.Collection<Schema> schemas = schemaGenerator.getAllSchemas(); for(Schema schema : schemas) { File file = new File(schemaPath + "/" + schema.getName()); NamespaceResolver schemaNamespaces = schema.getNamespaceResolver(); schemaNamespaces.put(Constants.SCHEMA_PREFIX, XMLConstants.W3C_XML_SCHEMA_NS_URI); schemaDescriptor.setNamespaceResolver(schemaNamespaces); marshaller.marshal(schema, new FileOutputStream(file)); } return schemaGenerator.getSchemaTypeInfo(); }
private Object buildFragment(Property property, SDODataObject parentObject, SDODataObject value) { //build an XML Fragment from this SDO XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); XMLMarshaller xmlMarshaller = ((SDOXMLHelper)helperContext.getXMLHelper()).getXmlContext().createMarshaller(); Document doc = xmlPlatform.createDocument(); XMLRoot root = new XMLRoot(); root.setObject(value); root.setLocalName(property.getName()); if(((SDOProperty)property).isNamespaceQualified()){ root.setNamespaceURI(parentObject.getType().getURI()); } xmlMarshaller.marshal(root, doc); return doc.getDocumentElement(); } }
public Map<String, SchemaTypeInfo> generateSchemaFiles(String schemaPath, Map<QName, Type> additionalGlobalElements) throws FileNotFoundException { // process any additional global elements processAdditionalElements(additionalGlobalElements, annotationsProcessor); schemaGenerator.generateSchema(annotationsProcessor.getTypeInfoClasses(), annotationsProcessor.getTypeInfos(), annotationsProcessor.getUserDefinedSchemaTypes(), annotationsProcessor.getPackageToPackageInfoMappings(), annotationsProcessor.getGlobalElements(), annotationsProcessor.getArrayClassesToGeneratedClasses()); CoreProject proj = new SchemaModelProject(); XMLContext context = new XMLContext((Project)proj); XMLMarshaller marshaller = context.createMarshaller(); Descriptor schemaDescriptor = (Descriptor)proj.getDescriptor(Schema.class); java.util.Collection<Schema> schemas = schemaGenerator.getAllSchemas(); for(Schema schema : schemas) { File file = new File(schemaPath + "/" + schema.getName()); NamespaceResolver schemaNamespaces = schema.getNamespaceResolver(); schemaNamespaces.put(Constants.SCHEMA_PREFIX, XMLConstants.W3C_XML_SCHEMA_NS_URI); schemaDescriptor.setNamespaceResolver(schemaNamespaces); marshaller.marshal(schema, new FileOutputStream(file)); } return schemaGenerator.getSchemaTypeInfo(); }
public JAXBMarshaller createMarshaller(JAXBContext jaxbContext) throws javax.xml.bind.JAXBException { // create a JAXBIntrospector and set it on the marshaller JAXBMarshaller marshaller = new JAXBMarshaller(xmlContext.createMarshaller(), jaxbContext); if (generator != null && generator.hasMarshalCallbacks()) { // initialize each callback in the map ClassLoader classLoader = getXMLContext().getSession(0).getDatasourcePlatform().getConversionManager().getLoader(); for (Object o : generator.getMarshalCallbacks().keySet()) { MarshalCallback cb = (MarshalCallback) generator.getMarshalCallbacks().get(o); cb.initialize(classLoader); } marshaller.setMarshalCallbacks(generator.getMarshalCallbacks()); } if (properties != null) { setPropertyOnMarshaller(JAXBContextProperties.MEDIA_TYPE, marshaller); setPropertyOnMarshaller(JAXBContextProperties.JSON_ATTRIBUTE_PREFIX, marshaller); setPropertyOnMarshaller(JAXBContextProperties.NAMESPACE_PREFIX_MAPPER, marshaller); setPropertyOnMarshaller(JAXBContextProperties.JSON_INCLUDE_ROOT, marshaller); setPropertyOnMarshaller(JAXBContextProperties.JSON_VALUE_WRAPPER, marshaller); setPropertyOnMarshaller(JAXBContextProperties.JSON_NAMESPACE_SEPARATOR, marshaller); setPropertyOnMarshaller(JAXBContextProperties.OBJECT_GRAPH, marshaller); setPropertyOnMarshaller(JAXBContextProperties.JSON_WRAPPER_AS_ARRAY_NAME, marshaller); setPropertyOnMarshaller(JAXBContextProperties.BEAN_VALIDATION_MODE, marshaller); setPropertyOnMarshaller(JAXBContextProperties.BEAN_VALIDATION_FACTORY, marshaller); setPropertyOnMarshaller(JAXBContextProperties.BEAN_VALIDATION_GROUPS, marshaller); setPropertyOnMarshaller(JAXBContextProperties.BEAN_VALIDATION_NO_OPTIMISATION, marshaller); setPropertyOnMarshaller(JAXBContextProperties.JSON_TYPE_COMPATIBILITY, marshaller); setPropertyOnMarshaller(JAXBContextProperties.JSON_USE_XSD_TYPES_WITH_PREFIX, marshaller); } return marshaller; }
public Map<String, SchemaTypeInfo> generateSchemaFiles(SchemaOutputResolver outputResolver, Map<QName, Type> additionalGlobalElements) { // process any additional global elements processAdditionalElements(additionalGlobalElements, annotationsProcessor); schemaGenerator.generateSchema(annotationsProcessor.getTypeInfoClasses(), annotationsProcessor.getTypeInfos(), annotationsProcessor.getUserDefinedSchemaTypes(), annotationsProcessor.getPackageToPackageInfoMappings(), annotationsProcessor.getGlobalElements(), annotationsProcessor.getArrayClassesToGeneratedClasses(), outputResolver); CoreProject proj = new SchemaModelProject(); XMLContext context = new XMLContext((Project)proj); XMLMarshaller marshaller = context.createMarshaller(); Descriptor schemaDescriptor = (Descriptor)proj.getDescriptor(Schema.class); java.util.Collection<Schema> schemas = schemaGenerator.getAllSchemas(); for(Schema schema : schemas) { try { NamespaceResolver schemaNamespaces = schema.getNamespaceResolver(); schemaNamespaces.put(Constants.SCHEMA_PREFIX, XMLConstants.W3C_XML_SCHEMA_NS_URI); schemaDescriptor.setNamespaceResolver(schemaNamespaces); // make sure we don't call into the provided output resolver more than once javax.xml.transform.Result target; if (schema.hasResult()) { target = schema.getResult(); } else { target = outputResolver.createOutput(schema.getTargetNamespace(), schema.getName()); } marshaller.marshal(schema, target); } catch (IOException ex) { ex.printStackTrace(); } } return schemaGenerator.getSchemaTypeInfo(); }