private boolean buildSessionConfigs(SessionManager sessionManager, ClassLoader loader,Document document, Project project){ // No errors occurred, unmasrshal the document which will return a // SessionConfigs containing 0 or more SessionConfigs and send // them through the factory to create actual Sessions XMLContext context = new XMLContext(project); XMLUnmarshaller unmarshaller = context.createUnmarshaller(); SessionConfigs configs = (SessionConfigs)unmarshaller.unmarshal(document); SessionsFactory factory = new SessionsFactory(); Map sessions = factory.buildSessionConfigs(configs, loader); for (Iterator iterator = sessions.entrySet().iterator(); iterator.hasNext(); ) { Map.Entry entry = (Map.Entry)iterator.next(); // Only add the session if missing. if (!sessionManager.getSessions().containsKey(entry.getKey())) { sessionManager.addSession((String)entry.getKey(), (Session)entry.getValue()); } } return true; }
private boolean buildSessionConfigs(SessionManager sessionManager, ClassLoader loader,Document document, Project project){ // No errors occurred, unmasrshal the document which will return a // SessionConfigs containing 0 or more SessionConfigs and send // them through the factory to create actual Sessions XMLContext context = new XMLContext(project); XMLUnmarshaller unmarshaller = context.createUnmarshaller(); SessionConfigs configs = (SessionConfigs)unmarshaller.unmarshal(document); SessionsFactory factory = new SessionsFactory(); Map<String, Session> sessions = factory.buildSessionConfigs(configs, loader); for (Map.Entry<String, Session> entry: sessions.entrySet()) { // Only add the session if missing. if (!sessionManager.getSessions().containsKey(entry.getKey())) { sessionManager.addSession(entry.getKey(), entry.getValue()); } } return true; }
private boolean buildSessionConfigs(SessionManager sessionManager, ClassLoader loader,Document document, Project project){ // No errors occurred, unmasrshal the document which will return a // SessionConfigs containing 0 or more SessionConfigs and send // them through the factory to create actual Sessions XMLContext context = new XMLContext(project); XMLUnmarshaller unmarshaller = context.createUnmarshaller(); SessionConfigs configs = (SessionConfigs)unmarshaller.unmarshal(document); SessionsFactory factory = new SessionsFactory(); Map<String, Session> sessions = factory.buildSessionConfigs(configs, loader); for (Map.Entry<String, Session> entry: sessions.entrySet()) { // Only add the session if missing. if (!sessionManager.getSessions().containsKey(entry.getKey())) { sessionManager.addSession(entry.getKey(), entry.getValue()); } } return true; }
/** * INTERNAL: */ protected void addXMLEntityMappings(String mappingFile, XMLContext context) { // If the input stream is null, we didn't find the mapping file, so // don't bother trying to read it. InputStream inputStream = persistenceUnitReader.getInputStream(mappingFile, false); if (inputStream != null) { try { XMLEntityMappings entityMappings = (XMLEntityMappings) context.createUnmarshaller().unmarshal(inputStream); // For eclipselink-orm merging and overriding these need to be set. entityMappings.setIsEclipseLinkORMFile(mappingFile.equals(MetadataHelper.ECLIPSELINK_ORM_FILE)); entityMappings.setMappingFile(mappingFile); processingEnv.getMessager().printMessage(Kind.NOTE, "File loaded : " + mappingFile + ", is eclipselink-orm file: " + entityMappings.isEclipseLinkORMFile()); xmlEntityMappings.add(entityMappings); } finally { persistenceUnitReader.closeInputStream(inputStream); } } }
@SuppressWarnings("unchecked") public boolean load(SessionManager sessionManager, ClassLoader loader) { Document document = loadDocument(loader); if(getExceptionStore().isEmpty()){ if (document.getDocumentElement().getTagName().equals("sessions")) { XMLContext context = new XMLContext(new XMLSessionConfigProject_11_1_1()); XMLUnmarshaller unmarshaller = context.createUnmarshaller(); SessionConfigs configs = (SessionConfigs)unmarshaller.unmarshal(document); XRSessionsFactory factory = new XRSessionsFactory(); Map<String, Session> sessions = factory.buildSessionConfigs(configs, loader); for (Map.Entry<String, Session> entry : sessions.entrySet()) { if (!sessionManager.getSessions().containsKey(entry.getKey())) { sessionManager.addSession(entry.getKey(), entry.getValue()); } } return true; } } return false; } }
@SuppressWarnings("unchecked") public boolean load(SessionManager sessionManager, ClassLoader loader) { Document document = loadDocument(loader); if(getExceptionStore().isEmpty()){ if (document.getDocumentElement().getTagName().equals("sessions")) { XMLContext context = new XMLContext(new XMLSessionConfigProject_11_1_1()); XMLUnmarshaller unmarshaller = context.createUnmarshaller(); SessionConfigs configs = (SessionConfigs)unmarshaller.unmarshal(document); XRSessionsFactory factory = new XRSessionsFactory(); Map<String, Session> sessions = factory.buildSessionConfigs(configs, loader); for (Map.Entry<String, Session> entry : sessions.entrySet()) { if (!sessionManager.getSessions().containsKey(entry.getKey())) { sessionManager.addSession(entry.getKey(), entry.getValue()); } } return true; } } return false; } }
public XMLUnmarshaller getXmlUnmarshaller() { XMLUnmarshaller unmarshaller = xmlUnmarshallerMap.get(Thread.currentThread()); if (null == unmarshaller) { unmarshaller = getXmlContext().createUnmarshaller(); unmarshaller.getProperties().put(SDOConstants.SDO_HELPER_CONTEXT, aHelperContext); unmarshaller.setUnmappedContentHandlerClass(SDOUnmappedContentHandler.class); unmarshaller.setUnmarshalListener(new SDOUnmarshalListener(aHelperContext)); unmarshaller.setResultAlwaysXMLRoot(true); xmlUnmarshallerMap.put(Thread.currentThread(), unmarshaller); } XMLContext context = getXmlContext(); if (unmarshaller.getXMLContext() != context) { unmarshaller.setXMLContext(context); } return unmarshaller; }
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 XMLUnmarshaller getXmlUnmarshaller() { XMLUnmarshaller unmarshaller = xmlUnmarshallerMap.get(Thread.currentThread()); if (null == unmarshaller) { unmarshaller = getXmlContext().createUnmarshaller(); unmarshaller.getProperties().put(SDOConstants.SDO_HELPER_CONTEXT, aHelperContext); unmarshaller.setUnmappedContentHandlerClass(SDOUnmappedContentHandler.class); unmarshaller.setUnmarshalListener(new SDOUnmarshalListener(aHelperContext)); unmarshaller.setResultAlwaysXMLRoot(true); xmlUnmarshallerMap.put(Thread.currentThread(), unmarshaller); } XMLContext context = getXmlContext(); if (unmarshaller.getXMLContext() != context) { unmarshaller.setXMLContext(context); } return unmarshaller; }
public XMLBinder(XMLContext context) { this.context = new XMLContext(context.getXMLContextState()); marshaller = this.context.createMarshaller(); unmarshaller = this.context.createUnmarshaller(); initialize(); }
XMLUnmarshaller unmarshaller = context.createUnmarshaller(); return (SessionConfigs)unmarshaller.unmarshal(document); }else{ XMLUnmarshaller unmarshaller = context.createUnmarshaller(); return (SessionConfigs)unmarshaller.unmarshal(document); }else{
/** * INTERNAL: */ protected void addXMLEntityMappings(String mappingFile, XMLContext context) { // If the input stream is null, we didn't find the mapping file, so // don't bother trying to read it. InputStream inputStream = persistenceUnitReader.getInputStream(mappingFile, false); if (inputStream != null) { try { XMLEntityMappings entityMappings = (XMLEntityMappings) context.createUnmarshaller().unmarshal(inputStream); // For eclipselink-orm merging and overriding these need to be set. entityMappings.setIsEclipseLinkORMFile(mappingFile.equals(MetadataHelper.ECLIPSELINK_ORM_FILE)); entityMappings.setMappingFile(mappingFile); if (factory.getLogger().shouldLog(LogLevel.INFO, LogCategory.PROCESSOR)) { processingEnv.getMessager().printMessage(Kind.NOTE, "File loaded : " + mappingFile + ", is eclipselink-orm file: " + entityMappings.isEclipseLinkORMFile()); } xmlEntityMappings.add(entityMappings); } finally { persistenceUnitReader.closeInputStream(inputStream); } } }
/** * <p>INTERNAL: * */ public void loadXMLSchema(InputStream xrSchemaStream) { SchemaModelProject schemaProject = new SchemaModelProject(); XMLContext xmlContext = new XMLContext(schemaProject); XMLUnmarshaller unmarshaller = xmlContext.createUnmarshaller(); Schema schema = (Schema)unmarshaller.unmarshal(xrSchemaStream); NamespaceResolver nr = schema.getNamespaceResolver(); String targetNamespace = schema.getTargetNamespace(); nr.put(TARGET_NAMESPACE_PREFIX, targetNamespace); xrService.schema = schema; xrService.schemaNamespace = targetNamespace; }
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 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); }
XMLUnmarshaller unmarshaller = ((XMLContext)context[0]).createUnmarshaller();
/** * <p>INTERNAL: * Read and unmarshal <code>XRService</code>'s <tt>.xsd</tt> file. * @param xrSchemaStream Stream resource for the <code>XRService</code>'s <tt>.xsd</tt> file. */ public void loadXMLSchema(InputStream xrSchemaStream) { SchemaModelProject schemaProject = new SchemaModelProject(); XMLContext xmlContext = new XMLContext(schemaProject); XMLUnmarshaller unmarshaller = xmlContext.createUnmarshaller(); Schema schema; try { schema = (Schema)unmarshaller.unmarshal(xrSchemaStream); } catch (XMLMarshalException e) { xmlContext.getSession().getSessionLog().log( SessionLog.WARNING, SessionLog.DBWS, "dbws_xml_schema_read_error", e.getLocalizedMessage()); throw new DBWSException(OXM_PROCESSING_SCH, e); } NamespaceResolver nr = schema.getNamespaceResolver(); String targetNamespace = schema.getTargetNamespace(); nr.put(TARGET_NAMESPACE_PREFIX, targetNamespace); xrService.schema = schema; xrService.schemaNamespace = targetNamespace; }
/** * Read a project in the format of an ObjectPersistenceRuntimeXMLProject. * This could include a TopLink 11.1.1 project or a TopLink 10.1.3 project * @param document * @param classLoader * @param opmProject * @return */ public static Project readObjectPersistenceRuntimeFormat(Document document, ClassLoader classLoader, Project opmProject){ XMLLogin xmlLogin = new XMLLogin(); xmlLogin.setDatasourcePlatform(new org.eclipse.persistence.oxm.platform.DOMPlatform()); opmProject.setDatasourceLogin(xmlLogin); // Create the OPM project. if (classLoader != null) { xmlLogin.getDatasourcePlatform().getConversionManager().setLoader(classLoader); } // Marshal OPM format. XMLContext context = new XMLContext(opmProject); context.getSession(Project.class).getEventManager().addListener(new MissingDescriptorListener()); XMLUnmarshaller unmarshaller = context.createUnmarshaller(); Project project = (Project)unmarshaller.unmarshal(document); // Set the project's class loader. if ((classLoader != null) && (project.getDatasourceLogin() != null)) { project.getDatasourceLogin().getDatasourcePlatform().getConversionManager().setLoader(classLoader); } return project; }
/** * Read a project in the format of an ObjectPersistenceRuntimeXMLProject. * This could include a TopLink 11.1.1 project or a TopLink 10.1.3 project * @param document * @param classLoader * @param opmProject * @return */ public static Project readObjectPersistenceRuntimeFormat(Document document, ClassLoader classLoader, Project opmProject){ XMLLogin xmlLogin = new XMLLogin(); xmlLogin.setDatasourcePlatform(new org.eclipse.persistence.oxm.platform.DOMPlatform()); opmProject.setDatasourceLogin(xmlLogin); // Create the OPM project. if (classLoader != null) { xmlLogin.getDatasourcePlatform().getConversionManager().setLoader(classLoader); } // Marshal OPM format. XMLContext context = new XMLContext(opmProject); context.getSession(Project.class).getEventManager().addListener(new MissingDescriptorListener()); XMLUnmarshaller unmarshaller = context.createUnmarshaller(); Project project = (Project)unmarshaller.unmarshal(document); // Set the project's class loader. if ((classLoader != null) && (project.getDatasourceLogin() != null)) { project.getDatasourceLogin().getDatasourcePlatform().getConversionManager().setLoader(classLoader); } return project; }