aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-05-26 20:52:13 +0000
committerOlivier Lamy <olamy@apache.org>2011-05-26 20:52:13 +0000
commit1788eb54c492ac4a0f3efd6d4d504fd8fc55d26c (patch)
tree6f6ff2e608639c0ff425ade6c7516a7858f30507 /archiva-modules/metadata
parent16714e5e4dc72fa81589ebe23a4cbe49f57be462 (diff)
downloadarchiva-1788eb54c492ac4a0f3efd6d4d504fd8fc55d26c.tar.gz
archiva-1788eb54c492ac4a0f3efd6d4d504fd8fc55d26c.zip
[MRM-1473] remove use of plexus-spring
remove all dependencies to plexus-container use of sisu-inject-plexus (version 2.2.2 with ASL license) for components using maven api components. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1128075 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/pom.xml13
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java71
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/resources/META-INF/spring-context.xml34
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java4
4 files changed, 87 insertions, 35 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/pom.xml b/archiva-modules/metadata/metadata-repository-api/pom.xml
index f93c46365..30e4ef8b8 100644
--- a/archiva-modules/metadata/metadata-repository-api/pom.xml
+++ b/archiva-modules/metadata/metadata-repository-api/pom.xml
@@ -27,6 +27,14 @@
<name>Archiva Metadata Repository API</name>
<dependencies>
<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-model</artifactId>
</dependency>
@@ -34,11 +42,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.codehaus.redback.components</groupId>
- <artifactId>plexus-spring</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<plugins>
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
index 08115b1cb..903cbf199 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
@@ -30,7 +30,12 @@ import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataN
import org.apache.archiva.repository.events.RepositoryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -38,42 +43,57 @@ import java.util.List;
/**
* Default implementation of the metadata resolver API. At present it will handle updating the content repository
* from new or changed information in the model and artifacts from the repository storage.
- *
+ * <p/>
* This is a singleton component to allow an alternate implementation to be provided. It is intended to be the same
* system-wide for the whole content repository instead of on a per-managed-repository basis. Therefore, the session is
* passed in as an argument to obtain any necessary resources, rather than the class being instantiated within the
* session in the context of a single managed repository's resolution needs.
- *
+ * <p/>
* Note that the caller is responsible for the session, such as closing and saving (which is implied by the resolver
* being obtained from within the session). The {@link RepositorySession#markDirty()} method is used as a hint to ensure
* that the session knows we've made changes at close. We cannot ensure the changes will be persisted if the caller
* chooses to revert first. This is preferable to storing the metadata immediately - a separate session would require
* having a bi-directional link with the session factory, and saving the existing session might save other changes
* unknowingly by the caller.
- *
- * @plexus.component role="org.apache.archiva.metadata.repository.MetadataResolver"
+ * <p/>
+ * plexus.component role="org.apache.archiva.metadata.repository.MetadataResolver"
*/
+@Service( "metadataResolver#default" )
public class DefaultMetadataResolver
implements MetadataResolver
{
+
+ private Logger log = LoggerFactory.getLogger( DefaultMetadataResolver.class );
+
/**
* FIXME: this needs to be configurable based on storage type - and could also be instantiated per repo. Change to a
* factory, and perhaps retrieve from the session. We should avoid creating one per request, however.
- *
+ * <p/>
* TODO: Also need to accommodate availability of proxy module
* ... could be a different type since we need methods to modify the storage metadata, which would also allow more
* appropriate methods to pass in the already determined repository configuration, for example, instead of the ID
*
* @plexus.requirement role-hint="maven2"
*/
+ @Inject
+ @Named( value = "repositoryStorage#maven2" )
private RepositoryStorage repositoryStorage;
/**
- * @plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener"
+ * plexus.requirement role="org.apache.archiva.repository.events.RepositoryListener"
*/
private List<RepositoryListener> listeners;
- private static final Logger log = LoggerFactory.getLogger( DefaultMetadataResolver.class );
+
+ @Inject
+ private ApplicationContext applicationContext;
+
+ @PostConstruct
+ private void initialize()
+ {
+ listeners =
+ new ArrayList<RepositoryListener>( applicationContext.getBeansOfType( RepositoryListener.class ).values() );
+ }
public ProjectVersionMetadata resolveProjectVersion( RepositorySession session, String repoId, String namespace,
String projectId, String projectVersion )
@@ -81,8 +101,8 @@ public class DefaultMetadataResolver
{
MetadataRepository metadataRepository = session.getRepository();
- ProjectVersionMetadata metadata = metadataRepository.getProjectVersion( repoId, namespace, projectId,
- projectVersion );
+ ProjectVersionMetadata metadata =
+ metadataRepository.getProjectVersion( repoId, namespace, projectId, projectVersion );
// TODO: do we want to detect changes as well by comparing timestamps? isProjectVersionNewerThan(updated)
// in such cases we might also remove/update stale metadata, including adjusting plugin-based facets
// This would also be better than checking for completeness - we can then refresh only when fixed (though
@@ -159,8 +179,8 @@ public class DefaultMetadataResolver
{
MetadataRepository metadataRepository = session.getRepository();
Collection<String> namespaces = metadataRepository.getRootNamespaces( repoId );
- Collection<String> storageNamespaces = repositoryStorage.listRootNamespaces( repoId, new ExcludesFilter<String>(
- namespaces ) );
+ Collection<String> storageNamespaces =
+ repositoryStorage.listRootNamespaces( repoId, new ExcludesFilter<String>( namespaces ) );
if ( storageNamespaces != null && !storageNamespaces.isEmpty() )
{
if ( log.isDebugEnabled() )
@@ -193,9 +213,8 @@ public class DefaultMetadataResolver
Collection<String> namespaces = metadataRepository.getNamespaces( repoId, namespace );
Collection<String> exclusions = new ArrayList<String>( namespaces );
exclusions.addAll( metadataRepository.getProjects( repoId, namespace ) );
- Collection<String> storageNamespaces = repositoryStorage.listNamespaces( repoId, namespace,
- new ExcludesFilter<String>(
- exclusions ) );
+ Collection<String> storageNamespaces =
+ repositoryStorage.listNamespaces( repoId, namespace, new ExcludesFilter<String>( exclusions ) );
if ( storageNamespaces != null && !storageNamespaces.isEmpty() )
{
if ( log.isDebugEnabled() )
@@ -228,8 +247,8 @@ public class DefaultMetadataResolver
Collection<String> projects = metadataRepository.getProjects( repoId, namespace );
Collection<String> exclusions = new ArrayList<String>( projects );
exclusions.addAll( metadataRepository.getNamespaces( repoId, namespace ) );
- Collection<String> storageProjects = repositoryStorage.listProjects( repoId, namespace,
- new ExcludesFilter<String>( exclusions ) );
+ Collection<String> storageProjects =
+ repositoryStorage.listProjects( repoId, namespace, new ExcludesFilter<String>( exclusions ) );
if ( storageProjects != null && !storageProjects.isEmpty() )
{
if ( log.isDebugEnabled() )
@@ -278,10 +297,8 @@ public class DefaultMetadataResolver
{
try
{
- ProjectVersionMetadata versionMetadata = repositoryStorage.readProjectVersionMetadata( repoId,
- namespace,
- projectId,
- projectVersion );
+ ProjectVersionMetadata versionMetadata =
+ repositoryStorage.readProjectVersionMetadata( repoId, namespace, projectId, projectVersion );
for ( RepositoryListener listener : listeners )
{
listener.addArtifact( session, repoId, namespace, projectId, versionMetadata );
@@ -295,8 +312,8 @@ public class DefaultMetadataResolver
}
catch ( RepositoryStorageMetadataInvalidException e )
{
- log.warn( "Not update project in metadata repository due to an error resolving it from storage: " +
- e.getMessage() );
+ log.warn( "Not update project in metadata repository due to an error resolving it from storage: "
+ + e.getMessage() );
for ( RepositoryListener listener : listeners )
{
@@ -324,13 +341,11 @@ public class DefaultMetadataResolver
throws MetadataResolutionException
{
MetadataRepository metadataRepository = session.getRepository();
- Collection<ArtifactMetadata> artifacts = metadataRepository.getArtifacts( repoId, namespace, projectId,
- projectVersion );
+ Collection<ArtifactMetadata> artifacts =
+ metadataRepository.getArtifacts( repoId, namespace, projectId, projectVersion );
ExcludesFilter<String> filter = new ExcludesFilter<String>( createArtifactIdList( artifacts ) );
- Collection<ArtifactMetadata> storageArtifacts = repositoryStorage.readArtifactsMetadata( repoId, namespace,
- projectId,
- projectVersion,
- filter );
+ Collection<ArtifactMetadata> storageArtifacts =
+ repositoryStorage.readArtifactsMetadata( repoId, namespace, projectId, projectVersion, filter );
if ( storageArtifacts != null && !storageArtifacts.isEmpty() )
{
if ( log.isDebugEnabled() )
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/resources/META-INF/spring-context.xml b/archiva-modules/metadata/metadata-repository-api/src/main/resources/META-INF/spring-context.xml
new file mode 100644
index 000000000..6e1dc2489
--- /dev/null
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/resources/META-INF/spring-context.xml
@@ -0,0 +1,34 @@
+<?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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:annotation-config/>
+ <context:component-scan base-package="org.apache.archiva.metadata.repository"/>
+
+
+</beans> \ No newline at end of file
diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
index 2d9c87bd7..9d45c8ded 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
@@ -19,6 +19,7 @@ package org.apache.archiva.metadata.repository;
* under the License.
*/
+import junit.framework.TestCase;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.CiManagement;
import org.apache.archiva.metadata.model.Dependency;
@@ -31,7 +32,6 @@ import org.apache.archiva.metadata.model.Organization;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.Scm;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,7 +44,7 @@ import java.util.List;
import java.util.Map;
public abstract class AbstractMetadataRepositoryTest
- extends PlexusInSpringTestCase
+ extends TestCase
{
protected static final String OTHER_REPO_ID = "other-repo";