Hello Shane, How will the cache be cleared? Other than dumping and restarting the container? That would be a problem for embedded project loading.
Milos On Sun, Sep 28, 2008 at 6:52 AM, <[EMAIL PROTECTED]> wrote: > Author: sisbell > Date: Sat Sep 27 21:52:53 2008 > New Revision: 699773 > > URL: http://svn.apache.org/viewvc?rev=699773&view=rev > Log: > Removed use of workspace from project builder. In the build of trunk, there > were about 50K of calls from MavenMetadataSource to the project builder. I > put a simple hashmap cache in the metadata source to reduce calls to dozens. > > Modified: > > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java > > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java > > Modified: > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java > URL: > http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=699773&r1=699772&r2=699773&view=diff > ============================================================================== > --- > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java > (original) > +++ > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java > Sat Sep 27 21:52:53 2008 > @@ -132,11 +132,7 @@ > public MavenProject build( File projectDescriptor, > ProjectBuilderConfiguration config ) > throws ProjectBuildingException > { > - MavenProject project = projectWorkspace.getProject( > projectDescriptor ); > - > - if ( project == null ) > - { > - project = readModelFromLocalPath( "unknown", projectDescriptor, > new PomArtifactResolver( > + MavenProject project = readModelFromLocalPath( "unknown", > projectDescriptor, new PomArtifactResolver( > config.getLocalRepository(), > repositoryHelper.buildArtifactRepositories( > getSuperProject( config, projectDescriptor, true ).getModel() > ), artifactResolver ), config ); > > @@ -152,8 +148,6 @@ > project.setFile( projectDescriptor ); > > setBuildOutputDirectoryOnParent( project ); > - > - } > return project; > } > > @@ -170,21 +164,11 @@ > return buildFromRepository( artifact, remoteArtifactRepositories, > localRepository ); > } > > - > public MavenProject buildFromRepository( Artifact artifact, List > remoteArtifactRepositories, > ArtifactRepository > localRepository ) > throws ProjectBuildingException > { > - MavenProject project = null; > - if ( !Artifact.LATEST_VERSION.equals( artifact.getVersion() ) && > - !Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) ) > - { > - project = > - projectWorkspace.getProject( artifact.getGroupId(), > artifact.getArtifactId(), artifact.getVersion() ); > - } > File f = artifact.getFile(); > - if ( project == null ) > - { > repositoryHelper.findModelFromRepository( artifact, > remoteArtifactRepositories, localRepository ); > > ProjectBuilderConfiguration config = > @@ -195,10 +179,9 @@ > artifactRepositories.addAll( > repositoryHelper.buildArtifactRepositories( > getSuperProject( config, artifact.getFile(), false > ).getModel() ) ); > > - project = readModelFromLocalPath( "unknown", artifact.getFile(), > new PomArtifactResolver( > + MavenProject project = readModelFromLocalPath( "unknown", > artifact.getFile(), new PomArtifactResolver( > config.getLocalRepository(), artifactRepositories, > artifactResolver ), config ); > project = buildInternal( project.getModel(), config, > artifact.getFile(), project.getParentFile(), false ); > - } > > artifact.setFile( f ); > project.setVersion( artifact.getVersion() ); > @@ -440,9 +423,6 @@ > > externalProfileManager ) ); > project.setActiveProfiles( projectProfiles ); > > - projectWorkspace.storeProjectByCoordinate( project ); > - projectWorkspace.storeProjectByFile( project ); > - > return project; > } > > > Modified: > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java > URL: > http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=699773&r1=699772&r2=699773&view=diff > ============================================================================== > --- > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java > (original) > +++ > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java > Sat Sep 27 21:52:53 2008 > @@ -56,12 +56,7 @@ > import org.codehaus.plexus.util.StringUtils; > > import java.io.File; > -import java.util.ArrayList; > -import java.util.Collections; > -import java.util.Iterator; > -import java.util.LinkedHashSet; > -import java.util.List; > -import java.util.Set; > +import java.util.*; > > /** > * @author Jason van Zyl > @@ -149,6 +144,8 @@ > return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + > artifact.getVersion(); > } > > + private HashMap<String, MavenProject> hm = new HashMap<String, > MavenProject>(); > + > private ProjectRelocation retrieveRelocatedProject( Artifact artifact, > ArtifactRepository localRepository, > > List<ArtifactRepository> remoteRepositories ) > throws ArtifactMetadataRetrievalException > @@ -184,44 +181,55 @@ > } > else > { > - try > + > + if(hm.containsKey(pomArtifact.getId())) > { > - project = > - mavenProjectBuilder.buildFromRepository( > pomArtifact, remoteRepositories, localRepository ); > + project = hm.get(pomArtifact.getId()); > } > - catch ( InvalidProjectModelException e ) > + else > { > - handleInvalidOrMissingMavenPOM( artifact, e ); > - > - if ( getLogger().isDebugEnabled() ) > + try > { > - getLogger().debug( "Reason: " + e.getMessage() ); > + project = > + mavenProjectBuilder.buildFromRepository( > pomArtifact, remoteRepositories, localRepository ); > + hm.put(pomArtifact.getId(), project); > > - ModelValidationResult validationResult = > e.getValidationResult(); > + } > + catch ( InvalidProjectModelException e ) > + { > + handleInvalidOrMissingMavenPOM( artifact, e ); > > - if ( validationResult != null ) > + if ( getLogger().isDebugEnabled() ) > { > - getLogger().debug( "\nValidation Errors:" ); > - for ( Iterator i = > validationResult.getMessages().iterator(); i.hasNext(); ) > + getLogger().debug( "Reason: " + e.getMessage() ); > + > + ModelValidationResult validationResult = > e.getValidationResult(); > + > + if ( validationResult != null ) > { > - getLogger().debug( i.next().toString() ); > + getLogger().debug( "\nValidation Errors:" ); > + for ( Iterator i = > validationResult.getMessages().iterator(); i.hasNext(); ) > + { > + getLogger().debug( i.next().toString() ); > + } > + getLogger().debug( "\n" ); > + } > + else > + { > + getLogger().debug( "", e ); > } > - getLogger().debug( "\n" ); > - } > - else > - { > - getLogger().debug( "", e ); > } > + > + project = null; > } > + catch ( ProjectBuildingException e ) > + { > + handleInvalidOrMissingMavenPOM( artifact, e ); > > - project = null; > + project = null; > + } > } > - catch ( ProjectBuildingException e ) > - { > - handleInvalidOrMissingMavenPOM( artifact, e ); > > - project = null; > - } > > if ( project != null ) > { > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
