o Unified code

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@819871 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-09-29 09:46:01 +00:00
parent 42884072b2
commit 3bcdf432b2
6 changed files with 45 additions and 22 deletions

View File

@ -106,9 +106,9 @@ public CacheRecord get( Plugin plugin, ClassLoader parentRealm, List<String> par
return cache.get( new CacheKey( plugin, parentRealm, parentImports, localRepository, remoteRepositories ) );
}
public void put( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
ClassRealm pluginRealm, List<Artifact> pluginArtifacts )
public CacheRecord put( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
ClassRealm pluginRealm, List<Artifact> pluginArtifacts )
{
if ( pluginRealm == null || pluginArtifacts == null )
{
@ -123,7 +123,10 @@ public void put( Plugin plugin, ClassLoader parentRealm, List<String> parentImpo
}
CacheRecord record = new CacheRecord( pluginRealm, pluginArtifacts );
cache.put( key, record );
return record;
}
public void flush()
@ -234,7 +237,7 @@ private static <T> boolean eq( T s1, T s2 )
return s1 != null ? s1.equals( s2 ) : s2 == null;
}
public void register( MavenProject project, ClassRealm pluginRealm )
public void register( MavenProject project, CacheRecord record )
{
// default cache does not track plugin usage
}

View File

@ -53,19 +53,20 @@ public CacheRecord( ClassRealm realm, List<Artifact> artifacts )
CacheRecord get( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories );
void put( Plugin plugin, ClassLoader parentRealm, List<String> parentImports, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, ClassRealm pluginRealm, List<Artifact> pluginArtifacts );
CacheRecord put( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
ClassRealm pluginRealm, List<Artifact> pluginArtifacts );
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.
* Registers the specified cache record 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 records 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}.
* @param record The cache record being used for the project, must not be {@code null}.
*/
void register( MavenProject project, ClassRealm pluginRealm );
void register( MavenProject project, CacheRecord record );
}

View File

@ -315,12 +315,13 @@ public synchronized void setupPluginRealm( PluginDescriptor pluginDescriptor, Ma
{
createPluginRealm( pluginDescriptor, session, parent, imports );
pluginRealmCache.put( plugin, parent, imports, session.getLocalRepository(),
project.getPluginArtifactRepositories(), pluginDescriptor.getClassRealm(),
pluginDescriptor.getArtifacts() );
cacheRecord =
pluginRealmCache.put( plugin, parent, imports, session.getLocalRepository(),
project.getPluginArtifactRepositories(), pluginDescriptor.getClassRealm(),
pluginDescriptor.getArtifacts() );
}
pluginRealmCache.register( project, pluginDescriptor.getClassRealm() );
pluginRealmCache.register( project, cacheRecord );
}
private void createPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent,

View File

@ -362,11 +362,11 @@ public synchronized ProjectRealmCache.CacheRecord createProjectRealm( MavenProje
extensionArtifactFilter = new ExclusionSetFilter( exclusions );
}
projectRealmCache.put( extensionRealms, projectRealm, extensionArtifactFilter );
record = new ProjectRealmCache.CacheRecord( projectRealm, extensionArtifactFilter );
record = projectRealmCache.put( extensionRealms, projectRealm, extensionArtifactFilter );
}
projectRealmCache.register( project, record );
return record;
}

View File

@ -83,8 +83,8 @@ public CacheRecord get( List<? extends ClassRealm> extensionRealms )
return cache.get( new CacheKey( extensionRealms ) );
}
public void put( List<? extends ClassRealm> extensionRealms, ClassRealm projectRealm,
ArtifactFilter extensionArtifactFilter )
public CacheRecord put( List<? extends ClassRealm> extensionRealms, ClassRealm projectRealm,
ArtifactFilter extensionArtifactFilter )
{
if ( projectRealm == null )
{
@ -99,7 +99,10 @@ public void put( List<? extends ClassRealm> extensionRealms, ClassRealm projectR
}
CacheRecord record = new CacheRecord( projectRealm, extensionArtifactFilter );
cache.put( key, record );
return record;
}
public void flush()
@ -107,4 +110,9 @@ public void flush()
cache.clear();
}
public void register( MavenProject project, CacheRecord record )
{
// default cache does not track record usage
}
}

View File

@ -52,9 +52,19 @@ public CacheRecord( ClassRealm realm, ArtifactFilter extensionArtifactFilter )
CacheRecord get( List<? extends ClassRealm> extensionRealms );
void put( List<? extends ClassRealm> extensionRealms, ClassRealm projectRealm,
ArtifactFilter extensionArtifactFilter );
CacheRecord put( List<? extends ClassRealm> extensionRealms, ClassRealm projectRealm,
ArtifactFilter extensionArtifactFilter );
void flush();
/**
* Registers the specified cache record 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 records from the
* cache.
*
* @param project The project that employs the plugin realm, must not be {@code null}.
* @param record The cache record being used for the project, must not be {@code null}.
*/
void register( MavenProject project, CacheRecord record );
}