You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2011/07/01 06:19:02 UTC
svn commit: r1141790 - in
/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core:
GeronimoServerBehaviourDelegate.java GeronimoSourcePathComputerDelegate.java
Author: gawor
Date: Fri Jul 1 04:19:02 2011
New Revision: 1141790
URL: http://svn.apache.org/viewvc?rev=1141790&view=rev
Log:
GERONIMODEVTOOLS-763: Reset source lookup project list
Modified:
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java?rev=1141790&r1=1141789&r2=1141790&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java Fri Jul 1 04:19:02 2011
@@ -62,6 +62,7 @@ import org.apache.geronimo.st.v30.core.o
import org.apache.geronimo.st.v30.core.osgi.OSGIBundleHelper;
import org.apache.geronimo.st.v30.core.osgi.OsgiConstants;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -75,7 +76,11 @@ import org.eclipse.debug.core.DebugPlugi
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.containers.DefaultSourceContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.internal.launching.RuntimeClasspathEntry;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
@@ -122,6 +127,8 @@ abstract public class GeronimoServerBeha
private PublishStateListener publishStateListener;
private Lock publishLock = new ReentrantLock();
+
+ private Set<IProject> knownSourceProjects = null;
/*
* (non-Javadoc)
@@ -255,6 +262,46 @@ abstract public class GeronimoServerBeha
}
}
+ void setKnownSourceProjects(Set<IProject> knownSourceProjects) {
+ this.knownSourceProjects = knownSourceProjects;
+ }
+
+ boolean hasKnownSourceProject(List<IModule[]> moduleList) {
+ if (knownSourceProjects != null) {
+ for (IModule[] modules : moduleList) {
+ for (IModule module : modules) {
+ IProject project = module.getProject();
+ if (project != null && !knownSourceProjects.contains(project)) {
+ Trace.trace(Trace.INFO, "Project " + project.getName() + " is not source lookup list.", Activator.traceCore); //$NON-NLS-1$
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ void resetSourceLookupList() {
+ Trace.trace(Trace.INFO, "Resetting source lookup list.", Activator.traceCore); //$NON-NLS-1$
+
+ // reset DefaultSourceContainer - that will force Eclipse to re-compute the source paths
+ AbstractSourceLookupDirector locator = (AbstractSourceLookupDirector) getServer().getLaunch().getSourceLocator();
+ ISourceContainer[] oldContainers = locator.getSourceContainers();
+ ISourceContainer[] newContainers = new ISourceContainer[oldContainers.length];
+ System.arraycopy(oldContainers, 0, newContainers, 0, oldContainers.length);
+ DefaultSourceContainer newDefaultContainer = new DefaultSourceContainer();
+ for (int i = 0; i < newContainers.length; i++) {
+ if (newDefaultContainer.getType().equals(newContainers[i].getType())) {
+ newContainers[i] = newDefaultContainer;
+ break;
+ }
+ }
+ locator.setSourceContainers(newContainers);
+
+ // reset knownSourceProjects as they will be set once Eclipse re-computes the source paths
+ knownSourceProjects = null;
+ }
+
/*
* Override this method to be able to process in-place shared lib entries and restart the shared lib configuration for all projects prior
* to publishing each IModule.
@@ -318,7 +365,12 @@ abstract public class GeronimoServerBeha
list.setRootModuleDelta(moduleDeltaKind.intValue());
} else {
list.addChildModule(module, moduleDeltaKind.intValue());
- }
+ }
+ }
+
+ // Reset source code lookup list - see GERONIMODEVTOOLS-763 for details.
+ if (ILaunchManager.DEBUG_MODE.equals(getServer().getMode()) && !hasKnownSourceProject(modules)) {
+ resetSourceLookupList();
}
if(status.isOK()) {
Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java?rev=1141790&r1=1141789&r2=1141790&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoSourcePathComputerDelegate.java Fri Jul 1 04:19:02 2011
@@ -65,18 +65,23 @@ public class GeronimoSourcePathComputerD
IServer server = ServerUtil.getServer(configuration);
IModule[] modules = server.getModules();
- List<IJavaProject> javaProjectList = new ArrayList<IJavaProject>();
- // populate list of java projects and their source folders
- processModules(modules, javaProjectList, server, monitor);
+ Set<IProject> projectList = new HashSet<IProject>();
+ // populate list of projects and their source folders
+ processModules(modules, projectList, server, monitor);
// create a ProjectRuntime classpath entry for each JavaProject
- IRuntimeClasspathEntry[] projectEntries = new IRuntimeClasspathEntry[javaProjectList.size()];
- for (int i = 0; i < javaProjectList.size(); i++) {
- projectEntries[i] = JavaRuntime.newProjectRuntimeClasspathEntry(javaProjectList.get(i));
+ List<IRuntimeClasspathEntry> projectEntriesList = new ArrayList<IRuntimeClasspathEntry>(projectList.size());
+ for (IProject project : projectList) {
+ IJavaProject javaProject = getJavaProject(project);
+ if (javaProject != null) {
+ projectEntriesList.add(JavaRuntime.newProjectRuntimeClasspathEntry(javaProject));
+ }
}
+ IRuntimeClasspathEntry[] projectEntries = new IRuntimeClasspathEntry[projectEntriesList.size()];
+ projectEntriesList.toArray(projectEntries);
// combine unresolved entries and project entries
- IRuntimeClasspathEntry[] unresolvedEntries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
+ IRuntimeClasspathEntry[] unresolvedEntries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
IRuntimeClasspathEntry[] entries = new IRuntimeClasspathEntry[projectEntries.length + unresolvedEntries.length];
System.arraycopy(unresolvedEntries, 0, entries, 0, unresolvedEntries.length);
System.arraycopy(projectEntries, 0, entries, unresolvedEntries.length, projectEntries.length);
@@ -100,6 +105,10 @@ public class GeronimoSourcePathComputerD
ISourceContainer[] runtimeContainers = processServer(server);
addAll(allContainers, runtimeContainers);
+ // set known source project list
+ GeronimoServerBehaviourDelegate delegate = getDelegate(server);
+ delegate.setKnownSourceProjects(projectList);
+
Trace.tracePoint("Exit", Activator.traceCore, "GeronimoSourcePathComputerDelegate.computeSourceContainers", toStringList(allContainers));
return allContainers.toArray(new ISourceContainer[allContainers.size()]);
@@ -139,44 +148,52 @@ public class GeronimoSourcePathComputerD
return new ISourceContainer[] {};
}
- private void processModules(IModule[] modules, List<IJavaProject> javaProjectList, IServer server, IProgressMonitor monitor) {
+ private void processModules(IModule[] modules, Set<IProject> projectList, IServer server, IProgressMonitor monitor) {
for (int i = 0; i < modules.length; i++) {
IProject project = modules[i].getProject();
IModule[] childModules = server.getChildModules(new IModule[] { modules[i] }, monitor);
if (childModules != null && childModules.length > 0) {
- processModules(childModules, javaProjectList, server, monitor);
+ processModules(childModules, projectList, server, monitor);
}
if (project != null) {
- //process referenced projects for shared lib
- try {
- IProject[] referencedProjects = project.getReferencedProjects();
- for(int j = 0; j < referencedProjects.length; j++) {
- processJavaProject(javaProjectList, referencedProjects[j]);
- }
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- processJavaProject(javaProjectList, project);
+ processProject(projectList, project);
}
}
}
- private void processJavaProject(List<IJavaProject> javaProjectList, IProject project) {
+ private void processProject(Set<IProject> projectList, IProject project) {
+ projectList.add(project);
try {
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
- if (!javaProjectList.contains(javaProject)) {
- javaProjectList.add(javaProject);
+ IProject[] referencedProjects = project.getReferencedProjects();
+ if (referencedProjects != null) {
+ for(int j = 0; j < referencedProjects.length; j++) {
+ processProject(projectList, referencedProjects[j]);
}
}
- } catch (Exception e) {
+ } catch (CoreException e) {
// ignore
}
}
+ public IJavaProject getJavaProject(IProject project) {
+ try {
+ if (project.hasNature(JavaCore.NATURE_ID)) {
+ return (IJavaProject) project.getNature(JavaCore.NATURE_ID);
+ }
+ } catch (CoreException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ private GeronimoServerBehaviourDelegate getDelegate(IServer server) {
+ GeronimoServerBehaviourDelegate delegate =
+ (GeronimoServerBehaviourDelegate) server.loadAdapter(GeronimoServerBehaviourDelegate.class, null);
+ return delegate;
+ }
+
private synchronized void init() {
if (additionalSrcPathComputerIds == null) {
additionalSrcPathComputerIds = new HashSet<String>();