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.spi.connector;
020
021import org.eclipse.aether.RepositorySystemSession;
022import org.eclipse.aether.repository.RemoteRepository;
023
024/**
025 * A pipeline factory to create piped repository connectors.
026 *
027 * @since 2.0.8
028 */
029public interface PipelineRepositoryConnectorFactory {
030
031    /**
032     * Create a piped repository connector for the specified remote repository. Typically, a factory will inspect
033     * {@link RemoteRepository#getProtocol()} and {@link RemoteRepository#getContentType()} to determine whether it can
034     * handle a repository. This method never throws or returns {@code null}, least can do is to return the passed in
035     * delegate connector instance.
036     *
037     * @param session The repository system session from which to configure the connector, must not be {@code null}. In
038     *            particular, a connector must notify any {@link RepositorySystemSession#getTransferListener()} set for
039     *            the session and should obey the timeouts configured for the session.
040     * @param repository The remote repository to create a connector for, must not be {@code null}.
041     * @param delegate The delegate connector, never {@code null}. The delegate is "right hand" connector in connector
042     *                 pipeline.
043     * @return The connector for the given repository, never {@code null}. If pipeline wants to step aside, it must
044     * return the passed in delegate connector instance.
045     */
046    RepositoryConnector newInstance(
047            RepositorySystemSession session, RemoteRepository repository, RepositoryConnector delegate);
048
049    /**
050     * The priority of this pipeline factory. Higher priority makes connector closer to right end (tail) of pipeline
051     * (closest to delegate), while lower priority makes it closer to left hand (head) of the pipeline.
052     */
053    float getPriority();
054}