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.transport.file; 020 021import javax.inject.Named; 022 023import java.util.Objects; 024 025import org.eclipse.aether.RepositorySystemSession; 026import org.eclipse.aether.repository.RemoteRepository; 027import org.eclipse.aether.spi.connector.transport.Transporter; 028import org.eclipse.aether.spi.connector.transport.TransporterFactory; 029import org.eclipse.aether.transfer.NoTransporterException; 030 031/** 032 * A transporter factory for repositories using the {@code file:} protocol. 033 */ 034@Named("file") 035public final class FileTransporterFactory implements TransporterFactory { 036 037 private float priority; 038 039 /** 040 * Creates an (uninitialized) instance of this transporter factory. <em>Note:</em> In case of manual instantiation 041 * by clients, the new factory needs to be configured via its various mutators before first use or runtime errors 042 * will occur. 043 */ 044 public FileTransporterFactory() { 045 // enables default constructor 046 } 047 048 public float getPriority() { 049 return priority; 050 } 051 052 /** 053 * Sets the priority of this component. 054 * 055 * @param priority The priority. 056 * @return This component for chaining, never {@code null}. 057 */ 058 public FileTransporterFactory setPriority(float priority) { 059 this.priority = priority; 060 return this; 061 } 062 063 public Transporter newInstance(RepositorySystemSession session, RemoteRepository repository) 064 throws NoTransporterException { 065 Objects.requireNonNull(session, "session cannot be null"); 066 Objects.requireNonNull(repository, "repository cannot be null"); 067 068 return new FileTransporter(repository); 069 } 070}