diff options
author | Olivier Lamy <olamy@apache.org> | 2011-06-01 13:48:32 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-06-01 13:48:32 +0000 |
commit | 76386bfcb1f4476f25eca5ac215263c1451a1cfd (patch) | |
tree | 7bb3b3e010837110d2b3a93f5049dfb3d68a0d12 /archiva-modules/plugins | |
parent | 09292c0037ee7206a357679fce4242983c3c0dca (diff) | |
download | archiva-76386bfcb1f4476f25eca5ac215263c1451a1cfd.tar.gz archiva-76386bfcb1f4476f25eca5ac215263c1451a1cfd.zip |
[MRM-1473] remove use of plexus-spring
fix module metadata-store-file
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1130154 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins')
4 files changed, 81 insertions, 15 deletions
diff --git a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index df353fa19..bd75b5720 100644 --- a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -67,7 +67,7 @@ public class FileMetadataRepository private final ArchivaConfiguration configuration; - private static final Logger log = LoggerFactory.getLogger( FileMetadataRepository.class ); + private Logger log = LoggerFactory.getLogger( FileMetadataRepository.class ); private static final String PROJECT_METADATA_KEY = "project-metadata"; @@ -118,7 +118,7 @@ public class FileMetadataRepository catch ( IOException e ) { // TODO! - e.printStackTrace(); + log.error( e.getMessage(), e ); } } @@ -222,7 +222,7 @@ public class FileMetadataRepository catch ( IOException e ) { // TODO - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + log.error( e.getMessage(), e ); } } @@ -279,7 +279,7 @@ public class FileMetadataRepository catch ( IOException e ) { // TODO - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + log.error( e.getMessage(), e ); } } @@ -296,7 +296,7 @@ public class FileMetadataRepository catch ( IOException e ) { // TODO! - e.printStackTrace(); + log.error( e.getMessage(), e ); } } @@ -342,7 +342,7 @@ public class FileMetadataRepository catch ( IOException e ) { // TODO - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + log.error( e.getMessage(), e ); return null; } MetadataFacet metadataFacet = null; @@ -375,7 +375,7 @@ public class FileMetadataRepository catch ( IOException e ) { // TODO! - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + log.error( e.getMessage(), e ); } } @@ -746,7 +746,7 @@ public class FileMetadataRepository catch ( IOException e ) { // TODO - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + log.error( e.getMessage(), e ); } return new Properties(); } @@ -933,7 +933,7 @@ public class FileMetadataRepository MetadataFacetFactory factory = metadataFacetFactories.get( facetId ); if ( factory == null ) { - log.error( "Attempted to load unknown project version metadata facet: " + facetId ); + log.error( "Attempted to load unknown project version metadata facet: {}", facetId ); } else { diff --git a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileRepositorySessionFactory.java b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileRepositorySessionFactory.java index 4301fc025..9b3ea500e 100644 --- a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileRepositorySessionFactory.java +++ b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileRepositorySessionFactory.java @@ -24,13 +24,21 @@ import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataResolver; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; +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.HashMap; import java.util.Map; /** - * @plexus.component role="org.apache.archiva.metadata.repository.RepositorySessionFactory" role-hint="file" + * plexus.component role="org.apache.archiva.metadata.repository.RepositorySessionFactory" role-hint="file" */ +@Service( "repositorySessionFactory#file" ) public class FileRepositorySessionFactory implements RepositorySessionFactory { @@ -40,15 +48,38 @@ public class FileRepositorySessionFactory private Map<String, MetadataFacetFactory> metadataFacetFactories; /** - * @plexus.requirement + * plexus.requirement */ + @Inject + @Named( value = "archivaConfiguration#default" ) private ArchivaConfiguration configuration; /** - * @plexus.requirement + * plexus.requirement */ + @Inject private MetadataResolver metadataResolver; + @Inject + private ApplicationContext applicationContext; + + @PostConstruct + public void initialize() + { + Map<String, MetadataFacetFactory> tmpMetadataFacetFactories = + applicationContext.getBeansOfType( MetadataFacetFactory.class ); + // olamy with spring the "id" is now "metadataFacetFactory#hint" + // whereas was only hint with plexus so let remove metadataFacetFactory# + metadataFacetFactories = new HashMap<String, MetadataFacetFactory>( tmpMetadataFacetFactories.size() ); + + for ( Map.Entry<String, MetadataFacetFactory> entry : tmpMetadataFacetFactories.entrySet() ) + { + metadataFacetFactories.put( StringUtils.substringAfterLast( entry.getKey(), "#" ), entry.getValue() ); + } + + + } + public RepositorySession createSession() { MetadataRepository metadataRepository = new FileMetadataRepository( metadataFacetFactories, configuration ); diff --git a/archiva-modules/plugins/metadata-store-file/src/main/resources/META-INF/spring-context.xml b/archiva-modules/plugins/metadata-store-file/src/main/resources/META-INF/spring-context.xml new file mode 100755 index 000000000..c5f30ba5c --- /dev/null +++ b/archiva-modules/plugins/metadata-store-file/src/main/resources/META-INF/spring-context.xml @@ -0,0 +1,33 @@ +<?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.file"/> + +</beans>
\ No newline at end of file diff --git a/archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java index 3922ec0ea..05693af32 100644 --- a/archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java +++ b/archiva-modules/plugins/metadata-store-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java @@ -41,9 +41,11 @@ public class FileMetadataRepositoryTest { super.setUp(); - File directory = getTestFile( "target/test-repositories" ); - FileUtils.deleteDirectory( directory ); - + File directory = new File( "target/test-repositories" ); + if (directory.exists()) + { + FileUtils.deleteDirectory( directory ); + } ArchivaConfiguration config = createTestConfiguration( directory ); Map<String, MetadataFacetFactory> factories = createTestMetadataFacetFactories(); |