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.remoterepo; 020 021import org.eclipse.aether.ConfigurationProperties; 022import org.eclipse.aether.RepositorySystemSession; 023import org.eclipse.aether.repository.RepositoryKeyFunction; 024 025/** 026 * A factory to create {@link RepositoryKeyFunction} instances. 027 * 028 * @since 2.0.14 029 */ 030public interface RepositoryKeyFunctionFactory { 031 /** 032 * Returns system-wide repository key function. 033 * 034 * @param session The repository session, must not be {@code null}. 035 * @return The repository key function. 036 * @see #repositoryKeyFunction(Class, RepositorySystemSession, String, String) 037 * @see org.eclipse.aether.ConfigurationProperties#REPOSITORY_SYSTEM_REPOSITORY_KEY_FUNCTION 038 */ 039 default RepositoryKeyFunction systemRepositoryKeyFunction(RepositorySystemSession session) { 040 return repositoryKeyFunction( 041 RepositoryKeyFunctionFactory.class, 042 session, 043 ConfigurationProperties.DEFAULT_REPOSITORY_SYSTEM_REPOSITORY_KEY_FUNCTION, 044 ConfigurationProperties.REPOSITORY_SYSTEM_REPOSITORY_KEY_FUNCTION); 045 } 046 047 /** 048 * Returns system-wide tracking repository key function. 049 * 050 * @param session The repository session, must not be {@code null}. 051 * @return The repository key function. 052 * @see #repositoryKeyFunction(Class, RepositorySystemSession, String, String) 053 * @see org.eclipse.aether.ConfigurationProperties#REPOSITORY_TRACKING_REPOSITORY_KEY_FUNCTION 054 * @since 2.0.23 055 */ 056 default RepositoryKeyFunction trackingRepositoryKeyFunction(RepositorySystemSession session) { 057 return repositoryKeyFunction( 058 RepositoryKeyFunctionFactory.class, 059 session, 060 ConfigurationProperties.DEFAULT_REPOSITORY_TRACKING_REPOSITORY_KEY_FUNCTION, 061 ConfigurationProperties.REPOSITORY_TRACKING_REPOSITORY_KEY_FUNCTION); 062 } 063 064 /** 065 * Method that based on configuration returns the "repository key function". The returned function will be session 066 * cached if session is equipped with cache, otherwise it will be non cached. Method never returns {@code null}. 067 * Only the {@code configurationKey} parameter may be {@code null} in which case no configuration lookup happens 068 * but the {@code defaultValue} is directly used instead. 069 * 070 * @param owner The "owner" of key function (used to create cache-key), must not be {@code null}. 071 * @param session The repository session, must not be {@code null}. 072 * @param defaultValue The default value of repository key configuration, must not be {@code null}. 073 * @param configurationKey The configuration key to lookup configuration from, may be {@code null}, in which case 074 * no configuration lookup happens but the {@code defaultValue} is used to create the 075 * repository key function. 076 * @return The repository key function. 077 */ 078 RepositoryKeyFunction repositoryKeyFunction( 079 Class<?> owner, RepositorySystemSession session, String defaultValue, String configurationKey); 080}