use of org.eclipse.persistence.sdo.helper.SDOClassLoader in project eclipselink by eclipse-ee4j.
the class SDOType method getInstanceClass.
@Override
public Class<?> getInstanceClass() {
if ((javaClass == null) && (javaClassName != null)) {
try {
SDOClassLoader loader = ((SDOXMLHelper) aHelperContext.getXMLHelper()).getLoader();
Class<?> clazz = loader.getParent().loadClass(javaClassName);
if (isValidInstanceClass(clazz)) {
javaClass = clazz;
} else {
javaClass = getClass();
}
} catch (ClassNotFoundException e) {
javaClass = getClass();
} catch (SecurityException e) {
throw SDOException.classNotFound(e, getURI(), getName());
}
}
if (javaClass == getClass()) {
return null;
}
return javaClass;
}
use of org.eclipse.persistence.sdo.helper.SDOClassLoader in project eclipselink by eclipse-ee4j.
the class SDOType method getImplClass.
/**
* INTERNAL:
*/
public Class<?> getImplClass() {
if ((javaImplClass == null) && (getImplClassName() != null)) {
try {
SDOClassLoader loader = ((SDOXMLHelper) aHelperContext.getXMLHelper()).getLoader();
javaImplClass = loader.loadClass(getImplClassName(), this);
xmlDescriptor.setJavaClass(javaImplClass);
} catch (ClassNotFoundException e) {
throw SDOException.classNotFound(e, getURI(), getName());
} catch (SecurityException e) {
throw SDOException.classNotFound(e, getURI(), getName());
}
}
return javaImplClass;
}
use of org.eclipse.persistence.sdo.helper.SDOClassLoader in project eclipselink by eclipse-ee4j.
the class SDOXMLHelperDelegate method reset.
@Override
public void reset() {
setTopLinkProject(null);
setXmlContext(null);
this.xmlMarshallerMap.clear();
this.xmlUnmarshallerMap.clear();
setLoader(new SDOClassLoader(getClass().getClassLoader(), aHelperContext));
}
use of org.eclipse.persistence.sdo.helper.SDOClassLoader in project eclipselink by eclipse-ee4j.
the class LoadAndSaveTestCases method testClassGenerationLoadAndSave.
public void testClassGenerationLoadAndSave() throws Exception {
// TODO: hard coded path should be parameterized as an option to the test suite
String tmpDirName = tempFileDir + "/tmp/";
File f = new File(tmpDirName);
f.mkdir();
f.deleteOnExit();
generateClasses(tmpDirName);
setUp();
compileFiles(tmpDirName, getPackages());
URL[] urls = new URL[1];
urls[0] = f.toURI().toURL();
URLClassLoader myURLLoader = new URLClassLoader(urls);
String package1 = getPackages().get(0);
String className = package1 + "/" + getRootInterfaceName();
className = className.replaceAll("/", ".");
Class<?> urlLoadedClass = myURLLoader.loadClass(className);
((SDOXMLHelper) xmlHelper).setLoader(new SDOClassLoader(myURLLoader, aHelperContext));
Class<?> loadedClass2 = ((SDOXMLHelper) xmlHelper).getLoader().loadClass(className);
defineTypes();
assertEquals(urlLoadedClass, loadedClass2);
FileInputStream inputStream = new FileInputStream(getControlFileName());
XMLDocument document = xmlHelper.load(inputStream);
Class<?> loadedClass = document.getRootObject().getType().getInstanceClass();
assertEquals(urlLoadedClass, loadedClass);
verifyAfterLoad(document);
StringWriter writer = new StringWriter();
xmlHelper.save(document, writer, null);
compareXML(getControlWriteFileName(), writer.toString());
}
Aggregations