]> source.dussan.org Git - archiva.git/commitdiff
remove use of plexus api (Initializable phase)
authorOlivier Lamy <olamy@apache.org>
Sun, 29 May 2011 18:00:17 +0000 (18:00 +0000)
committerOlivier Lamy <olamy@apache.org>
Sun, 29 May 2011 18:00:17 +0000 (18:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1128918 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/resources/META-INF/spring-context.xml [new file with mode: 0644]
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MockConfiguration.java
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/MimeTypes.java
archiva-modules/archiva-web/archiva-webdav/src/main/resources/META-INF/spring-context.xml [new file with mode: 0644]
archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java
archiva-modules/plugins/metadata-store-jcr/src/main/resources/META-INF/spring-context.xml [new file with mode: 0644]

index bdc82ebddce1dcbde6bc7bc90e504881ec620da9..39a9b204873f902139e343e1a2f09f1ef258542e 100644 (file)
@@ -91,7 +91,6 @@ import java.util.Set;
 @Service( "archivaConfiguration#default" )
 public class DefaultArchivaConfiguration
     implements ArchivaConfiguration, RegistryListener
-    //, Initializable
 {
     private Logger log = LoggerFactory.getLogger( DefaultArchivaConfiguration.class );
 
index 6cecc467ef2c26d5a73f33266b1b887df836b07c..6a774f591d5933d27328510274520ced1744c7f8 100644 (file)
@@ -37,13 +37,16 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
 import org.apache.maven.archiva.consumers.ConsumerException;
 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.registry.Registry;
 import org.codehaus.plexus.registry.RegistryListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
 
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -52,31 +55,35 @@ import java.util.List;
  * Take an artifact off of disk and put it into the metadata repository.
  *
  * @version $Id: ArtifactUpdateDatabaseConsumer.java 718864 2008-11-19 06:33:35Z brett $
- * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
+ * plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
  * role-hint="create-archiva-metadata" instantiation-strategy="per-lookup"
  */
+@Service("knownRepositoryContentConsumer#create-archiva-metadata")
+@Scope("prototype")
 public class ArchivaMetadataCreationConsumer
     extends AbstractMonitoredConsumer
-    implements KnownRepositoryContentConsumer, RegistryListener, Initializable
+    implements KnownRepositoryContentConsumer, RegistryListener
 {
     /**
-     * @plexus.configuration default-value="create-archiva-metadata"
+     * plexus.configuration default-value="create-archiva-metadata"
      */
-    private String id;
+    private String id = "create-archiva-metadata";
 
     /**
-     * @plexus.configuration default-value="Create basic metadata for Archiva to be able to reference the artifact"
+     * plexus.configuration default-value="Create basic metadata for Archiva to be able to reference the artifact"
      */
-    private String description;
+    private String description = "Create basic metadata for Archiva to be able to reference the artifact";
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private ArchivaConfiguration configuration;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private FileTypes filetypes;
 
     private Date whenGathered;
@@ -88,14 +95,17 @@ public class ArchivaMetadataCreationConsumer
      *
      * @plexus.requirement
      */
+    @Inject
     private RepositorySessionFactory repositorySessionFactory;
 
     /**
      * FIXME: this needs to be configurable based on storage type - and could also be instantiated per repo. Change to a
      * factory.
      *
-     * @plexus.requirement role-hint="maven2"
+     * plexus.requirement role-hint="maven2"
      */
+    @Inject
+    @Named(value = "repositoryStorage#maven2")
     private RepositoryStorage repositoryStorage;
 
     private static final Logger log = LoggerFactory.getLogger( ArchivaMetadataCreationConsumer.class );
@@ -243,8 +253,8 @@ public class ArchivaMetadataCreationConsumer
         includes.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) );
     }
 
+    @PostConstruct
     public void initialize()
