}
}
// try to instantiate the resource
Resource resource = null;
Map<String, Object> prParams = new HashMap<String, Object>();
if (aResourceManager != null) {
prParams.put(Resource.PARAM_RESOURCE_MANAGER, aResourceManager);
}
prParams.put(AnalysisEngineImplBase.PARAM_VERIFICATION_MODE, Boolean.TRUE);
try {
resource = UIMAFramework.produceResource((ResourceSpecifier) current, prParams);
// (null == aResourceManager) ? Collections.<String, Object>emptyMap() : resourceMgrInMap);
} catch (Exception e) {
// record failure, so we don't ask for this again, for a while
synchronized (metaDataCache) {
if (cacheDebug) {
System.err.format("GetMetaDataCache: saving entry in cache%n");
}
metaDataCache.put(metaDataCacheKey, new MetaDataCacheEntry(null));
}
// failed. If aOutputFailedRemotes is non-null, add an entry to it to it, else throw the
// exception.
if (aOutputFailedRemotes != null) {
aOutputFailedRemotes.put(aContextName, e);
} else {
if (e instanceof ResourceInitializationException)
throw (ResourceInitializationException) e;
else if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new RuntimeException(e);
}
}
ResourceMetaData metadata = (resource == null) ? null : resource.getMetaData();
synchronized (metaDataCache) {
if (cacheDebug) {
System.err.format("GetMetaDataCache: saving entry in cache%n");
}
metaDataCache.put(metaDataCacheKey, new MetaDataCacheEntry(metadata));
}
if (resource != null) {
if (metadata instanceof ProcessingResourceMetaData) {
mdList.add((ProcessingResourceMetaData) metadata);
}
resource.destroy();
}
} else {
throw new ResourceInitializationException(
ResourceInitializationException.UNSUPPORTED_OBJECT_TYPE_IN_CREATE_CAS,
new Object[] { current.getClass().getName() });