001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.connector.basic; 020 021import javax.inject.Inject; 022import javax.inject.Named; 023 024import java.util.Map; 025 026import org.eclipse.aether.RepositorySystemSession; 027import org.eclipse.aether.repository.RemoteRepository; 028import org.eclipse.aether.spi.checksums.ProvidedChecksumsSource; 029import org.eclipse.aether.spi.connector.RepositoryConnector; 030import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; 031import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider; 032import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider; 033import org.eclipse.aether.spi.connector.transport.TransporterProvider; 034import org.eclipse.aether.spi.io.ChecksumProcessor; 035import org.eclipse.aether.transfer.NoRepositoryConnectorException; 036 037import static java.util.Objects.requireNonNull; 038 039/** 040 * A repository connector factory that employs pluggable 041 * {@link org.eclipse.aether.spi.connector.transport.TransporterFactory transporters} and 042 * {@link org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory repository layouts} for the transfers. 043 */ 044@Named(BasicRepositoryConnectorFactory.NAME) 045public final class BasicRepositoryConnectorFactory implements RepositoryConnectorFactory { 046 public static final String NAME = "basic"; 047 private final TransporterProvider transporterProvider; 048 049 private final RepositoryLayoutProvider layoutProvider; 050 051 private final ChecksumPolicyProvider checksumPolicyProvider; 052 053 private final ChecksumProcessor checksumProcessor; 054 055 private final Map<String, ProvidedChecksumsSource> providedChecksumsSources; 056 057 private float priority; 058 059 @Inject 060 public BasicRepositoryConnectorFactory( 061 TransporterProvider transporterProvider, 062 RepositoryLayoutProvider layoutProvider, 063 ChecksumPolicyProvider checksumPolicyProvider, 064 ChecksumProcessor checksumProcessor, 065 Map<String, ProvidedChecksumsSource> providedChecksumsSources) { 066 this.transporterProvider = requireNonNull(transporterProvider, "transporter provider cannot be null"); 067 this.layoutProvider = requireNonNull(layoutProvider, "repository layout provider cannot be null"); 068 this.checksumPolicyProvider = requireNonNull(checksumPolicyProvider, "checksum policy provider cannot be null"); 069 this.checksumProcessor = requireNonNull(checksumProcessor, "checksum processor cannot be null"); 070 this.providedChecksumsSources = 071 requireNonNull(providedChecksumsSources, "provided checksum sources cannot be null"); 072 } 073 074 @Override 075 public float getPriority() { 076 return priority; 077 } 078 079 /** 080 * Sets the priority of this component. 081 * 082 * @param priority The priority. 083 * @return This component for chaining, never {@code null}. 084 */ 085 public BasicRepositoryConnectorFactory setPriority(float priority) { 086 this.priority = priority; 087 return this; 088 } 089 090 @Override 091 public RepositoryConnector newInstance(RepositorySystemSession session, RemoteRepository repository) 092 throws NoRepositoryConnectorException { 093 requireNonNull(session, "session cannot be null"); 094 requireNonNull(repository, "repository cannot be null"); 095 096 return new BasicRepositoryConnector( 097 session, 098 repository, 099 transporterProvider, 100 layoutProvider, 101 checksumPolicyProvider, 102 checksumProcessor, 103 providedChecksumsSources); 104 } 105}