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.impl;
020
021import java.util.Map;
022import java.util.Set;
023import java.util.concurrent.TimeUnit;
024
025import org.eclipse.aether.named.NamedLockFactory;
026
027/**
028 * Selector for system-wide use of named locks.
029 *
030 * @since 2.0.17
031 */
032public interface NamedLockFactorySelector {
033    /**
034     * Returns immutable set of available lock factory names, to be used for logging purposes or alike.
035     * Never returns {@code null}.
036     */
037    Set<String> getAvailableLockFactories();
038
039    /**
040     * Selects {@link NamedLockFactory} based on configuration.
041     * Never returns {@code null} but may throw in case of invalid configuration.
042     *
043     * @param configuration The configuration maps, must be not {@code null}.
044     * @throws IllegalArgumentException In case of invalid configuration.
045     */
046    NamedLockFactory getNamedLockFactory(Map<String, ?> configuration);
047
048    /**
049     * Returns the maximum amount of time to be blocked, while obtaining a named lock, based on configuration.
050     * May throw in case of invalid configuration.
051     *
052     * @param configuration The configuration maps, must be not {@code null}.
053     * @throws IllegalArgumentException In case of invalid configuration.
054     */
055    long getLockWaitTime(Map<String, ?> configuration);
056
057    /**
058     * Returns the unit of maximum amount of time based on configuration.
059     * Never returns {@code null} but may throw in case of invalid configuration.
060     *
061     * @param configuration The configuration maps, must be not {@code null}.
062     * @throws IllegalArgumentException In case of invalid configuration.
063     */
064    TimeUnit getLockWaitTimeUnit(Map<String, ?> configuration);
065}