You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2018/06/30 18:57:38 UTC
[uima-uimafit] 01/01: [UIMA-5805] No longer set extension
classloader in DefaultResourceManagerCreator
This is an automated email from the ASF dual-hosted git repository.
rec pushed a commit to branch feature/5805-do-not-set-extension-classloader-if-not-required
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git
commit 110733dda309fc5c023f2410d21cf10738131256
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Sat Jun 30 20:57:33 2018 +0200
[UIMA-5805] No longer set extension classloader in DefaultResourceManagerCreator
- If UIMA Core supports the context classloader, we do not need to set it on the resource manager.
---
.../uima/fit/internal/ResourceManagerFactory.java | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
index 0b64d32..8da8214 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/internal/ResourceManagerFactory.java
@@ -24,6 +24,7 @@ import org.apache.uima.UIMAFramework;
import org.apache.uima.UimaContext;
import org.apache.uima.UimaContextAdmin;
import org.apache.uima.UimaContextHolder;
+import org.apache.uima.impl.UimaVersion;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.ResourceManager;
import org.springframework.util.ClassUtils;
@@ -59,6 +60,7 @@ public class ResourceManagerFactory {
}
public static class DefaultResourceManagerCreator implements ResourceManagerCreator {
+ @Override
public ResourceManager newResourceManager() throws ResourceInitializationException {
try {
UimaContext activeContext = UimaContextHolder.getContext();
@@ -74,7 +76,20 @@ public class ResourceManagerFactory {
// UIMA core still does not fall back to the context classloader in all cases.
// This was the default behavior until uimaFIT 2.2.0.
ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
- resMgr.setExtensionClassPath(ClassUtils.getDefaultClassLoader(), "", true);
+
+ // Since UIMA Core version 2.10.3 and 3.0.1 the thread context classloader is taken
+ // into account by the core framework. Thus, we no longer have to explicitly set a
+ // classloader these or more recent versions. (cf. UIMA-5802)
+ short maj = UimaVersion.getMajorVersion();
+ short min = UimaVersion.getMinorVersion();
+ short rev = UimaVersion.getBuildRevision();
+ boolean uimaCoreIgnoresContextClassloader =
+ (maj == 2 && (min < 10 || (min == 10 && rev < 3))) || // version < 2.10.3
+ (maj == 3 && ((min == 0 && rev < 1))); // version < 3.0.1
+ if (uimaCoreIgnoresContextClassloader) {
+ resMgr.setExtensionClassPath(ClassUtils.getDefaultClassLoader(), "", true);
+ }
+
return resMgr;
}
}