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.wagon; 020 021import javax.inject.Inject; 022import javax.inject.Named; 023 024import org.eclipse.aether.RepositorySystemSession; 025import org.eclipse.aether.repository.RemoteRepository; 026import org.eclipse.aether.spi.connector.transport.Transporter; 027import org.eclipse.aether.spi.connector.transport.TransporterFactory; 028import org.eclipse.aether.spi.io.PathProcessor; 029import org.eclipse.aether.transfer.NoTransporterException; 030 031import static java.util.Objects.requireNonNull; 032 033/** 034 * A transporter factory using <a href="http://maven.apache.org/wagon/" target="_blank">Apache Maven Wagon</a>. Note 035 * that this factory merely serves as an adapter to the Wagon API and by itself does not provide any transport services 036 * unless one or more wagon implementations are registered with the {@link WagonProvider}. 037 */ 038@Named(WagonTransporterFactory.NAME) 039public final class WagonTransporterFactory implements TransporterFactory { 040 public static final String NAME = "wagon"; 041 042 private final WagonProvider wagonProvider; 043 044 private final WagonConfigurator wagonConfigurator; 045 046 private final PathProcessor pathProcessor; 047 048 private float priority = -1.0f; 049 050 @Inject 051 public WagonTransporterFactory( 052 WagonProvider wagonProvider, WagonConfigurator wagonConfigurator, PathProcessor pathProcessor) { 053 this.wagonProvider = wagonProvider; 054 this.wagonConfigurator = wagonConfigurator; 055 this.pathProcessor = pathProcessor; 056 } 057 058 @Override 059 public float getPriority() { 060 return priority; 061 } 062 063 /** 064 * Sets the priority of this component. 065 * 066 * @param priority The priority. 067 * @return This component for chaining, never {@code null}. 068 */ 069 public WagonTransporterFactory setPriority(float priority) { 070 this.priority = priority; 071 return this; 072 } 073 074 @Override 075 public Transporter newInstance(RepositorySystemSession session, RemoteRepository repository) 076 throws NoTransporterException { 077 requireNonNull(session, "session cannot be null"); 078 requireNonNull(repository, "repository cannot be null"); 079 080 return new WagonTransporter(wagonProvider, wagonConfigurator, repository, session, pathProcessor); 081 } 082}