001package org.eclipse.aether.transport.http; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import javax.inject.Inject; 023import javax.inject.Named; 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.spi.locator.Service; 030import org.eclipse.aether.spi.locator.ServiceLocator; 031import org.eclipse.aether.spi.log.Logger; 032import org.eclipse.aether.spi.log.LoggerFactory; 033import org.eclipse.aether.spi.log.NullLoggerFactory; 034import org.eclipse.aether.transfer.NoTransporterException; 035 036/** 037 * A transporter factory for repositories using the {@code http:} or {@code https:} protocol. The provided transporters 038 * support uploads to WebDAV servers and resumable downloads. 039 */ 040@Named( "http" ) 041public final class HttpTransporterFactory 042 implements TransporterFactory, Service 043{ 044 045 private Logger logger = NullLoggerFactory.LOGGER; 046 047 private float priority = 5.0f; 048 049 /** 050 * Creates an (uninitialized) instance of this transporter factory. <em>Note:</em> In case of manual instantiation 051 * by clients, the new factory needs to be configured via its various mutators before first use or runtime errors 052 * will occur. 053 */ 054 public HttpTransporterFactory() 055 { 056 // enables default constructor 057 } 058 059 @Inject 060 HttpTransporterFactory( LoggerFactory loggerFactory ) 061 { 062 setLoggerFactory( loggerFactory ); 063 } 064 065 public void initService( ServiceLocator locator ) 066 { 067 setLoggerFactory( locator.getService( LoggerFactory.class ) ); 068 } 069 070 /** 071 * Sets the logger factory to use for this component. 072 * 073 * @param loggerFactory The logger factory to use, may be {@code null} to disable logging. 074 * @return This component for chaining, never {@code null}. 075 */ 076 public HttpTransporterFactory setLoggerFactory( LoggerFactory loggerFactory ) 077 { 078 this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, HttpTransporter.class ); 079 return this; 080 } 081 082 public float getPriority() 083 { 084 return priority; 085 } 086 087 /** 088 * Sets the priority of this component. 089 * 090 * @param priority The priority. 091 * @return This component for chaining, never {@code null}. 092 */ 093 public HttpTransporterFactory setPriority( float priority ) 094 { 095 this.priority = priority; 096 return this; 097 } 098 099 public Transporter newInstance( RepositorySystemSession session, RemoteRepository repository ) 100 throws NoTransporterException 101 { 102 return new HttpTransporter( repository, session, logger ); 103 } 104 105}