use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class TomcatLaunchConfigurationDelegate method launch.
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
IServer server = ServerUtil.getServer(configuration);
if (server == null) {
Trace.trace(Trace.FINEST, "Launch configuration could not find server");
// throw CoreException();
return;
}
if (server.shouldPublish() && ServerCore.isAutoPublishing())
server.publish(IServer.PUBLISH_INCREMENTAL, monitor);
TomcatServerBehaviour tomcatServer = (TomcatServerBehaviour) server.loadAdapter(TomcatServerBehaviour.class, null);
String mainTypeName = tomcatServer.getRuntimeClass();
IVMInstall vm = verifyVMInstall(configuration);
IVMRunner runner = vm.getVMRunner(mode);
if (runner == null)
runner = vm.getVMRunner(ILaunchManager.RUN_MODE);
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) {
tomcatServer.stopImpl();
throw ce;
}
}
// Launch the configuration
tomcatServer.setupLaunch(launch, mode, monitor);
try {
runner.run(runConfig, launch, monitor);
tomcatServer.addProcessListener(launch.getProcesses()[0]);
} catch (Exception e) {
// Ensure we don't continue to think the server is starting
tomcatServer.stopImpl();
}
}
use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class PreviewSourcePathComputerDelegate method computeSourceContainers.
/* (non-Javadoc)
* @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
*/
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
List<IRuntimeClasspathEntry> classpaths = new ArrayList<IRuntimeClasspathEntry>();
classpaths.addAll(Arrays.asList(JavaRuntime.computeUnresolvedSourceLookupPath(configuration)));
List<ISourceContainer> sourcefolderList = new ArrayList<ISourceContainer>();
IServer server = ServerUtil.getServer(configuration);
if (server != null) {
List<IJavaProject> list = new ArrayList<IJavaProject>();
IModule[] modules = server.getModules();
for (IModule module : modules) {
IProject project = module.getProject();
if (project != null) {
IFolder moduleFolder = project.getFolder(module.getName());
if (moduleFolder.exists()) {
sourcefolderList.add(new FolderSourceContainer(moduleFolder, true));
}
try {
if (project.hasNature(JavaCore.NATURE_ID)) {
IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
if (!list.contains(javaProject))
list.add(javaProject);
}
} catch (Exception e) {
// ignore
}
}
}
int size = list.size();
IJavaProject[] projects = new IJavaProject[size];
list.toArray(projects);
for (IJavaProject project : projects) classpaths.addAll(Arrays.asList(JavaRuntime.computeUnresolvedRuntimeClasspath(project)));
}
IRuntimeClasspathEntry[] entries = new IRuntimeClasspathEntry[classpaths.size()];
classpaths.toArray(entries);
IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration);
ISourceContainer[] sourceContainers = JavaRuntime.getSourceContainers(resolved);
if (!sourcefolderList.isEmpty()) {
ISourceContainer[] combinedSourceContainers = new ISourceContainer[sourceContainers.length + sourcefolderList.size()];
sourcefolderList.toArray(combinedSourceContainers);
System.arraycopy(sourceContainers, 0, combinedSourceContainers, sourcefolderList.size(), sourceContainers.length);
sourceContainers = combinedSourceContainers;
}
return sourceContainers;
}
use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class ConfigurationResourceListener method resourceChanged.
/**
* Currently, only changes to Tomcat configuration files are detected and the associated
* server's state updated. This method needs to be as brief as possible if the change
* is unrelated to server configuration changes. Since the Servers project would change
* so rarely, it is worth saving some cycles in the resource listener by caching this project.
*/
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IProject project = getServersProject();
if (project != null) {
IResourceDelta delta = event.getDelta();
if (delta != null) {
IResourceDelta serversProjectDelta = delta.findMember(project.getFullPath());
if (serversProjectDelta != null) {
// The change occurred within the Servers project.
IResourceDelta[] childDelta = serversProjectDelta.getAffectedChildren();
if (childDelta.length > 0) {
IServer[] servers = ServerCore.getServers();
for (int i = 0; i < childDelta.length; i++) {
// Check if this subfolder of the Servers folder matches a Tomcat configuration folder
for (int j = 0; j < servers.length; j++) {
IServerType serverType = servers[j].getServerType();
if (serverType.getId().startsWith("org.eclipse.jst.server.tomcat.")) {
IFolder configFolder = servers[j].getServerConfiguration();
if (configFolder != null) {
if (childDelta[i].getFullPath().equals(configFolder.getFullPath())) {
// Found a Tomcat server affected by this delta. Update this server's publish state.
TomcatServerBehaviour tcServerBehaviour = (TomcatServerBehaviour) servers[j].loadAdapter(TomcatServerBehaviour.class, null);
if (tcServerBehaviour != null) {
// Indicate that this server needs to publish and restart if running
tcServerBehaviour.setTomcatServerPublishState(IServer.PUBLISH_STATE_INCREMENTAL);
tcServerBehaviour.setTomcatServerRestartState(true);
}
break;
}
}
}
}
}
}
}
}
}
}
}
use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class UpdateServerJob method run.
public IStatus run(IProgressMonitor monitor) {
for (IServer server : servers) {
if (server.getServerType() != null && server.getServerState() == IServer.STATE_UNKNOWN) {
monitor.subTask(NLS.bind(Messages.jobUpdateServer, server.getName()));
server.loadAdapter(ServerBehaviourDelegate.class, monitor);
}
}
return Status.OK_STATUS;
}
use of org.eclipse.wst.server.core.IServer in project webtools.servertools by eclipse.
the class ServersViewDropAdapter method performDrop.
public boolean performDrop(Object data) {
Object target = getCurrentTarget();
IServer server = null;
if (target instanceof IServer)
server = (IServer) target;
if (server == null)
return false;
Iterator iterator = null;
if (data instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) data;
iterator = sel.iterator();
}
if (iterator == null)
return false;
boolean b = true;
while (iterator.hasNext()) {
Object data2 = iterator.next();
if (!doSel(server, data2))
b = false;
}
return b;
}
Aggregations