use of org.eclipse.persistence.oxm.XMLContext in project eclipselink by eclipse-ee4j.
the class JAXBContext method newContextState.
/**
* INTERNAL:
* Build a new JAXBContextState from the current JAXBContextInput.
*/
private JAXBContextState newContextState() throws jakarta.xml.bind.JAXBException {
if (null == contextInput) {
return null;
}
synchronized (this) {
JAXBContextState newState = contextInput.createContextState();
XMLContext xmlContext = getXMLContext();
xmlContext.setXMLContextState(newState.getXMLContext().getXMLContextState());
newState.setXMLContext(xmlContext);
newState.setTypeToTypeMappingInfo(contextState.getTypeToTypeMappingInfo());
return newState;
}
}
use of org.eclipse.persistence.oxm.XMLContext in project eclipselink by eclipse-ee4j.
the class XMLEntityMappingsReader method read.
/**
* INTERNAL:
*/
protected static XMLEntityMappings read(String mappingFile, Reader reader1, Reader reader2, ClassLoader classLoader, Map properties) {
// Get the schema validation flag if present in the persistence unit properties
boolean validateORMSchema = isORMSchemaValidationPerformed(properties);
// Unmarshall JPA format.
XMLEntityMappings xmlEntityMappings;
try {
// First need to determine which context/schema to use, JPA 1.0, 2.0 or EclipseLink orm (only latest supported)
Object[] context = determineXMLContextAndSchema(mappingFile, reader1, validateORMSchema);
XMLUnmarshaller unmarshaller = ((XMLContext) context[0]).createUnmarshaller();
if (validateORMSchema) {
useLocalSchemaForUnmarshaller(unmarshaller, ((Schema) context[1]));
}
xmlEntityMappings = (XMLEntityMappings) unmarshaller.unmarshal(reader2);
} catch (Exception exception) {
throw ValidationException.errorParsingMappingFile(mappingFile, exception);
}
if (xmlEntityMappings != null) {
xmlEntityMappings.setMappingFile(mappingFile);
}
return xmlEntityMappings;
}
use of org.eclipse.persistence.oxm.XMLContext in project eclipselink by eclipse-ee4j.
the class XMLEntityMappingsWriter method write.
/**
* 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);
}
}
use of org.eclipse.persistence.oxm.XMLContext in project eclipselink by eclipse-ee4j.
the class PersistenceXMLMappings method createXMLContext.
/**
* INTERNAL:
*/
protected static XMLContext createXMLContext(String namespaceURI) {
Project project = new Project();
NamespaceResolver resolver = new NamespaceResolver();
resolver.setDefaultNamespaceURI(namespaceURI);
project.addDescriptor(buildPersistenceXMLDescriptor(resolver));
project.addDescriptor(buildPUInfoDescriptor(resolver));
project.addDescriptor(buildPUPropertyDescriptor(resolver));
return new XMLContext(project);
}
use of org.eclipse.persistence.oxm.XMLContext in project eclipselink by eclipse-ee4j.
the class JAXBEnumTypeConverterTestCases method testConverterClassNotFound.
public void testConverterClassNotFound() throws Exception {
try {
Project proj = new JAXBEnumTypeConverterProject();
proj.convertClassNamesToClasses(this.getClass().getClassLoader());
XMLContext xmlContext = new XMLContext(proj);
} catch (ValidationException validationException) {
Throwable nestedException = validationException.getInternalException();
if (nestedException instanceof ClassNotFoundException) {
return;
}
}
fail("An ClassNotFoundException should have occurred.");
}
Aggregations