maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r817681 - in /maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin: DefaultPluginRealmCache.java PluginRealmCache.java internal/DefaultMavenPluginManager.java
Date Tue, 22 Sep 2009 14:48:01 GMT
Author: bentmann
Date: Tue Sep 22 14:48:00 2009
New Revision: 817681

URL: http://svn.apache.org/viewvc?rev=817681&view=rev
Log:
[MNG-4194] API to safely release of plugin realms

o Allowed cache to track usage of plugins by projects

Modified:
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java?rev=817681&r1=817680&r2=817681&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
Tue Sep 22 14:48:00 2009
@@ -31,6 +31,7 @@
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Exclusion;
 import org.apache.maven.model.Plugin;
+import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
 import org.codehaus.plexus.component.annotations.Component;
 
@@ -233,4 +234,9 @@
         return s1 != null ? s1.equals( s2 ) : s2 == null;
     }
 
+    public void register( MavenProject project, ClassRealm pluginRealm )
+    {
+        // default cache does not track plugin usage
+    }
+
 }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java?rev=817681&r1=817680&r2=817681&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java
Tue Sep 22 14:48:00 2009
@@ -24,6 +24,7 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Plugin;
+import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
 
 /**
@@ -57,4 +58,14 @@
 
     void flush();
 
+    /**
+     * Registers the specified plugin realm for usage with the given project. Integrators
can use the information
+     * collected from this method in combination with a custom cache implementation to dispose
unused plugin realms from
+     * the cache.
+     * 
+     * @param project The project that employs the plugin realm, must not be {@code null}.
+     * @param pluginRealm The plugin realm being used for the project, must not be {@code
null}.
+     */
+    void register( MavenProject project, ClassRealm pluginRealm );
+
 }

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java?rev=817681&r1=817680&r2=817681&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
Tue Sep 22 14:48:00 2009
@@ -297,9 +297,11 @@
     {
         Plugin plugin = pluginDescriptor.getPlugin();
 
+        MavenProject project = session.getCurrentProject();
+
         PluginRealmCache.CacheRecord cacheRecord =
             pluginRealmCache.get( plugin, parent, imports, session.getLocalRepository(),
-                                  session.getCurrentProject().getPluginArtifactRepositories()
);
+                                  project.getPluginArtifactRepositories() );
 
         if ( cacheRecord != null )
         {
@@ -311,9 +313,11 @@
             createPluginRealm( pluginDescriptor, session, parent, imports );
 
             pluginRealmCache.put( plugin, parent, imports, session.getLocalRepository(),
-                                  session.getCurrentProject().getPluginArtifactRepositories(),
-                                  pluginDescriptor.getClassRealm(), pluginDescriptor.getArtifacts()
);
+                                  project.getPluginArtifactRepositories(), pluginDescriptor.getClassRealm(),
+                                  pluginDescriptor.getArtifacts() );
         }
+
+        pluginRealmCache.register( project, pluginDescriptor.getClassRealm() );
     }
 
     private void createPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session,
ClassLoader parent,



Mime
View raw message