// get installed pear root directory - specified as URI of the
// descriptor
File pearRootDir = new File(pearRootDirPath);
// create pear package browser to get the pear meta data
PackageBrowser pkgBrowser = new PackageBrowser(pearRootDir);
Properties systemProps = System.getProperties();
// get pear env variables and set them as system properties
Properties props = pkgBrowser.getComponentEnvVars();
for (Entry<Object, Object> entry : props.entrySet()) {
String key = (String) entry.getKey();
String value = (String) entry.getValue();
// log warning if system property already exist and does not have
// the same value
if (systemProps.containsKey(key)) {
String systemPropValue = (String) systemProps.get(key);
if (!systemPropValue.equals(value)) {
UIMAFramework.getLogger(this.getClass()).logrb(
Level.WARNING,
this.getClass().getName(),
"initialize",
LOG_RESOURCE_BUNDLE,
"UIMA_pear_runtime_system_var_already_set__WARNING",
new Object[] { (key + "=" + systemPropValue), (key + "=" + value),
pkgBrowser.getRootDirectory().getName() });
}
}
// set new system property
System.setProperty(key, value);
UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
"initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_set_system_var__CONFIG",
new Object[] { key + "=" + value, pkgBrowser.getRootDirectory().getName() });
}
// Caller's Resource Manager obtained from the additional parameters
// Note: UimaContext can be null for a top level call to
// produceAnalysisEngine,
// where the descriptor is a Pear Resource.
ResourceManager applicationRM = (aAdditionalParams == null) ? null
: (ResourceManager) aAdditionalParams.get(Resource.PARAM_RESOURCE_MANAGER);
if (null == applicationRM) {
UimaContextAdmin uimaContext = (aAdditionalParams == null) ? null
: (UimaContextAdmin) aAdditionalParams.get(Resource.PARAM_UIMA_CONTEXT);
if (null != uimaContext) {
applicationRM = uimaContext.getResourceManager();
}
}
String classPath = pkgBrowser.buildComponentRuntimeClassPath();
String dataPath = pkgBrowser.getComponentDataPath();
StringPair sp = new StringPair(classPath, dataPath);
ResourceManager innerRM;
synchronized (cachedResourceManagers) {
Map<StringPair, ResourceManager> c1 = cachedResourceManagers.get(applicationRM);
if (null == c1) {
innerRM = createRM(sp, pkgBrowser, applicationRM);
cachedResourceManagers.put(applicationRM, createRMmap(sp, innerRM));
} else {
innerRM = c1.get(sp);
if (null == innerRM) {
innerRM = createRM(sp, pkgBrowser, applicationRM);
c1.put(sp, innerRM);
UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
"initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_add_RM_map",
new Object[] { sp.classPath, sp.dataPath });
}
}
}
// Create an XML input source from the specifier file
XMLInputSource in = new XMLInputSource(pkgBrowser.getInstallationDescriptor()
.getMainComponentDesc());
// Parse the resource specifier
ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);