private void launchConfiguration() {
    try {
      ILaunch launch = launchConfig.launch(mode, null);
      if (launch.canTerminate()) {
        while (!launch.isTerminated()) {
          Thread.sleep(100);
        }
      }
    } catch (CoreException e) {
      BPCLIPreferences.logError("Error encountered during launch of " + launchConfig.getName(), e);
    } catch (InterruptedException e) {
      BPCLIPreferences.logError("Could not sleep execution thread", e);
    } finally {
      System.out.println("Execution complete.  Exiting.");
      // Unless running in debug exit after the build
      if (!debug) {
        PlatformUI.getWorkbench()
            .getDisplay()
            .asyncExec(
                new Runnable() {

                  @Override
                  public void run() {
                    PlatformUI.getWorkbench().close();
                  }
                });
      }
    }
  }
示例#2
0
 private ILaunch launchPeer(final BackendData data) {
   final ILaunchConfiguration launchConfig = data.asLaunchConfiguration();
   try {
     final boolean registerForDebug =
         data.getLaunch() != null || SystemConfiguration.getInstance().isDeveloper();
     return launchConfig.launch(
         ILaunchManager.RUN_MODE, new NullProgressMonitor(), false, registerForDebug);
   } catch (final CoreException e) {
     ErlLogger.error(e);
     return null;
   }
 }
  private void launch(String pName, String fName, String mode) {
    try {
      ILaunchConfiguration found = null;
      ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
      ILaunchConfigurationType lct =
          lm.getLaunchConfigurationType(GoLaunchConfigurationDelegate.ID);
      ILaunchConfiguration[] lcfgs = lm.getLaunchConfigurations(lct);

      for (ILaunchConfiguration lcf : lcfgs) {
        String project = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_PROJECT, "");
        String mainfile = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_MAIN, "");
        String prgArgs = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_ARGS, "");

        if (prgArgs.isEmpty()) {
          // this is an empty run, no params, don't mix with already
          // definded with params
          if (project.equalsIgnoreCase(pName)
              && Path.fromOSString(fName).equals(Path.fromOSString(mainfile))) {
            found = lcf;
            break;
          }
        }
      }

      if (found == null) {
        // create a new launch configuration
        String cfgName = lm.generateLaunchConfigurationName(Path.fromOSString(fName).lastSegment());
        ILaunchConfigurationWorkingCopy workingCopy = lct.newInstance(null, cfgName);
        workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_PROJECT, pName);
        workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_MAIN, fName);
        workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_ARGS, "");
        workingCopy.setAttribute(
            GoConstants.GO_CONF_ATTRIBUTE_BUILD_CONFIG, BuildConfiguration.RELEASE.toString());
        workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
        workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, "UTF-8");

        found = workingCopy.doSave();
      }

      if (found != null) {
        found.launch(mode, null, true, true);
      }
    } catch (CoreException ce) {
      Activator.logError(ce);
    }
  }
示例#4
0
  public static boolean deployModel(
      List<IResource> resources, String carnotHome, String carnotWork) {
    boolean deployed = false;

    if (null != resources && !resources.isEmpty()) {
      try {
        IProject project = getCommonProject(resources);
        ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType type =
            manager.getLaunchConfigurationType(
                IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
        ILaunchConfigurationWorkingCopy wc =
            type.newInstance(null, "Infinity Process Model Deployment"); // $NON-NLS-1$
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
        wc.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
            ModelingCoreActivator.ID_DEPLOY_MODEL_CP_PROVIDER);
        wc.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
            ModelDeploymentTool.class.getName());
        // Activate if debugging deployment is needed.
        // String debug =
        // " -Xdebug -Xnoagent -Djava.compiler=NONE
        // -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000";
        // String debug =
        // " -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000";
        wc.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
            "-Xms50m -Xmx256m" + getLocaleArgs()); // $NON-NLS-1$
        // "-Xms50m -Xmx256m" + debug);

        boolean version =
            PlatformUI.getPreferenceStore().getBoolean(BpmProjectNature.PREFERENCE_DEPLOY_version);

        String realm =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_realm);
        String partition =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_partition);
        String user =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_id);
        String password =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_password);
        String domain =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_domain);

        StringBuilder programAttributes = new StringBuilder();
        boolean separator = false;
        for (IResource resource : resources) {
          // addArgument(programAttributes, "filename64", resource.getLocation().toOSString(), true,
          // separator);
          // separator = true;
          try {
            String fileName = resource.getLocation().toOSString();
            String encodedFileName =
                new String(Base64.encode(fileName.getBytes(XpdlUtils.UTF8_ENCODING)));
            addArgument(
                programAttributes, "filename64", encodedFileName, false, separator); // $NON-NLS-1$
            separator = true;
          } catch (UnsupportedEncodingException e) {
            // should never happen since UTF-8 is standard supported on all java versions.
            e.printStackTrace();
          }
        }
        if (version) {
          addArgument(
              programAttributes,
              "version",
              Boolean.TRUE.toString(),
              false,
              true); //$NON-NLS-1$ //$NON-NLS-2$
        }

        if (!StringUtils.isEmpty(user) && !StringUtils.isEmpty(password)) {
          addArgument(programAttributes, "user", user, true, true); // $NON-NLS-1$
          addArgument(
              programAttributes, "password", password, true, true); // $NON-NLS-1$

          if (!StringUtils.isEmpty(realm)) {
            addArgument(programAttributes, "realm", realm, true, true); // $NON-NLS-1$
          }

          if (!StringUtils.isEmpty(partition)) {
            addArgument(
                programAttributes, "partition", partition, true, true); // $NON-NLS-1$
          }

          if (!StringUtils.isEmpty(domain)) {
            addArgument(programAttributes, "domain", domain, true, true); // $NON-NLS-1$
          }
        }

        wc.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programAttributes.toString());

        wc.setAttribute(CarnotToolClasspathProvider.ATTR_HOME_LOCATION, carnotHome);
        wc.setAttribute(CarnotToolClasspathProvider.ATTR_WORK_LOCATION, carnotWork);

        wc.setAttribute(
            CarnotToolClasspathProvider.ATTR_EXTRA_LOCATION,
            BpmCoreLibrariesClasspathContainer.getLibraryLocation(
                    DeployPlugin.PLUGIN_ID, new String[] {"bin", ""})
                .toString()); //$NON-NLS-1$ //$NON-NLS-2$

        ILaunchConfiguration config = wc.doSave();
        ILaunch toolLaunch = config.launch(ILaunchManager.RUN_MODE, null);

        deployed = (0 < toolLaunch.getProcesses().length);

        config.delete();
        wc.delete();
      } catch (CoreException e) {
        // TODO
        e.printStackTrace();
      }
    }
    return deployed;
  }
 private void doLaunch(final String mode, final Collection<IErlProject> projects)
     throws CoreException {
   final ILaunchConfiguration launchConfiguration = getLaunchConfiguration(projects, mode);
   bringConsoleViewToFront();
   launchConfiguration.launch(mode, null);
 }
 private void launch(
     ILaunchConfiguration lc, String mode, IProgressMonitor monitor, boolean shouldBeLaunched)
     throws CoreException {
   if (!shouldBeLaunched) return;
   lc.launch(mode, monitor);
 }