use of org.eclipse.jdt.launching.IVMRunner in project webtools.servertools by eclipse.
the class GenericServerLaunchConfigurationDelegate method launch.
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
*/
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
IServer server = ServerUtil.getServer(configuration);
if (server == null) {
abort(GenericServerCoreMessages.missingServer, null, IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
// Commented until bug 210859 is resolved
// if (server.shouldPublish() && ServerCore.isAutoPublishing())
// server.publish(IServer.PUBLISH_INCREMENTAL, monitor);
@SuppressWarnings("null") GenericServerBehaviour genericServer = (GenericServerBehaviour) server.loadAdapter(ServerBehaviourDelegate.class, null);
try {
genericServer.setupLaunch(launch, mode, monitor);
if (genericServer.getServer().getServerType().supportsRemoteHosts() && !SocketUtil.isLocalhost(genericServer.getServer().getHost())) {
// no launch for remote servers
return;
}
String mainTypeName = genericServer.getStartClassName();
IVMInstall vm = verifyVMInstall(configuration);
IVMRunner runner = vm.getVMRunner(mode);
if (runner == null && ILaunchManager.PROFILE_MODE.equals(mode)) {
runner = vm.getVMRunner(ILaunchManager.RUN_MODE);
}
if (runner == null) {
throw new CoreException(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, GenericServerCoreMessages.runModeNotSupported, null));
}
File workingDir = verifyWorkingDirectory(configuration);
String workingDirName = null;
if (workingDir != null)
workingDirName = workingDir.getAbsolutePath();
// Program & VM args
String pgmArgs = getProgramArguments(configuration);
String vmArgs = getVMArguments(configuration);
String[] envp = getEnvironment(configuration);
ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
// VM-specific attributes
Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
// Classpath
String[] classpath = getClasspath(configuration);
// Create VM config
VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
runConfig.setVMArguments(execArgs.getVMArgumentsArray());
runConfig.setWorkingDirectory(workingDirName);
runConfig.setEnvironment(envp);
runConfig.setVMSpecificAttributesMap(vmAttributesMap);
// Bootpath
String[] bootpath = getBootpath(configuration);
if (bootpath != null && bootpath.length > 0)
runConfig.setBootClassPath(bootpath);
setDefaultSourceLocator(launch, configuration);
if (ILaunchManager.PROFILE_MODE.equals(mode)) {
try {
ServerProfilerDelegate.configureProfiling(launch, vm, runConfig, monitor);
} catch (CoreException ce) {
genericServer.stopImpl();
throw ce;
}
}
// Launch the configuration
genericServer.startPingThread();
runner.run(runConfig, launch, monitor);
genericServer.setProcess(launch.getProcesses()[0]);
} catch (CoreException e) {
// $NON-NLS-1$
Trace.trace(Trace.SEVERE, "error launching generic server", e);
genericServer.terminate();
throw e;
}
}
use of org.eclipse.jdt.launching.IVMRunner in project liferay-ide by liferay.
the class PortalServerLaunchConfigDelegate method launchServer.
private void launchServer(final IServer server, final ILaunchConfiguration config, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
final IVMInstall vm = verifyVMInstall(config);
final IVMRunner runner = vm.getVMRunner(mode) != null ? vm.getVMRunner(mode) : vm.getVMRunner(ILaunchManager.RUN_MODE);
final File workingDir = verifyWorkingDirectory(config);
final String workingDirPath = workingDir != null ? workingDir.getAbsolutePath() : null;
final String progArgs = getProgramArguments(config);
final String vmArgs = getVMArguments(config);
final String[] envp = getEnvironment(config);
final ExecutionArguments execArgs = new ExecutionArguments(vmArgs, progArgs);
final Map<String, Object> vmAttributesMap = getVMSpecificAttributesMap(config);
final PortalServerBehavior portalServer = (PortalServerBehavior) server.loadAdapter(PortalServerBehavior.class, monitor);
final String classToLaunch = portalServer.getClassToLaunch();
final String[] classpath = getClasspath(config);
final VMRunnerConfiguration runConfig = new VMRunnerConfiguration(classToLaunch, classpath);
runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
runConfig.setVMArguments(execArgs.getVMArgumentsArray());
runConfig.setWorkingDirectory(workingDirPath);
runConfig.setEnvironment(envp);
runConfig.setVMSpecificAttributesMap(vmAttributesMap);
final String[] bootpath = getBootpath(config);
if (ListUtil.isNotEmpty(bootpath)) {
runConfig.setBootClassPath(bootpath);
}
portalServer.launchServer(launch, mode, monitor);
server.addServerListener(new IServerListener() {
@Override
public void serverChanged(ServerEvent event) {
if ((event.getKind() & ServerEvent.MODULE_CHANGE) > 0) {
AbstractSourceLookupDirector sourceLocator = (AbstractSourceLookupDirector) launch.getSourceLocator();
try {
final String memento = config.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String) null);
if (memento != null) {
sourceLocator.initializeFromMemento(memento);
} else {
sourceLocator.initializeDefaults(config);
}
} catch (CoreException e) {
LiferayServerCore.logError("Could not reinitialize source lookup director", e);
}
} else if ((event.getKind() & ServerEvent.SERVER_CHANGE) > 0 && event.getState() == IServer.STATE_STOPPED) {
server.removeServerListener(this);
}
}
});
try {
runner.run(runConfig, launch, monitor);
portalServer.addProcessListener(launch.getProcesses()[0]);
} catch (Exception e) {
portalServer.cleanup();
}
}
use of org.eclipse.jdt.launching.IVMRunner in project mdw-designer by CenturyLinkCloud.
the class CucumberLaunchConfiguration method launch.
@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
String folderPath = config.getAttribute(FOLDER, "");
List<String> featurePaths = config.getAttribute(FEATURES, new ArrayList<String>());
IVMInstall vm = verifyVMInstall(config);
IVMRunner runner = vm.getVMRunner(mode);
String[] classpath = getClasspath(config);
VMRunnerConfiguration runConfig = new VMRunnerConfiguration(CUCUMBER_CLI_MAIN, classpath);
verifyWorkingDirectory(config);
String[] bootpath = getBootpath(config);
runConfig.setBootClassPath(bootpath);
List<String> vmArgs = PluginUtil.arrayToList(DebugPlugin.parseArguments(getVMArguments(config)));
// TODO: add debug args based on mode?
StringBuilder featuresArg = new StringBuilder("-Dcucumber.options=");
for (int i = 0; i < featurePaths.size(); i++) {
String featurePath = featurePaths.get(i);
featuresArg.append(folderPath.isEmpty() ? featurePath : (folderPath + "/" + featurePath));
if (i < featurePaths.size() - 1)
featuresArg.append(" ");
}
vmArgs.add(featuresArg.toString());
runConfig.setVMArguments(vmArgs.toArray(new String[0]));
runConfig.setWorkingDirectory(getWorkingDirectory(config).getAbsolutePath());
List<String> args = PluginUtil.arrayToList(DebugPlugin.parseArguments(getProgramArguments(config)));
args.add("--glue");
args.add(config.getAttribute(GLUE, DEFAULT_GLUE));
runConfig.setProgramArguments(args.toArray(new String[0]));
runner.run(runConfig, launch, monitor);
}
use of org.eclipse.jdt.launching.IVMRunner in project mdw-designer by CenturyLinkCloud.
the class CucumberTestLaunchConfiguration method launch.
@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
IVMInstall vm = verifyVMInstall(config);
IVMRunner runner = vm.getVMRunner(mode);
String[] classpath = getClasspath(config);
VMRunnerConfiguration runConfig = new VMRunnerConfiguration(CUCUMBER_CLI_MAIN, classpath);
verifyWorkingDirectory(config);
String[] bootpath = getBootpath(config);
runConfig.setBootClassPath(bootpath);
runConfig.setVMArguments(DebugPlugin.parseArguments(getVMArguments(config)));
runConfig.setWorkingDirectory(getWorkingDirectory(config).getAbsolutePath());
String[] args = DebugPlugin.parseArguments(getProgramArguments(config));
runConfig.setProgramArguments(args);
runner.run(runConfig, launch, monitor);
}
use of org.eclipse.jdt.launching.IVMRunner in project ow by vtst.
the class EasyJavaProgramLaunchConfigurationDelegate method launch.
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
Fixture fixture = getFixture(config);
if (monitor == null)
monitor = new NullProgressMonitor();
monitor.beginTask(config.getName() + "...", 3);
if (monitor.isCanceled())
return;
try {
monitor.subTask(messages.getString("verifying_launch_attributes"));
String mainTypeName = verifyMainTypeName(config);
IVMRunner runner = getVMRunner(config, mode);
File workingDir = verifyWorkingDirectory(config);
String workingDirName = null;
if (workingDir != null) {
workingDirName = workingDir.getAbsolutePath();
}
// Environment variables
String[] envp = getEnvironment(config);
// VM-specific attributes
@SuppressWarnings("unchecked") Map<String, Object> vmAttributesMap = getVMSpecificAttributesMap(config);
// Classpath
String[] classpath = getClasspath(config);
// Create VM config
VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
runConfig.setProgramArguments(getProgramArgumentsArray(config, fixture));
runConfig.setEnvironment(envp);
runConfig.setVMArguments(getVMArgumentsArray(config, fixture));
runConfig.setWorkingDirectory(workingDirName);
runConfig.setVMSpecificAttributesMap(vmAttributesMap);
// Bootpath
runConfig.setBootClassPath(getBootpath(config));
// check for cancellation
if (monitor.isCanceled()) {
return;
}
// stop in main
prepareStopInMain(config);
// done the verification phase
monitor.worked(1);
monitor.subTask(messages.getString("creating_source_locator"));
// set the source locator if required
setDefaultSourceLocator(launch, config);
monitor.worked(1);
// Launch the configuration - 1 unit of work
monitor.subTask(messages.getString("run_external_program"));
runner.run(runConfig, launch, monitor);
for (IProcess process : launch.getProcesses()) {
addProcessListeners(config, fixture, new EasyLaunchConfigurationDelegateUtils.ProcessListernerAcceptorImpl(process));
}
// check for cancellation
if (monitor.isCanceled())
return;
} finally {
monitor.done();
}
}
Aggregations