felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsav...@apache.org
Subject svn commit: r963491 - in /felix/trunk/sigil/eclipse: core/src/org/apache/felix/sigil/eclipse/internal/builders/ core/src/org/apache/felix/sigil/eclipse/internal/resources/ core/src/org/apache/felix/sigil/eclipse/job/ ui/src/org/apache/felix/sigil/ui/ec...
Date Mon, 12 Jul 2010 21:22:17 GMT
Author: dsavage
Date: Mon Jul 12 21:22:13 2010
New Revision: 963491

URL: http://svn.apache.org/viewvc?rev=963491&view=rev
Log:
improve performance of resolver in workspaces with many sigil projects - prevent cyclical
resolver tasks

Modified:
    felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
    felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
    felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/startup/SigilStartup.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/SigilUI.java
    felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java

Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java?rev=963491&r1=963490&r2=963491&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
(original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
Mon Jul 12 21:22:13 2010
@@ -44,6 +44,9 @@ import org.eclipse.core.resources.Resour
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jdt.core.IClasspathEntry;
 import org.eclipse.jdt.core.IJavaModelMarker;
 import org.eclipse.jdt.core.JavaCore;
@@ -56,7 +59,6 @@ import org.eclipse.ui.console.MessageCon
 
 public class SigilIncrementalProjectBuilder extends IncrementalProjectBuilder
 {
-
     @Override
     protected IProject[] build( int kind, @SuppressWarnings("unchecked") Map args, IProgressMonitor
monitor )
         throws CoreException
@@ -216,25 +218,34 @@ public class SigilIncrementalProjectBuil
 
     private static void loginfo( String message )
     {
-        BuildConsole console = findConsole();
-        MessageConsoleStream stream = console.getMessageStream();
-        stream.println( "INFO: " + message );
+        log("INFO: " + message);
     }
 
-
     private static void logwarn( String message )
     {
-        BuildConsole console = findConsole();
-        MessageConsoleStream stream = console.getMessageStream();
-        stream.println( "WARN: " + message );
+        log( "WARN: " + message );
     }
 
 
     private static void logerror( String message )
     {
-        BuildConsole console = findConsole();
-        MessageConsoleStream stream = console.getMessageStream();
-        stream.println( "ERROR: " + message );
+        log( "ERROR: " + message );
+    }
+
+    private static void log(final String message)
+    {
+        // do this in background to avoid deadlock with ui 
+        Job job = new Job("log") {
+            @Override
+            protected IStatus run(IProgressMonitor arg0)
+            {
+                BuildConsole console = findConsole();
+                MessageConsoleStream stream = console.getMessageStream();
+                stream.println( message );
+                return Status.OK_STATUS;
+            }
+        };
+        job.schedule();
     }
 
 

Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java?rev=963491&r1=963490&r2=963491&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
(original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
Mon Jul 12 21:22:13 2010
@@ -21,6 +21,7 @@ package org.apache.felix.sigil.eclipse.i
 import java.util.LinkedList;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
+import org.apache.felix.sigil.eclipse.job.ResolveProjectsJob;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.model.ICapabilityModelElement;
 import org.apache.felix.sigil.model.IModelElement;
@@ -33,10 +34,10 @@ import org.eclipse.core.resources.IResou
 import org.eclipse.core.resources.IResourceDeltaVisitor;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
+//import org.eclipse.core.runtime.IProgressMonitor;
+//import org.eclipse.core.runtime.IStatus;
+//import org.eclipse.core.runtime.Status;
+//import org.eclipse.core.runtime.jobs.Job;
 
 public class ProjectResourceListener implements IResourceChangeListener
 {
@@ -53,6 +54,9 @@ public class ProjectResourceListener imp
         try
         {
             switch ( event.getType() ) {
+                case IResourceChangeEvent.PRE_REFRESH:
+                    handleRefresh(event);
+                    break;
                 case IResourceChangeEvent.PRE_DELETE:
                     handlePreDelete(event);
                     break;
@@ -60,6 +64,8 @@ public class ProjectResourceListener imp
                     handlePostChange(event);
                     break;
             }
+            
+            handleUpdate();
         }
         catch (CoreException e)
         {
@@ -67,6 +73,43 @@ public class ProjectResourceListener imp
         }
     }
 
+    private void handleUpdate()
+    {
+        if( capabilities.size() > 0 ) {
+            final LinkedList<ICapabilityModelElement> changes = new LinkedList<ICapabilityModelElement>(capabilities);
+            capabilities.clear();
+            
+            ResolveProjectsJob job = new ResolveProjectsJob(ResourcesPlugin.getWorkspace(),
changes);
+            job.schedule();        
+        }
+    }
+    
+    private void handleRefresh(IResourceChangeEvent event) throws CoreException
+    {
+        IResourceDelta delta = event.getDelta();
+        if ( delta != null )
+        {
+            delta.accept( new IResourceDeltaVisitor()
+            {
+                public boolean visit( IResourceDelta delta ) throws CoreException
+                {
+                    IResource resource = delta.getResource();
+                    if ( resource instanceof IProject )
+                    {
+                        IProject project = ( IProject ) resource;
+                        if ( SigilCore.isSigilProject( project ) )
+                        {
+                            readCapabilities(project);
+                        }
+                        // Recurse no more
+                        return false;
+                    }
+                    return true;
+                }
+            } );            
+        }
+    }    
+
     private LinkedList<ICapabilityModelElement> capabilities = new LinkedList<ICapabilityModelElement>();
     
     private void handlePostChange(IResourceChangeEvent event) throws CoreException
@@ -97,25 +140,7 @@ public class ProjectResourceListener imp
                     }
                     return true;
                 }
-            } );
-            
-            if( capabilities.size() > 0 ) {
-                final LinkedList<ICapabilityModelElement> changes = new LinkedList<ICapabilityModelElement>(capabilities);
-                capabilities.clear();
-                
-                Job job = new Job("Rebuild project dependencies")
-                {
-                    
-                    @Override
-                    protected IStatus run(IProgressMonitor monitor)
-                    {
-                        SigilCore.rebuildBundleDependencies(null, changes, monitor);
-                        return Status.OK_STATUS;
-                    }
-                };
-                job.setRule(ResourcesPlugin.getWorkspace().getRoot());
-                job.schedule();
-            }
+            } );            
         }
     }
 
