import org.apache.archiva.model.ArchivaArtifact;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
+import org.apache.archiva.redback.components.cache.Cache;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContentFactory;
import org.apache.archiva.repository.RepositoryException;
@Named( value = "repositoryProxyConnectors#default" )
private RepositoryProxyConnectors connectors;
+ @Inject
+ @Named( value = "browse#versionMetadata" )
+ private Cache<String, ProjectVersionMetadata> versionMetadataCache;
+
public BrowseResult getRootGroups( String repositoryId )
throws ArchivaRestServiceException
{
{
try
{
- versionMetadata =
- metadataResolver.resolveProjectVersion( repositorySession, repoId, groupId, artifactId,
- version );
+ ProjectVersionMetadata projectVersionMetadataResolved = null;
+ boolean useCache = !StringUtils.endsWith( version, VersionUtil.SNAPSHOT );
+ String cacheKey = null;
+ boolean cacheToUpdate = false;
+ // FIXME a bit maven centric!!!
+ // not a snapshot so get it from cache
+ if ( useCache )
+ {
+ cacheKey = repoId + groupId + artifactId + version;
+ projectVersionMetadataResolved = versionMetadataCache.get( cacheKey );
+ }
+ if ( useCache && projectVersionMetadataResolved != null )
+ {
+ versionMetadata = projectVersionMetadataResolved;
+ }
+ else
+ {
+ projectVersionMetadataResolved =
+ metadataResolver.resolveProjectVersion( repositorySession, repoId, groupId,
+ artifactId, version );
+ versionMetadata = projectVersionMetadataResolved;
+ cacheToUpdate = true;
+ }
+
+ if ( useCache && cacheToUpdate )
+ {
+ versionMetadataCache.put( cacheKey, projectVersionMetadataResolved );
+ }
+
}
catch ( MetadataResolutionException e )
{
{
// TODO: what about if we want to see this irrespective of version?
references.addAll(
- metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId, artifactId, version )
- );
+ metadataResolver.resolveProjectReferences( repositorySession, repoId, groupId, artifactId,
+ version ) );
}
}
catch ( MetadataResolutionException e )
n + "." + subNamespaces.iterator().next() );
}
}
+
+ public Cache getVersionMetadataCache()
+ {
+ return versionMetadataCache;
+ }
+
+ public void setVersionMetadataCache( Cache versionMetadataCache )
+ {
+ this.versionMetadataCache = versionMetadataCache;
+ }
}
</jaxrs:outFaultInterceptors>
</jaxrs:server>
+ <bean name="browse#versionMetadata" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
+ init-method="initialize">
+ <property name="diskPersistent" value="false"/>
+ <property name="eternal" value="false"/>
+ <property name="maxElementsInMemory" value="1000"/>
+ <property name="memoryEvictionPolicy" value="LRU"/>
+ <property name="name" value="userPermissions"/>
+ <property name="timeToIdleSeconds" value="300"/>
+ <property name="timeToLiveSeconds" value="600"/>
+ </bean>
+
</beans>
\ No newline at end of file