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.impl;
20  
21  import java.util.Map;
22  import java.util.Set;
23  import java.util.concurrent.TimeUnit;
24  
25  import org.eclipse.aether.named.NamedLockFactory;
26  
27  /**
28   * Selector for system-wide use of named locks.
29   *
30   * @since 2.0.17
31   */
32  public interface NamedLockFactorySelector {
33      /**
34       * Returns immutable set of available lock factory names, to be used for logging purposes or alike.
35       * Never returns {@code null}.
36       */
37      Set<String> getAvailableLockFactories();
38  
39      /**
40       * Selects {@link NamedLockFactory} based on configuration.
41       * Never returns {@code null} but may throw in case of invalid configuration.
42       *
43       * @param configuration The configuration maps, must be not {@code null}.
44       * @throws IllegalArgumentException In case of invalid configuration.
45       */
46      NamedLockFactory getNamedLockFactory(Map<String, ?> configuration);
47  
48      /**
49       * Returns the maximum amount of time to be blocked, while obtaining a named lock, based on configuration.
50       * May throw in case of invalid configuration.
51       *
52       * @param configuration The configuration maps, must be not {@code null}.
53       * @throws IllegalArgumentException In case of invalid configuration.
54       */
55      long getLockWaitTime(Map<String, ?> configuration);
56  
57      /**
58       * Returns the unit of maximum amount of time based on configuration.
59       * Never returns {@code null} but may throw in case of invalid configuration.
60       *
61       * @param configuration The configuration maps, must be not {@code null}.
62       * @throws IllegalArgumentException In case of invalid configuration.
63       */
64      TimeUnit getLockWaitTimeUnit(Map<String, ?> configuration);
65  }