@@ -147,6 +172,4 @@ public class ProjectResourceListener imp
             }
         });
     }
-
-
 }

Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java?rev=963491&r1=963490&r2=963491&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
(original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
Mon Jul 12 21:22:13 2010
@@ -22,9 +22,15 @@ package org.apache.felix.sigil.eclipse.j
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.LinkedList;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
+import org.apache.felix.sigil.model.ICapabilityModelElement;
+import org.apache.felix.sigil.model.IModelElement;
+import org.apache.felix.sigil.model.IModelWalker;
+import org.apache.felix.sigil.model.IRequirementModelElement;
+import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.WorkspaceJob;
 import org.eclipse.core.runtime.CoreException;
@@ -36,23 +42,32 @@ import org.eclipse.core.runtime.MultiSta
 public class ResolveProjectsJob extends WorkspaceJob
 {
     private final Collection<ISigilProjectModel> sigilProjects;
+    private final LinkedList<ICapabilityModelElement> capabilities;
     
     public ResolveProjectsJob( IWorkspace workspace )
     {
         super( "Resolving Sigil projects" );
         setRule( workspace.getRoot() );
         sigilProjects = SigilCore.getRoot().getProjects();
+        capabilities = null;
     }
 
+    public ResolveProjectsJob(IWorkspace workspace, LinkedList<ICapabilityModelElement>
capabilities)
+    {
+        super( "Resolving Sigil projects" );
+        this.capabilities = capabilities;
+        setRule( workspace.getRoot() );
+        sigilProjects = SigilCore.getRoot().getProjects();
+    }
 
     public ResolveProjectsJob(ISigilProjectModel project)
     {
         super( "Resolving Sigil project" );
         setRule( project.getProject().getWorkspace().getRoot() );
         sigilProjects = Collections.singleton(project);
+        capabilities = null;
     }
 
-
     @Override
     public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
     {
@@ -64,8 +79,10 @@ public class ResolveProjectsJob extends 
         {
             try
             {
-                if ( flush ) sigilProject.flushDependencyState();
-                sigilProject.rebuildDependencies(monitor);
+                if ( isDependent(sigilProject) ) { 
+                    if ( flush) sigilProject.flushDependencyState();
+                    sigilProject.rebuildDependencies(monitor);
+                }
             }
             catch ( CoreException e )
             {
@@ -75,4 +92,42 @@ public class ResolveProjectsJob extends 
 
         return status;
     }
+
+    private boolean isDependent(ISigilProjectModel sigilProject)
+    {
+        if ( capabilities == null ) {
+            return true;
+        }
+        else {
+            ISigilBundle b = sigilProject.getBundle();
+            if ( b == null ) {
+                // sigil project deleted can't be a dependent
+                return false;
+            }
+            else {
+                final boolean[] dep = new boolean[1];
+                
+                b.visit(new IModelWalker()
+                {
+                    public boolean visit(IModelElement element)
+                    {
+                        if (element instanceof IRequirementModelElement) {
+                            IRequirementModelElement r = (IRequirementModelElement) element;
+        
+                            for (ICapabilityModelElement c : capabilities) {
+                                if( r.accepts(c)) {
+                                    dep[0] = true;
+                                    break;
+                                }
+                            }
+                        }
+                        // found a dependency stop walking
+                        return !dep[0];
+                    }
+                });
+                
+                return dep[0];
+            }
+        }
+    }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/startup/SigilStartup.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/startup/SigilStartup.java?rev=963491&r1=963490&r2=963491&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/startup/SigilStartup.java
(original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/startup/SigilStartup.java
Mon Jul 12 21:22:13 2010
@@ -26,6 +26,7 @@ import org.apache.felix.sigil.eclipse.Si
 import org.apache.felix.sigil.eclipse.job.ResolveProjectsJob;
 import org.apache.felix.sigil.repository.IRepositoryChangeListener;
 import org.apache.felix.sigil.repository.RepositoryChangeEvent;
+import org.apache.felix.sigil.ui.eclipse.ui.SigilUI;
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -47,24 +48,29 @@ public class SigilStartup implements ISt
         {
             public void repositoryChanged( RepositoryChangeEvent event )
             {
-                final int update = updateCounter.incrementAndGet();
-                
-                Job job = new Job("Pending repository update") {
-                    @Override
-                    protected IStatus run(IProgressMonitor monitor)
-                    {
-                        if ( update == updateCounter.get() ) {
-                            IWorkspace workspace = ResourcesPlugin.getWorkspace();
-                            ResolveProjectsJob job = new ResolveProjectsJob( workspace );
-                            job.setSystem( true );
-                            job.schedule();
-                        }
-                        return Status.OK_STATUS;
-                    }
+                if ( !SigilUI.WORKSPACE_REPOSITORY_ID.equals( event.getRepository().getId()
) ) {
+                    final int update = updateCounter.incrementAndGet();
                     
-                };
-                job.setSystem(true);
-                job.schedule(100);
+                    Job job = new Job("Pending repository update") {
+                        @Override
+                        protected IStatus run(IProgressMonitor monitor)
+                        {
+                            if ( update == updateCounter.get() ) {
+                                IWorkspace workspace = ResourcesPlugin.getWorkspace();
+                                ResolveProjectsJob job = new ResolveProjectsJob( workspace
);
+                                job.setSystem( true );
+                                job.schedule();
+                            }
+                            return Status.OK_STATUS;
+                        }
+                        
+                    };
+                    job.setSystem(true);
+                    job.schedule(100);
+                } 
+                //else {
+                //   Repository changes are handled by ProjectResourceListener 
+                //}
             }
         } );
     }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/SigilUI.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/SigilUI.java?rev=963491&r1=963490&r2=963491&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/SigilUI.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/SigilUI.java Mon
Jul 12 21:22:13 2010
@@ -54,6 +54,8 @@ public class SigilUI extends AbstractUIP
 
     public static final String ID_REPOSITORY_VIEW = "org.apache.felix.sigil.ui.repositoryBrowser";
     public static final String ID_DEPENDENCY_VIEW = "org.apache.felix.sigil.ui.bundleDependencyView";
+    
+    public static final String WORKSPACE_REPOSITORY_ID = "org.apache.felix.sigil.core.workspaceprovider";
 
     // The shared instance
     private static SigilUI plugin;

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java?rev=963491&r1=963490&r2=963491&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java
(original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java
Mon Jul 12 21:22:13 2010
@@ -238,9 +238,6 @@ public class SigilProjectEditorPart exte
         try
         {
             switch (event.getType()) {
-                case IResourceChangeEvent.PRE_REFRESH:
-                    handleRefresh(event);
-                    break;
                 case IResourceChangeEvent.POST_BUILD:
                     handleBuild(event);
                     break;
@@ -262,13 +259,6 @@ public class SigilProjectEditorPart exte
     }
 
 
-    private void handleRefresh(IResourceChangeEvent event)
-    {
-        ResolveProjectsJob job = new ResolveProjectsJob(project);
-        job.schedule();        
-    }
-
-
     private void handleChange(IResourceChangeEvent event) throws CoreException
     {
         IResourceDelta delta = event.getDelta();
@@ -386,8 +376,6 @@ public class SigilProjectEditorPart exte
         tempProject.setBundle(null);
         project.setBundle( null );
         refreshAllPages();
-        ResolveProjectsJob job = new ResolveProjectsJob(project);
-        job.schedule();        
     }
 
 



Mime
View raw message