-        throws InitializationException
     {
         configuration.addChangeListener( this );
 
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/resources/META-INF/spring-context.xml
new file mode 100644 (file)
index 0000000..b08c32d
--- /dev/null
@@ -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.consumers.metadata"/>
+
+</beans>
\ No newline at end of file
index 7fbcda0fd949ff88c809d525fb766b2ceef6454a..f836043fff21b8c2afc893a6b3f98df51a79475f 100644 (file)
@@ -1,5 +1,8 @@
 package org.apache.archiva.metadata.repository;
 
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Configurable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
 import org.springframework.stereotype.Service;
 
 /*
@@ -33,6 +36,8 @@ public class TestRepositorySessionFactory
 
     public void setResolver( MetadataResolver resolver )
     {
+        Configurable configurable;
+        Startable startable;
         this.resolver = resolver;
     }
 }
index cb21dc0e1e7a5a031f72c0ab05b04fd8373c99ff..b6e1ea4802c64c555d676716ae98651e2e728796 100644 (file)
@@ -31,11 +31,11 @@ import org.codehaus.plexus.registry.RegistryException;
 import org.codehaus.plexus.registry.RegistryListener;
 import org.easymock.MockControl;
 import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
-import java.io.File;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -50,13 +50,11 @@ import java.util.Set;
  *          role-hint="mock"
  */
 @Service( "archivaConfiguration#mock" )
+@Scope( "prototype" )
 public class MockConfiguration
     implements ArchivaConfiguration
 {
 
-    @Inject
-    protected ApplicationContext applicationContext;
-
     private Configuration configuration = new Configuration();
 
     private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
@@ -77,17 +75,8 @@ public class MockConfiguration
     public void initialize()
         throws Exception
     {
-
-        // random name or cleanup ??
-        String repoPath = "target/test-repository/managed/" + "foo";//getName();
-        File repoLocation = new File( repoPath );
-        ManagedRepositoryContent managedDefaultRepository =
-            createRepository( AbstractProxyTestCase.ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath,
-                              "default" );
-        ManagedRepositoryConfiguration repoConfig = managedDefaultRepository.getRepository();
-        //configuration.addManagedRepository( repoConfig );
-
-        configuration.setRepositoryScanning( new RepositoryScanningConfiguration(){
+        configuration.setRepositoryScanning( new RepositoryScanningConfiguration()
+        {
             @Override
             public List<FileType> getFileTypes()
             {
@@ -96,21 +85,6 @@ public class MockConfiguration
         } );
     }
 
-    protected ManagedRepositoryContent createRepository( String id, String name, String path, String layout )
-        throws Exception
-    {
-        ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
-        repo.setId( id );
-        repo.setName( name );
-        repo.setLocation( path );
-        repo.setLayout( layout );
-
-        ManagedRepositoryContent repoContent =
-            applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class );
-        repoContent.setRepository( repo );
-        return repoContent;
-    }
-
     public void addChangeListener( RegistryListener listener )
     {
         registryListeners.add( listener );
index 5d28c531640abe47fd2b8d4fdae3fff70309e8be..4e0d9d03d366128ea7e8ae2c1d41425e888c286c 100644 (file)
@@ -77,18 +77,24 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator;
 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 javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import javax.servlet.http.HttpServletResponse;
 
 /**
- * @plexus.component role="org.apache.maven.archiva.webdav.ArchivaDavResourceFactory"
+ * plexus.component role="org.apache.maven.archiva.webdav.ArchivaDavResourceFactory"
  */
+@Service( "davResourceFactory#archiva" )
 public class ArchivaDavResourceFactory
     implements DavResourceFactory, Auditable
 {
@@ -99,48 +105,58 @@ public class ArchivaDavResourceFactory
     private Logger log = LoggerFactory.getLogger( ArchivaDavResourceFactory.class );
 
     /**
-     * @plexus.requirement role="org.apache.archiva.audit.AuditListener"
+     * plexus.requirement role="org.apache.archiva.audit.AuditListener"
      */
     private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private RepositoryContentFactory repositoryFactory;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private RepositoryRequest repositoryRequest;
 
     /**
-     * @plexus.requirement role-hint="default"
+     * plexus.requirement role-hint="default"
      */
+    @Inject
+    @Named( value = "repositoryProxyConnectors#default" )
     private RepositoryProxyConnectors connectors;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private MetadataTools metadataTools;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private MimeTypes mimeTypes;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private ArchivaConfiguration archivaConfiguration;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private ServletAuthenticator servletAuth;
 
     /**
-     * @plexus.requirement role-hint="basic"
+     * plexus.requirement role-hint="basic"
      */
+    @Inject
+    @Named( value = "httpAuthenticator#basic" )
     private HttpAuthenticator httpAuth;
 
     /**
@@ -149,25 +165,42 @@ public class ArchivaDavResourceFactory
     private final LockManager lockManager = new SimpleLockManager();
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private ChecksumFile checksum;
 
     /**
-     * @plexus.requirement role-hint="sha1"
+     * plexus.requirement role-hint="sha1"
      */
+    @Inject
+    @Named( value = "digester#sha1" )
     private Digester digestSha1;
 
     /**
-     * @plexus.requirement role-hint="md5";
+     * plexus.requirement role-hint="md5";
      */
+    @Inject
+    @Named( value = "digester#md5" )
     private Digester digestMd5;
 
     /**
-     * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
+     * plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
      */
+    @Inject
+    @Named( value = "archivaTaskScheduler#repository" )
     private RepositoryArchivaTaskScheduler scheduler;
 
+    @Inject
+    private ApplicationContext applicationContext;
+
+    @PostConstruct
+    public void initialize()
+    {
+        this.auditListeners =
+            new ArrayList<AuditListener>( applicationContext.getBeansOfType( AuditListener.class ).values() );
+    }
+
     public DavResource createResource( final DavResourceLocator locator, final DavServletRequest request,
                                        final DavServletResponse response )
         throws DavException
@@ -231,8 +264,8 @@ public class ArchivaDavResourceFactory
             resource = processRepository( request, archivaLocator, activePrincipal, managedRepository );
 
             String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
-            resourcesInAbsolutePath.add( new File( managedRepository.getRepoRoot(),
-                                                   logicalResource ).getAbsolutePath() );
+            resourcesInAbsolutePath.add(
+                new File( managedRepository.getRepoRoot(), logicalResource ).getAbsolutePath() );
         }
 
         String requestedResource = request.getRequestURI();
@@ -249,24 +282,25 @@ public class ArchivaDavResourceFactory
                 artifactId = StringUtils.substringAfterLast( artifactId, "/" );
 
                 ArchivaDavResource res = (ArchivaDavResource) resource;
-                String filePath = StringUtils.substringBeforeLast( res.getLocalResource().getAbsolutePath().replace(
-                    '\\', '/' ), "/" );
+                String filePath =
+                    StringUtils.substringBeforeLast( res.getLocalResource().getAbsolutePath().replace( '\\', '/' ),
+                                                     "/" );
                 filePath = filePath + "/maven-metadata-" + repoGroupConfig.getId() + ".xml";
 
                 // for MRM-872 handle checksums of the merged metadata files
                 if ( repositoryRequest.isSupportFile( requestedResource ) )
                 {
-                    File metadataChecksum = new File( filePath + "." + StringUtils.substringAfterLast(
-                        requestedResource, "." ) );
+                    File metadataChecksum =
+                        new File( filePath + "." + StringUtils.substringAfterLast( requestedResource, "." ) );
                     if ( metadataChecksum.exists() )
                     {
-                        LogicalResource logicalResource = new LogicalResource( RepositoryPathUtil.getLogicalResource(
-                            locator.getResourcePath() ) );
+                        LogicalResource logicalResource =
+                            new LogicalResource( RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ) );
 
-                        resource = new ArchivaDavResource( metadataChecksum.getAbsolutePath(),
-                                                           logicalResource.getPath(), null, request.getRemoteAddr(),
-                                                           activePrincipal, request.getDavSession(), archivaLocator,
-                                                           this, mimeTypes, auditListeners, scheduler );
+                        resource =
+                            new ArchivaDavResource( metadataChecksum.getAbsolutePath(), logicalResource.getPath(), null,
+                                                    request.getRemoteAddr(), activePrincipal, request.getDavSession(),
+                                                    archivaLocator, this, mimeTypes, auditListeners, scheduler );
                     }
                 }
                 else
@@ -297,10 +331,11 @@ public class ArchivaDavResourceFactory
                             LogicalResource logicalResource = new LogicalResource(
                                 RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ) );
 
-                            resource = new ArchivaDavResource( resourceFile.getAbsolutePath(),
-                                                               logicalResource.getPath(), null, request.getRemoteAddr(),
-                                                               activePrincipal, request.getDavSession(), archivaLocator,
-                                                               this, mimeTypes, auditListeners, scheduler );
+                            resource =
+                                new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(), null,
+                                                        request.getRemoteAddr(), activePrincipal,
+                                                        request.getDavSession(), archivaLocator, this, mimeTypes,
+                                                        auditListeners, scheduler );
                         }
                         catch ( RepositoryMetadataException r )
                         {
@@ -359,8 +394,8 @@ public class ArchivaDavResourceFactory
 
             try
             {
-                DavResource updatedResource = processRepository( request, archivaLocator, activePrincipal,
-                                                                 managedRepository );
+                DavResource updatedResource =
+                    processRepository( request, archivaLocator, activePrincipal, managedRepository );
                 if ( resource == null )
                 {
                     resource = updatedResource;
@@ -371,8 +406,8 @@ public class ArchivaDavResourceFactory
                 {
                     logicalResource = logicalResource.substring( 1 );
                 }
-                resourcesInAbsolutePath.add( new File( managedRepository.getRepoRoot(),
-                                                       logicalResource ).getAbsolutePath() );
+                resourcesInAbsolutePath.add(
+                    new File( managedRepository.getRepoRoot(), logicalResource ).getAbsolutePath() );
             }
             catch ( DavException e )
             {
@@ -443,15 +478,14 @@ public class ArchivaDavResourceFactory
                         {
                             // Perform an adjustment of the resource to the managed
                             // repository expected path.
-                            String localResourcePath = repositoryRequest.toNativePath( logicalResource.getPath(),
-                                                                                       managedRepository );
+                            String localResourcePath =
+                                repositoryRequest.toNativePath( logicalResource.getPath(), managedRepository );
                             resourceFile = new File( managedRepository.getRepoRoot(), localResourcePath );
-                            resource = new ArchivaDavResource( resourceFile.getAbsolutePath(),
-                                                               logicalResource.getPath(),
-                                                               managedRepository.getRepository(),
-                                                               request.getRemoteAddr(), activePrincipal,
-                                                               request.getDavSession(), archivaLocator, this, mimeTypes,
-                                                               auditListeners, scheduler );
+                            resource =
+                                new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(),
+                                                        managedRepository.getRepository(), request.getRemoteAddr(),
+                                                        activePrincipal, request.getDavSession(), archivaLocator, this,
+                                                        mimeTypes, auditListeners, scheduler );
                         }
                         catch ( LayoutException e )
                         {
@@ -463,11 +497,11 @@ public class ArchivaDavResourceFactory
 
                         if ( fromProxy )
                         {
-                            String event = ( previouslyExisted ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE ) +
-                                PROXIED_SUFFIX;
+                            String event = ( previouslyExisted ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE )
+                                PROXIED_SUFFIX;
 
-                            log.debug( "Proxied artifact '" + resourceFile.getName() + "' in repository '" +
-                                managedRepository.getId() + "' (current user '" + activePrincipal + "')" );
+                            log.debug( "Proxied artifact '" + resourceFile.getName() + "' in repository '"
+                                           + managedRepository.getId() + "' (current user '" + activePrincipal + "')" );
 
                             triggerAuditEvent( request.getRemoteAddr(), archivaLocator.getRepositoryId(),
                                                logicalResource.getPath(), event, activePrincipal );
@@ -487,8 +521,8 @@ public class ArchivaDavResourceFactory
 
                 // check if target repo is enabled for releases
                 // we suppose that release-artifacts can be deployed only to repos enabled for releases
-                if ( managedRepository.getRepository().isReleases() && !repositoryRequest.isMetadata( resourcePath ) &&
-                    !repositoryRequest.isSupportFile( resourcePath ) )
+                if ( managedRepository.getRepository().isReleases() && !repositoryRequest.isMetadata( resourcePath )
+                    && !repositoryRequest.isSupportFile( resourcePath ) )
                 {
                     ArtifactReference artifact = null;
                     try
@@ -498,11 +532,11 @@ public class ArchivaDavResourceFactory
                         if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
                         {
                             // check if artifact already exists and if artifact re-deployment to the repository is allowed
-                            if ( managedRepository.hasContent( artifact ) &&
-                                managedRepository.getRepository().isBlockRedeployments() )
+                            if ( managedRepository.hasContent( artifact )
+                                && managedRepository.getRepository().isBlockRedeployments() )
                             {
-                                log.warn( "Overwriting released artifacts in repository '" + managedRepository.getId() +
-                                    "' is not allowed." );
+                                log.warn( "Overwriting released artifacts in repository '" + managedRepository.getId()
+                                              + "' is not allowed." );
                                 throw new DavException( HttpServletResponse.SC_CONFLICT,
                                                         "Overwriting released artifacts is not allowed." );
                             }
@@ -530,8 +564,8 @@ public class ArchivaDavResourceFactory
                     String relPath = PathUtil.getRelative( rootDirectory.getAbsolutePath(), destDir );
 
                     log.debug(
-                        "Creating destination directory '" + destDir.getName() + "' (current user '" + activePrincipal +
-                            "')" );
+                        "Creating destination directory '" + destDir.getName() + "' (current user '" + activePrincipal
+                            "')" );
 
                     triggerAuditEvent( request.getRemoteAddr(), managedRepository.getId(), relPath,
                                        AuditEvent.CREATE_DIR, activePrincipal );
@@ -567,9 +601,9 @@ public class ArchivaDavResourceFactory
             logicalResource = logicalResource.substring( 1 );
         }
         File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource );
-        DavResource resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource,
-                                                       managedRepository.getRepository(), davSession, archivaLocator,
-                                                       this, mimeTypes, auditListeners, scheduler );
+        DavResource resource =
+            new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource, managedRepository.getRepository(),
+                                    davSession, archivaLocator, this, mimeTypes, auditListeners, scheduler );
 
         resource.addLockManager( lockManager );
         return resource;
@@ -607,8 +641,8 @@ public class ArchivaDavResourceFactory
 
                 resource.setPath( managedRepository.toPath( artifact ) );
 
-                log.debug( "Proxied artifact '" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" +
-                    artifact.getVersion() + "'" );
+                log.debug( "Proxied artifact '" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":"
+                               + artifact.getVersion() + "'" );
 
                 return ( proxiedFile != null );
             }
@@ -630,7 +664,7 @@ public class ArchivaDavResourceFactory
      * A relocation capable client will request the POM prior to the artifact, and will then read meta-data and do
      * client side relocation. A simplier client (like maven 1) will only request the artifact and not use the
      * metadatas.
-     * <p>
+     * <p/>
      * For such clients, archiva does server-side relocation by reading itself the &lt;relocation&gt; element in
      * metadatas and serving the expected artifact.
      */
@@ -916,8 +950,8 @@ public class ArchivaDavResourceFactory
                         {
                             // TODO: review exception handling
                             log.debug(
-                                "Skipping repository '" + managedRepository + "' for user '" + activePrincipal + "': " +
-                                    e.getMessage() );
+                                "Skipping repository '" + managedRepository + "' for user '" + activePrincipal + "': "
+                                    e.getMessage() );
                         }
                     }
                     else
