use of org.eclipse.birt.core.exception.BirtException in project head by mifos.
the class OSGILauncher method doStartup.
private void doStartup(PlatformConfig config) throws BirtException {
if (frameworkClassLoader != null) {
//$NON-NLS-1$
logger.log(Level.WARNING, "Framework is already started");
return;
}
platformConfig = config;
IPlatformContext context = config.getPlatformContext();
if (context == null) {
throw new FrameworkException("PlatformContext is not setted - {0}", //$NON-NLS-1$
new Object[] { "PlatformConfig" });
}
// process install.area
String root = context.getPlatform();
platformDirectory = new File(root);
if (!platformDirectory.exists() || !platformDirectory.isDirectory()) {
throw new FrameworkException("Framework {0} doesn't exist or is not a directory", //$NON-NLS-1$
new Object[] { root });
}
//$NON-NLS-1$
String path = new File(platformDirectory, "plugins").toString();
//$NON-NLS-1$
path = searchFor("org.eclipse.osgi", path);
if (path == null) {
throw new FrameworkException("Could not find the Framework - {0}", //$NON-NLS-1$
new Object[] { "org.eclipse.osgi" });
}
try {
osgiFramework = new File(path).toURI().toURL();
} catch (MalformedURLException ex) {
//cannot be here
}
ClassLoader original = Thread.currentThread().getContextClassLoader();
try {
ClassLoader loader = this.getClass().getClassLoader();
frameworkClassLoader = new ChildFirstURLClassLoader(new URL[] { osgiFramework }, loader);
// load the class explicitly.
try {
loader.loadClass("org.mozilla.javascript.Context");
loader.loadClass("org.mozilla.javascript.Scriptable");
loader.loadClass("org.mozilla.javascript.ScriptableObject");
// frameworkClassLoader.loadClass(
// "org.mozilla.javascript.Context"
} catch (Exception ex) {
}
Class clazz = frameworkClassLoader.loadClass(ECLIPSE_STARTER);
setupOSGiProperties();
setupSecurityPolicy();
Method initPropertiesMethod = clazz.getMethod("setInitialProperties", //$NON-NLS-1$
new Class[] { Map.class });
if (initPropertiesMethod != null) {
System.setProperty("osgi.framework.useSystemProperties", //$NON-NLS-1$ //$NON-NLS-2$
"false");
properties.put("osgi.framework.useSystemProperties", "false");
initPropertiesMethod.invoke(null, new Object[] { properties });
} else {
Iterator iter = properties.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
System.setProperty(key, value);
}
System.setProperty("osgi.framework.useSystemProperties", //$NON-NLS-1$ //$NON-NLS-2$
"true");
}
Method runMethod = clazz.getMethod("startup", //$NON-NLS-1$
new Class[] { String[].class, Runnable.class });
bundleContext = runMethod.invoke(null, new Object[] { new String[] {}, null });
frameworkContextClassLoader = Thread.currentThread().getContextClassLoader();
} catch (BirtException be) {
throw be;
} catch (Exception e) {
throw new FrameworkException("Can not start up OSGI - {0}", new Object[] { e.getMessage() }, e);
} finally {
Thread.currentThread().setContextClassLoader(original);
}
}
Aggregations