lock(appHandle);
boolean isDefault = appHandle.isDefault();
if (((EclipseAppDescriptor) appHandle.getApplicationDescriptor()).getThreadType() == EclipseAppDescriptor.FLAG_TYPE_MAIN_THREAD) {
// use the ApplicationLauncher provided by the framework to ensure it is launched on the main thread
DefaultApplicationListener curDefaultApplicationListener = null;
ApplicationLauncher appLauncher = null;
synchronized (this) {
appLauncher = (ApplicationLauncher) launcherTracker.getService();
if (appLauncher == null) {
if (isDefault) {
// we need to wait to allow the ApplicationLauncher to get registered;
// save the handle to be launched as soon as the ApplicationLauncher is available
defaultMainThreadAppHandle = appHandle;
return;
}
throw new ApplicationException(ApplicationException.APPLICATION_INTERNAL_ERROR);
}
curDefaultApplicationListener = defaultAppListener;
}
if (curDefaultApplicationListener != null)
curDefaultApplicationListener.launch(appHandle);
else
appLauncher.launch(appHandle, appHandle.getArguments().get(IApplicationContext.APPLICATION_ARGS));
} else {
AnyThreadAppLauncher.launchEclipseApplication(appHandle);
DefaultApplicationListener curDefaultApplicationListener = null;
if (isDefault) {
ApplicationLauncher appLauncher = null;
synchronized (this) {
appLauncher = (ApplicationLauncher) launcherTracker.getService();
if (defaultAppListener == null)
defaultAppListener = new DefaultApplicationListener(appHandle);
curDefaultApplicationListener = defaultAppListener;
if (appLauncher == null) {
// we need to wait to allow the ApplicationLauncher to get registered;
// save the default app listener to be launched as soon as the ApplicationLauncher is available
defaultMainThreadAppHandle = curDefaultApplicationListener;
return;
}
}
appLauncher.launch(curDefaultApplicationListener, null);
}
}
}