private String cachedRMclassPath = null;
private SoftReference<UIMAClassLoader> cachedRMcl = new SoftReference<UIMAClassLoader>(null);
public ResourceManager createResourceManager(String classPath) {
ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
try {
if (null == classPath) {
classPath = getProjectClassPath();
}
String dataPath = CDEpropertyPage.getDataPath(getProject());
// first try to get the value of the class loader from the last (cached)
// value - should succeed frequently because the class loader is only dependent
// on the value of the classpath
UIMAClassLoader uimaCL = null;
if (cachedRMclassPath != null &&
cachedRMclassPath.equals(classPath)) {
uimaCL = cachedRMcl.get();
}
if (uimaCL != null) {
((ResourceManager_impl)resourceManager).setExtensionClassPath(uimaCL, true);
} else {
// first arg in next is the parent of the class loader. Make it be the
// uima framework's class loader (not this class's class loader)
// so the validation tests work properly (that test isAssignableFrom)
resourceManager.setExtensionClassPath(UIMAFramework.class.getClassLoader(), classPath, true);
cachedRMclassPath = classPath;
cachedRMcl = new SoftReference<UIMAClassLoader>((UIMAClassLoader) resourceManager.getExtensionClassLoader());
}
// in any case, set the data path
resourceManager.setDataPath(dataPath);
} catch (MalformedURLException e1) {
throw new InternalErrorCDE(Messages.getString("MultiPageEditor.14"), e1); //$NON-NLS-1$
} catch (CoreException e1) {
throw new InternalErrorCDE(Messages.getString("MultiPageEditor.15"), e1); //$NON-NLS-1$
}