mirror of
https://github.com/apache/archiva.git
synced 2025-02-08 02:59:43 +00:00
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>
|
<groupId>org.apache.maven.archiva</groupId>
|
||||||
<artifactId>archiva-common</artifactId>
|
<artifactId>archiva-common</artifactId>
|
||||||
</dependency>
|
</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>
|
<dependency>
|
||||||
<groupId>org.codehaus.plexus.cache</groupId>
|
<groupId>org.codehaus.plexus.cache</groupId>
|
||||||
<artifactId>plexus-cache-ehcache</artifactId>
|
<artifactId>plexus-cache-ehcache</artifactId>
|
||||||
<version>1.0-alpha-1</version>
|
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
@ -51,13 +58,6 @@
|
|||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-repository-metadata</artifactId>
|
<artifactId>maven-repository-metadata</artifactId>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.codehaus.plexus.cache.Cache;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
@ -29,24 +32,31 @@
|
|||||||
* CachedRepositoryQueryLayer - simple wrapper around another non-cached Repository Query Layer.
|
* CachedRepositoryQueryLayer - simple wrapper around another non-cached Repository Query Layer.
|
||||||
*
|
*
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @plexus.component role="org.apache.maven.archiva.layer.RepositoryQueryLayer" role-hint="cached"
|
|
||||||
*/
|
*/
|
||||||
public class CachedRepositoryQueryLayer
|
public class CachedRepositoryQueryLayer
|
||||||
implements RepositoryQueryLayer
|
implements RepositoryQueryLayer
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @plexus.requirement role-hint="repository-query"
|
|
||||||
*/
|
|
||||||
private Cache cache;
|
private Cache cache;
|
||||||
|
|
||||||
/**
|
|
||||||
* @plexus.requirement
|
|
||||||
*/
|
|
||||||
private RepositoryQueryLayer layer;
|
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 )
|
public boolean containsArtifact( Artifact artifact )
|
||||||
|
@ -36,12 +36,13 @@
|
|||||||
* DefaultRepositoryQueryLayer
|
* DefaultRepositoryQueryLayer
|
||||||
*
|
*
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
* @plexus.component role="org.apache.maven.archiva.layer.RepositoryQueryLayer" role-hint="default"
|
||||||
*/
|
*/
|
||||||
public class DefaultRepositoryQueryLayer
|
public class DefaultRepositoryQueryLayer
|
||||||
implements RepositoryQueryLayer
|
implements RepositoryQueryLayer
|
||||||
{
|
{
|
||||||
protected ArtifactRepository repository;
|
protected ArtifactRepository repository;
|
||||||
|
|
||||||
public DefaultRepositoryQueryLayer( ArtifactRepository repository )
|
public DefaultRepositoryQueryLayer( ArtifactRepository repository )
|
||||||
{
|
{
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CachedRepositoryQueryLayerTest
|
* CachedRepositoryQueryLayerTest
|
||||||
*
|
*
|
||||||
@ -34,7 +33,9 @@ protected void setUp()
|
|||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
queryLayer = (RepositoryQueryLayer) lookup( RepositoryQueryLayer.ROLE, "test-cached" );
|
RepositoryQueryLayer defaultLayer = new DefaultRepositoryQueryLayer( repository );
|
||||||
|
|
||||||
|
queryLayer = new CachedRepositoryQueryLayer( defaultLayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUseFileCache()
|
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…
x
Reference in New Issue
Block a user