@@ -937,8 +971,8 @@ public class ArchivaDavResourceFactory
                         {
                             // TODO: review exception handling
                             log.debug(
-                                "Skipping repository '" + managedRepository + "' for user '" + activePrincipal + "': " +
-                                    e.getMessage() );
+                                "Skipping repository '" + managedRepository + "' for user '" + activePrincipal + "': "
+                                    e.getMessage() );
                         }
                     }
                 }
@@ -949,9 +983,9 @@ public class ArchivaDavResourceFactory
             throw new UnauthorizedDavException( locator.getRepositoryId(), "User not authorized." );
         }
 
-        ArchivaVirtualDavResource resource = new ArchivaVirtualDavResource( mergedRepositoryContents,
-                                                                            logicalResource.getPath(), mimeTypes,
-                                                                            locator, this );
+        ArchivaVirtualDavResource resource =
+            new ArchivaVirtualDavResource( mergedRepositoryContents, logicalResource.getPath(), mimeTypes, locator,
+                                           this );
 
         // compatibility with MRM-440 to ensure browsing the repository group works ok
         if ( resource.isCollection() && !request.getRequestURI().endsWith( "/" ) )
@@ -1005,8 +1039,8 @@ public class ArchivaDavResourceFactory
             {
                 try
                 {
-                    if ( servletAuth.isAuthorized( activePrincipal, repository, WebdavMethodUtil.getMethodPermission(
-                        request.getMethod() ) ) )
+                    if ( servletAuth.isAuthorized( activePrincipal, repository,
+                                                   WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) )
                     {
                         allow = true;
                         break;
index d1fb7b97fc018e742ed2d7f8d1012d884be65d37..37128166553f7574baf5b35899e4dedd673a4286 100644 (file)
@@ -19,6 +19,13 @@ package org.apache.maven.archiva.webdav.util;
  * under the License.
  */
 
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -31,22 +38,15 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * MimeTypes 
  *
  * @version $Id: MimeTypes.java 7010 2007-10-25 23:35:02Z joakime $
  * 
- * @plexus.component role="org.apache.maven.archiva.webdav.util.MimeTypes"
+ * plexus.component role="org.apache.maven.archiva.webdav.util.MimeTypes"
  */
+@Service("mimeTpes")
 public class MimeTypes
-    implements Initializable
 {
     private static final String DEFAULT_MIME_TYPE = "application/octet-stream";
 
@@ -85,8 +85,8 @@ public class MimeTypes
 
     }
 
+    @PostConstruct
     public void initialize()
-        throws InitializationException
     {
         load( resource );
     }
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-webdav/src/main/resources/META-INF/spring-context.xml
new file mode 100644 (file)
index 0000000..89ad590
--- /dev/null
@@ -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.maven.archiva.webdav"/>
+
+</beans>
\ No newline at end of file
index 56331a3ad7d0193e6f20e38c66e7682a9b5fca25..2710ce2b27e90834877b2ad1c716fae09756ed26 100644 (file)
@@ -24,32 +24,41 @@ 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.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
 
-import java.util.Map;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
+import java.util.Map;
 
 /**
- * @plexus.component role="org.apache.archiva.metadata.repository.RepositorySessionFactory" role-hint="jcr"
+ * plexus.component role="org.apache.archiva.metadata.repository.RepositorySessionFactory" role-hint="jcr"
  */
+@Service( "repositorySessionFactory#jcr" )
 public class JcrRepositorySessionFactory
-    implements RepositorySessionFactory, Initializable
+    implements RepositorySessionFactory
 {
+
+    @Inject
+    private ApplicationContext applicationContext;
+
     /**
-     * @plexus.requirement role="org.apache.archiva.metadata.model.MetadataFacetFactory"
+     * plexus.requirement role="org.apache.archiva.metadata.model.MetadataFacetFactory"
      */
     private Map<String, MetadataFacetFactory> metadataFacetFactories;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private Repository repository;
 
     /**
-     * @plexus.requirement
+     * plexus.requirement
      */
+    @Inject
     private MetadataResolver metadataResolver;
 
     public RepositorySession createSession()
@@ -72,9 +81,11 @@ public class JcrRepositorySessionFactory
         }
     }
 
+    @PostConstruct
     public void initialize()
-        throws InitializationException
     {
+        metadataFacetFactories = applicationContext.getBeansOfType( MetadataFacetFactory.class );
+
         JcrMetadataRepository metadataRepository = null;
         try
         {
@@ -83,7 +94,7 @@ public class JcrRepositorySessionFactory
         }
         catch ( RepositoryException e )
         {
-            throw new InitializationException( e.getMessage(), e );
+            throw new RuntimeException( e.getMessage(), e );
         }
         finally
         {
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/resources/META-INF/spring-context.xml b/archiva-modules/plugins/metadata-store-jcr/src/main/resources/META-INF/spring-context.xml
new file mode 100644 (file)
index 0000000..0e5db0d
--- /dev/null
@@ -0,0 +1,35 @@
+<?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.maven.archiva.configuration"/>
+  <!-- olamy could be removed as only here temporary for plexus-spring -->
+  <alias name="archivaConfiguration#default" alias="archivaConfiguration"/>
+
+</beans>
\ No newline at end of file