View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.eclipse.aether.spi.remoterepo;
20  
21  import org.eclipse.aether.RepositorySystemSession;
22  import org.eclipse.aether.repository.RepositoryKeyFunction;
23  
24  /**
25   * A factory to create {@link RepositoryKeyFunction} instances.
26   *
27   * @since 2.0.14
28   */
29  public interface RepositoryKeyFunctionFactory {
30      /**
31       * Returns system-wide repository key function.
32       *
33       * @param session The repository session, must not be {@code null}.
34       * @return The repository key function.
35       * @see #repositoryKeyFunction(Class, RepositorySystemSession, String, String)
36       * @see org.eclipse.aether.ConfigurationProperties#REPOSITORY_SYSTEM_REPOSITORY_KEY_FUNCTION
37       */
38      RepositoryKeyFunction systemRepositoryKeyFunction(RepositorySystemSession session);
39  
40      /**
41       * Method that based on configuration returns the "repository key function". The returned function will be session
42       * cached if session is equipped with cache, otherwise it will be non cached. Method never returns {@code null}.
43       * Only the {@code configurationKey} parameter may be {@code null} in which case no configuration lookup happens
44       * but the {@code defaultValue} is directly used instead.
45       *
46       * @param owner The "owner" of key function (used to create cache-key), must not be {@code null}.
47       * @param session The repository session, must not be {@code null}.
48       * @param defaultValue The default value of repository key configuration, must not be {@code null}.
49       * @param configurationKey The configuration key to lookup configuration from, may be {@code null}, in which case
50       *                         no configuration lookup happens but the {@code defaultValue} is used to create the
51       *                         repository key function.
52       * @return The repository key function.
53       */
54      RepositoryKeyFunction repositoryKeyFunction(
55              Class<?> owner, RepositorySystemSession session, String defaultValue, String configurationKey);
56  }