// if this is a local resource (instantiated from a ResourceCreationSpecifier),
// initialize the ResourceManager and UIMA Context.
if (aSpecifier instanceof ResourceCreationSpecifier) {
// resolve imports in the metadata
ResourceMetaData metadata = ((ResourceCreationSpecifier) aSpecifier).getMetaData();
name = metadata.getName();
try {
metadata.resolveImports(getResourceManager());
} catch (InvalidXMLException e) {
throw new ResourceInitializationException(e);
}
// store Resource metadata so it can be retrieved via getMetaData() method
setMetaData(metadata);
// Check if a Settings object for the external overrides has been provided in the additional
// parameters map. If not and not already set from the parent UimaContext then create one
// (for the root context) from the system defaults
Settings externalOverrides = aAdditionalParams == null ? null :
(Settings) aAdditionalParams.get(Resource.PARAM_EXTERNAL_OVERRIDE_SETTINGS);
if (externalOverrides != null) {
mUimaContextAdmin.setExternalOverrides(externalOverrides);
} else {
if (mUimaContextAdmin.getExternalOverrides() == null) {
externalOverrides = new Settings_impl();
try {
externalOverrides.loadSystemDefaults();
} catch (ResourceConfigurationException e) {
throw new ResourceInitializationException(ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR,
new Object[] { name, metadata.getSourceUrlString() }, e);
}
mUimaContextAdmin.setExternalOverrides(externalOverrides);
}
}
// initialize configuration
try {
mUimaContextAdmin.getConfigurationManager().createContext(
mUimaContextAdmin.getQualifiedContextName(), getMetaData(), mUimaContextAdmin.getExternalOverrides());
mUimaContextAdmin.getConfigurationManager().setSession(mUimaContextAdmin.getSession());
} catch (ResourceConfigurationException e) {
throw new ResourceInitializationException(
ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] {
name, metadata.getSourceUrlString() }, e);
}
// initialize any external resource declared in this descriptor
ResourceManagerConfiguration resMgrCfg = ((ResourceCreationSpecifier) aSpecifier)
.getResourceManagerConfiguration();