cstamas commented on code in PR #1814: URL: https://github.com/apache/maven-resolver/pull/1814#discussion_r3000620903
########## maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/named/DefaultNamedLockFactorySelector.java: ########## @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.eclipse.aether.internal.impl.named; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; + +import org.eclipse.aether.ConfigurationProperties; +import org.eclipse.aether.MultiRuntimeException; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.impl.NamedLockFactorySelector; +import org.eclipse.aether.impl.RepositorySystemLifecycle; +import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapter; +import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactoryImpl; +import org.eclipse.aether.named.NamedLockFactory; +import org.eclipse.aether.named.providers.FileLockNamedLockFactory; +import org.eclipse.aether.util.ConfigUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.util.Objects.requireNonNull; + +@Singleton +@Named +public class DefaultNamedLockFactorySelector implements NamedLockFactorySelector { + public static final String CONFIG_PROPS_PREFIX = ConfigurationProperties.PREFIX_SYSTEM + "named."; + + /** + * Name of the lock factory to use in system. Out of the box supported ones are "file-lock", "rwlock-local", + * "semaphore-local", "noop". By adding extensions one can extend available lock factories (for example IPC locking). + * + * @configurationSource {@link RepositorySystemSession#getConfigProperties()} + * @configurationType {@link java.lang.String} + * @configurationDefaultValue {@link #DEFAULT_FACTORY_NAME} + */ + public static final String CONFIG_PROP_FACTORY_NAME = CONFIG_PROPS_PREFIX + "factory"; + + public static final String DEFAULT_FACTORY_NAME = FileLockNamedLockFactory.NAME; + + /** + * The maximum amount of time to be blocked, while obtaining a named lock. + * + * @configurationSource {@link RepositorySystemSession#getConfigProperties()} + * @configurationType {@link java.lang.Long} + * @configurationDefaultValue {@link #DEFAULT_LOCK_WAIT_TIME} + */ + public static final String CONFIG_PROP_LOCK_WAIT_TIME = CONFIG_PROPS_PREFIX + "time"; + + public static final long DEFAULT_LOCK_WAIT_TIME = 900L; + + /** + * The unit of maximum amount of time. Accepts TimeUnit enum names. + * + * @configurationSource {@link RepositorySystemSession#getConfigProperties()} + * @configurationType {@link java.lang.String} + * @configurationDefaultValue {@link #DEFAULT_LOCK_WAIT_TIME_UNIT} + */ + public static final String CONFIG_PROP_LOCK_WAIT_TIME_UNIT = CONFIG_PROPS_PREFIX + "timeUnit"; Review Comment: I always _hated_ my initial choice: `aether.syncContext.named.time.unit` and `aether.syncContext.named.time`. The `.unit` makes `time` look like an object (and not scalar) and `unit` be some property of it.... Also, these are totally new keys (prefix is different, is not `aether.syncContext...`). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
