This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.dependency.tree.maven2;
002/*
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *   http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
022import org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider;
023import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
024import org.slf4j.Logger;
025import org.slf4j.LoggerFactory;
026import org.eclipse.aether.RepositorySystemSession;
027import org.eclipse.aether.repository.RemoteRepository;
028import org.eclipse.aether.spi.connector.ArtifactDownload;
029import org.eclipse.aether.spi.connector.ArtifactUpload;
030import org.eclipse.aether.spi.connector.MetadataDownload;
031import org.eclipse.aether.spi.connector.MetadataUpload;
032import org.eclipse.aether.spi.connector.RepositoryConnector;
033import org.eclipse.aether.transfer.NoRepositoryConnectorException;
034
035import java.util.Collection;
036
037/**
038 *
039 * Creates a dummy connector, if the default connectory factory fails to create one.
040 *
041 * @author Olivier Lamy
042 * @since 1.4-M3
043 */
044public class ArchivaRepositoryConnectorFactory
045    implements RepositoryConnectorFactory
046{
047
048    private BasicRepositoryConnectorFactory delegate = new BasicRepositoryConnectorFactory();
049
050    public ArchivaRepositoryConnectorFactory()
051    {
052        // no op but empty constructor needed by aether
053        delegate.setRepositoryLayoutProvider(new DefaultRepositoryLayoutProvider());
054    }
055
056    @Override
057    public RepositoryConnector newInstance( RepositorySystemSession session, RemoteRepository repository )
058        throws NoRepositoryConnectorException
059    {
060        try
061        {
062            return delegate.newInstance( session, repository );
063        }
064        catch ( NoRepositoryConnectorException e )
065        {
066
067        }
068
069        return new RepositoryConnector()
070        {
071
072            private Logger log = LoggerFactory.getLogger( getClass() );
073
074            @Override
075            public void get( Collection<? extends ArtifactDownload> artifactDownloads,
076                             Collection<? extends MetadataDownload> metadataDownloads )
077            {
078                log.debug( "get" );
079            }
080
081            @Override
082            public void put( Collection<? extends ArtifactUpload> artifactUploads,
083                             Collection<? extends MetadataUpload> metadataUploads )
084            {
085                log.debug( "put" );
086            }
087
088            @Override
089            public void close()
090            {
091                log.debug( "close" );
092            }
093        };
094    }
095
096    @Override
097    public float getPriority( )
098    {
099        return 0;
100    }
101}