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 2017/02/06 13:19:18 UTC
svn commit: r1781896 -
/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java
Author: rec
Date: Mon Feb 6 13:19:18 2017
New Revision: 1781896
URL: http://svn.apache.org/viewvc?rev=1781896&view=rev
Log:
[UIMA-2903] List resources in a ResourceManager / remove hack in uimaFIT
- Go back to old reflection-based implementation so we are compatible with UIMA 2.9.0.
Modified:
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java
Modified: uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java?rev=1781896&r1=1781895&r2=1781896&view=diff
==============================================================================
--- uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java (original)
+++ uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ExternalResourceInitializer.java Mon Feb 6 13:19:18 2017
@@ -226,6 +226,32 @@ public final class ExternalResourceIniti
+ resMgr.getClass() + "]");
}
- return resMgr.getExternalResources();
+ // UIMA-2903 - List resources in a ResourceManager / remove hack in uimaFIT
+ // This is how we do it after upgrading to UIMA 2.10.0
+ // return resMgr.getExternalResources();
+
+ // For UIMA 2.9.0 and before, we need to do this
+ Field resourceMapField = null;
+ try {
+ // Fetch the list of resources
+ resourceMapField = ReflectionUtil.getField(resMgr, "mResourceMap");
+ resourceMapField.setAccessible(true);
+ @SuppressWarnings("unchecked")
+ Map<String, Object> resources = (Map<String, Object>) resourceMapField.get(resMgr);
+
+ return resources.values();
+ } catch (SecurityException e) {
+ throw new ResourceInitializationException(e);
+ } catch (NoSuchFieldException e) {
+ throw new ResourceInitializationException(e);
+ } catch (IllegalArgumentException e) {
+ throw new ResourceInitializationException(e);
+ } catch (IllegalAccessException e) {
+ throw new ResourceInitializationException(e);
+ } finally {
+ if (resourceMapField != null) {
+ resourceMapField.setAccessible(false);
+ }
+ }
}
}