mirror of https://github.com/apache/archiva.git
Using updated plexus-cache for runtime creation of Cache.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@512105 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0ce8ca699c
commit
cb8e218968
|
@ -34,10 +34,17 @@
|
|||
<groupId>org.apache.maven.archiva</groupId>
|
||||
<artifactId>archiva-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus.cache</groupId>
|
||||
<artifactId>plexus-cache-api</artifactId>
|
||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus.cache</groupId>
|
||||
<artifactId>plexus-cache-ehcache</artifactId>
|
||||
<version>1.0-alpha-1</version>
|
||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
@ -51,13 +58,6 @@
|
|||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-repository-metadata</artifactId>
|
||||
</dependency>
|
||||
<!-- TEST DEPS -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus.cache</groupId>
|
||||
<artifactId>plexus-cache-hashmap</artifactId>
|
||||
<version>1.0-alpha-1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
@ -22,6 +22,9 @@ package org.apache.maven.archiva.layer;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.codehaus.plexus.cache.Cache;
|
||||
import org.codehaus.plexus.cache.CacheException;
|
||||
import org.codehaus.plexus.cache.CacheHints;
|
||||
import org.codehaus.plexus.cache.factory.CacheFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -29,24 +32,31 @@ import java.util.List;
|
|||
* CachedRepositoryQueryLayer - simple wrapper around another non-cached Repository Query Layer.
|
||||
*
|
||||
* @version $Id$
|
||||
* @plexus.component role="org.apache.maven.archiva.layer.RepositoryQueryLayer" role-hint="cached"
|
||||
*/
|
||||
public class CachedRepositoryQueryLayer
|
||||
implements RepositoryQueryLayer
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement role-hint="repository-query"
|
||||
*/
|
||||
private Cache cache;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private RepositoryQueryLayer layer;
|
||||
|
||||
public CachedRepositoryQueryLayer()
|
||||
|
||||
public CachedRepositoryQueryLayer( RepositoryQueryLayer layer )
|
||||
throws RepositoryQueryLayerException
|
||||
{
|
||||
this.layer = layer;
|
||||
String repoId = layer.getRepository().getId();
|
||||
|
||||
CacheHints hints = new CacheHints();
|
||||
hints.setName( repoId );
|
||||
hints.setOverflowToDisk( false );
|
||||
try
|
||||
{
|
||||
this.cache = CacheFactory.getInstance().getCache( repoId, hints );
|
||||
}
|
||||
catch ( CacheException e )
|
||||
{
|
||||
throw new RepositoryQueryLayerException( "Unable to initialize cache: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsArtifact( Artifact artifact )
|
||||
|
|
|
@ -36,12 +36,13 @@ import java.util.List;
|
|||
* DefaultRepositoryQueryLayer
|
||||
*
|
||||
* @version $Id$
|
||||
* @plexus.component role="org.apache.maven.archiva.layer.RepositoryQueryLayer" role-hint="default"
|
||||
*/
|
||||
public class DefaultRepositoryQueryLayer
|
||||
implements RepositoryQueryLayer
|
||||
{
|
||||
protected ArtifactRepository repository;
|
||||
|
||||
|
||||
public DefaultRepositoryQueryLayer( ArtifactRepository repository )
|
||||
{
|
||||
this.repository = repository;
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.archiva.layer;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* CachedRepositoryQueryLayerTest
|
||||
*
|
||||
|
@ -34,7 +33,9 @@ public class CachedRepositoryQueryLayerTest
|
|||
{
|
||||
super.setUp();
|
||||
|
||||
queryLayer = (RepositoryQueryLayer) lookup( RepositoryQueryLayer.ROLE, "test-cached" );
|
||||
RepositoryQueryLayer defaultLayer = new DefaultRepositoryQueryLayer( repository );
|
||||
|
||||
queryLayer = new CachedRepositoryQueryLayer( defaultLayer );
|
||||
}
|
||||
|
||||
public void testUseFileCache()
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
~ distributed with this work for additional information
|
||||
~ regarding copyright ownership. The ASF licenses this file
|
||||
~ to you under the Apache License, Version 2.0 (the
|
||||
~ "License"); you may not use this file except in compliance
|
||||
~ with the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.archiva.layer.RepositoryQueryLayer</role>
|
||||
<role-hint>test-cached</role-hint>
|
||||
<implementation>org.apache.maven.archiva.layer.CachedRepositoryQueryLayer</implementation>
|
||||
<description>CachedRepositoryQueryLayer - simple wrapper around another non-cached Repository Query Layer.</description>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.cache.Cache</role>
|
||||
<role-hint>test-repository-query</role-hint>
|
||||
<field-name>cache</field-name>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.archiva.layer.RepositoryQueryLayer</role>
|
||||
<field-name>layer</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.codehaus.plexus.cache.Cache</role>
|
||||
<role-hint>test-repository-query</role-hint>
|
||||
<implementation>org.codehaus.plexus.cache.hashmap.HashMapCache</implementation>
|
||||
<configuration>
|
||||
<cache-hit-ratio>1.0</cache-hit-ratio>
|
||||
<cache-max-size>0</cache-max-size>
|
||||
</configuration>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
Loading…
Reference in New Issue