import org.apache.maven.archiva.repository.project.ProjectModelFilter;
import org.apache.maven.archiva.repository.project.ProjectModelMerge;
import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory;
+import org.codehaus.plexus.cache.Cache;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
* @plexus.requirement
*/
private ProjectModelResolverFactory resolverFactory;
+
+ /**
+ * @plexus.requirement role-hint="effective-project-cache"
+ */
+ private Cache effectiveProjectCache;
/**
* Take the provided {@link ArchivaProjectModel} and build the effective {@link ArchivaProjectModel}.
{
throw new IllegalStateException( "Unable to build effective pom with no project model resolvers defined." );
}
+
+ ArchivaProjectModel effectiveProject;
+ String projectKey = toProjectKey( project );
+
+ synchronized( effectiveProjectCache )
+ {
+ if( effectiveProjectCache.hasKey( projectKey ) )
+ {
+ effectiveProject = (ArchivaProjectModel) effectiveProjectCache.get( projectKey );
+ return effectiveProject;
+ }
+ }
// Clone submitted project (so that we don't mess with it)
- ArchivaProjectModel effectiveProject = ArchivaModelCloner.clone( project );
+ effectiveProject = ArchivaModelCloner.clone( project );
// Setup Expression Evaluation pieces.
effectiveProject = expressionFilter.filter( effectiveProject );
// Resolve dependency versions from dependency management.
applyDependencyManagement( effectiveProject );
+
+ synchronized( effectiveProjectCache )
+ {
+ effectiveProjectCache.put( projectKey, effectiveProject );
+ }
// Return what we got.
return effectiveProject;
VersionedReference parentRef = pom.getParentProject();
getLogger().debug( "Has parent: " + parentRef );
+
+ String pomKey = VersionedReference.toKey( parentRef );
+
+ synchronized( effectiveProjectCache )
+ {
+ if( effectiveProjectCache.hasKey( pomKey ) )
+ {
+ return (ArchivaProjectModel) effectiveProjectCache.get( pomKey );
+ }
+ }
// Find parent using resolvers.
ArchivaProjectModel parentProject = this.resolverFactory.getCurrentResolverStack().findProject( parentRef );
// TODO: Document this via monitor.
mixedProject = mixinSuperPom( pom );
}
+
+ synchronized( effectiveProjectCache )
+ {
+ effectiveProjectCache.put( pomKey, mixedProject );
+ }
}
else
{
mixedProject = mixinSuperPom( pom );
}
-
+
return mixedProject;
}
return key.toString();
}
+
+ private String toProjectKey( ArchivaProjectModel project )
+ {
+ StringBuffer key = new StringBuffer();
+
+ key.append( project.getGroupId() ).append( ":" );
+ key.append( project.getArtifactId() ).append( ":" );
+ key.append( project.getVersion() );
+
+ return key.toString();
+ }
}
--- /dev/null
+<component-set>
+ <components>
+ <component>
+ <role>org.codehaus.plexus.cache.Cache</role>
+ <role-hint>effective-project-cache</role-hint>
+ <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
+ <description>Effective Project Cache</description>
+ <configuration>
+ <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
+ <disk-persistent>true</disk-persistent>
+ <disk-store-path>${java.io.tmpdir}/archiva/effectiveproject</disk-store-path>
+ <eternal>true</eternal>
+ <max-elements-in-memory>1000</max-elements-in-memory>
+ <memory-eviction-policy>LRU</memory-eviction-policy>
+ <name>effective-project-cache</name>
+ <overflow-to-disk>false</overflow-to-disk>
+ <!-- TODO: Adjust the time to live to be more sane (ie: huge 4+ hours) -->
+ <!-- 45 minutes = 2700 seconds -->
+ <time-to-idle-seconds>2700</time-to-idle-seconds>
+ <!-- 30 minutes = 1800 seconds -->
+ <time-to-live-seconds>1800</time-to-live-seconds>
+ </configuration>
+ </component>
+ </components>
+</component-set>