try {
// 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);
// get pear env variables and set them as system properties
Properties props = pkgBrowser.getComponentEnvVars();
Iterator keyIterator = props.keySet().iterator();
Properties systemProps = System.getProperties();
while (keyIterator.hasNext()) {
String key = (String) keyIterator.next();
String value = (String) props.get(key);
// 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() });
}
ResourceManager applicationRM = this.getResourceManager();
String classPath = pkgBrowser.buildComponentClassPath();
String dataPath = pkgBrowser.getComponentDataPath();
StringPair sp = new StringPair(classPath, dataPath);
ResourceManager innerRM;
Map c1 = (Map)cachedResourceManagers.get(applicationRM);
if (null == c1) {
innerRM = createRM(sp, pkgBrowser);
cachedResourceManagers.put(applicationRM, createRMmap(sp, innerRM));
} else {
innerRM = (ResourceManager)c1.get(sp);
if (null == innerRM) {
innerRM = createRM(sp, pkgBrowser);
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);