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.localrepo;
020
021import org.eclipse.aether.RepositorySystemSession;
022import org.eclipse.aether.repository.LocalRepository;
023import org.eclipse.aether.repository.LocalRepositoryManager;
024import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
025
026/**
027 * A factory to create managers for the local repository. A local repository manager needs to keep track of artifacts
028 * and metadata and manage access. When the repository system needs a repository manager for a given local repository,
029 * it iterates the registered factories in descending order of their priority and calls
030 * {@link #newInstance(RepositorySystemSession, LocalRepository)} on them. The first manager returned by a factory will
031 * then be used for the local repository.
032 */
033public interface LocalRepositoryManagerFactory {
034
035    /**
036     * Tries to create a repository manager for the specified local repository. The distinguishing property of a local
037     * repository is its {@link LocalRepository#getContentType() type}, which may for example denote the used directory
038     * structure.
039     *
040     * @param session The repository system session from which to configure the manager, must not be {@code null}.
041     * @param repository The local repository to create a manager for, must not be {@code null}.
042     * @return The manager for the given repository, never {@code null}.
043     * @throws NoLocalRepositoryManagerException If the factory cannot create a manager for the specified local
044     *             repository.
045     */
046    LocalRepositoryManager newInstance(RepositorySystemSession session, LocalRepository repository)
047            throws NoLocalRepositoryManagerException;
048
049    /**
050     * The priority of this factory. Factories with higher priority are preferred over those with lower priority.
051     *
052     * @return The priority of this factory.
053     */
054    float getPriority();
055}