@After public void tearDown() throws CoreException { ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); if (launches.size() > 0) { lm.removeLaunches(launches.toArray(new ILaunch[launches.size()])); launches.clear(); } // Delete the Launch Configurations ILaunchConfiguration[] configs = lm.getLaunchConfigurations(); for (ILaunchConfiguration config : configs) { config.delete(); } }
/** cli Comment method "removeJobLaunch". */ public static void removeJobLaunch(IRepositoryViewObject objToDelete) { if (objToDelete == null) { return; } Property property = objToDelete.getProperty(); if (property == null || !(property.getItem() instanceof ProcessItem)) { return; } Project project = ProjectManager.getInstance().getProject(property); if (project == null) { return; } final String objProjectName = project.getLabel(); final String objId = property.getId(); // final String objName = property.getLabel(); final String objVersion = property.getVersion(); ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); if (launchManager == null) { return; } try { ILaunchConfiguration configuration = null; for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) { String jobId = config.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null); // String jobName = configuration.getAttribute(TalendDebugUIConstants.JOB_NAME, (String) // null); String jobVersion = config.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null); String projectName = config.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null); ILaunchConfigurationType type = config.getType(); if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals( type.getIdentifier()) && objProjectName.equals(projectName) && objId.equals(jobId) && objVersion.equals(jobVersion)) { configuration = config; break; } } if (configuration == null) { return; } configuration.delete(); } catch (CoreException e) { // nothing to do } }
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; }