This project has retired. For details please refer to its Attic page.
ArchivaRepositoryConnectorFactory xref
View Javadoc
1   package org.apache.archiva.dependency.tree.maven2;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
22  import org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider;
23  import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  import org.eclipse.aether.RepositorySystemSession;
27  import org.eclipse.aether.repository.RemoteRepository;
28  import org.eclipse.aether.spi.connector.ArtifactDownload;
29  import org.eclipse.aether.spi.connector.ArtifactUpload;
30  import org.eclipse.aether.spi.connector.MetadataDownload;
31  import org.eclipse.aether.spi.connector.MetadataUpload;
32  import org.eclipse.aether.spi.connector.RepositoryConnector;
33  import org.eclipse.aether.transfer.NoRepositoryConnectorException;
34  
35  import java.util.Collection;
36  
37  /**
38   *
39   * Creates a dummy connector, if the default connectory factory fails to create one.
40   *
41   * @author Olivier Lamy
42   * @since 1.4-M3
43   */
44  public class ArchivaRepositoryConnectorFactory
45      implements RepositoryConnectorFactory
46  {
47  
48      private BasicRepositoryConnectorFactory delegate = new BasicRepositoryConnectorFactory();
49  
50      public ArchivaRepositoryConnectorFactory()
51      {
52          // no op but empty constructor needed by aether
53          delegate.setRepositoryLayoutProvider(new DefaultRepositoryLayoutProvider());
54      }
55  
56      @Override
57      public RepositoryConnector newInstance( RepositorySystemSession session, RemoteRepository repository )
58          throws NoRepositoryConnectorException
59      {
60          try
61          {
62              return delegate.newInstance( session, repository );
63          }
64          catch ( NoRepositoryConnectorException e )
65          {
66  
67          }
68  
69          return new RepositoryConnector()
70          {
71  
72              private Logger log = LoggerFactory.getLogger( getClass() );
73  
74              @Override
75              public void get( Collection<? extends ArtifactDownload> artifactDownloads,
76                               Collection<? extends MetadataDownload> metadataDownloads )
77              {
78                  log.debug( "get" );
79              }
80  
81              @Override
82              public void put( Collection<? extends ArtifactUpload> artifactUploads,
83                               Collection<? extends MetadataUpload> metadataUploads )
84              {
85                  log.debug( "put" );
86              }
87  
88              @Override
89              public void close()
90              {
91                  log.debug( "close" );
92              }
93          };
94      }
95  
96      @Override
97      public float getPriority( )
98      {
99          return 0;
100     }
101 }