Package org.eclipse.osgi.service.runnable

Examples of org.eclipse.osgi.service.runnable.ApplicationLauncher


  public void frameworkStopping(BundleContext context) {
    // Shutdown the ApplicationLauncher service if it is available.
    ServiceReference launcherRef = context.getServiceReference(ApplicationLauncher.class.getName());
    if (launcherRef != null) {
      ApplicationLauncher launcher = (ApplicationLauncher) context.getService(launcherRef);
      // this will force a currently running application to stop.
      launcher.shutdown();
      context.ungetService(launcherRef);
    }
  }
View Full Code Here


    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);
      }
    }
  }
View Full Code Here

    }
    return null;
  }

  public Object addingService(ServiceReference reference) {
    ApplicationLauncher appLauncher;
    ParameterizedRunnable appRunnable;
    synchronized (this) {
      appLauncher = (ApplicationLauncher) context.getService(reference);
      // see if there is a default main threaded application waiting to run
      appRunnable = defaultMainThreadAppHandle;
      // null out so we do not attempt to start this handle again
      defaultMainThreadAppHandle = null;
    }
    if (appRunnable != null)
      // found a main threaded app; start it now that the app launcher is available
      appLauncher.launch(appRunnable, appRunnable instanceof EclipseAppHandle ? ((EclipseAppHandle) appRunnable).getArguments().get(IApplicationContext.APPLICATION_ARGS) : null);
    return appLauncher;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.osgi.service.runnable.ApplicationLauncher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.