[ https://issues.apache.org/jira/browse/MRESOLVER-291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17632647#comment-17632647 ]
ASF GitHub Bot commented on MRESOLVER-291: ------------------------------------------ slawekjaranowski commented on code in PR #219: URL: https://github.com/apache/maven-resolver/pull/219#discussion_r1020742306 ########## maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactoryAdapterFactoryImpl.java: ########## @@ -0,0 +1,255 @@ +package org.eclipse.aether.internal.impl.synccontext.named; + +/* + * 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. + */ + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.aether.MultiRuntimeException; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.impl.RepositorySystemLifecycle; +import org.eclipse.aether.internal.impl.synccontext.named.providers.DiscriminatingNameMapperProvider; +import org.eclipse.aether.internal.impl.synccontext.named.providers.FileGAVNameMapperProvider; +import org.eclipse.aether.internal.impl.synccontext.named.providers.FileHashingGAVNameMapperProvider; +import org.eclipse.aether.internal.impl.synccontext.named.providers.GAVNameMapperProvider; +import org.eclipse.aether.internal.impl.synccontext.named.providers.StaticNameMapperProvider; +import org.eclipse.aether.named.NamedLockFactory; +import org.eclipse.aether.named.providers.FileLockNamedLockFactory; +import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory; +import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory; +import org.eclipse.aether.named.providers.NoopNamedLockFactory; +import org.eclipse.aether.spi.locator.Service; +import org.eclipse.aether.spi.locator.ServiceLocator; +import org.eclipse.aether.util.ConfigUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.util.Objects.requireNonNull; + +/** + * Default implementation of {@link NamedLockFactoryAdapterFactory}. By default, this implementation creates + * instance of adapter for each call. In turn, on shutdown it cleanly invokes shutdown method of all existing named + * lock factories. If different behavior needed, override the {@link #getAdapter(RepositorySystemSession)} method. + * <p> + * This class most members and methods are protected, and is meant to be extended if needed to customize its behavior. + * Exception from this are private static constants and initializers, mostly meant to provide out of the box + * defaults and to be used when no Eclipse Sisu component container used. + * + * @since 1.9.1 + */ +@Singleton +@Named +public class NamedLockFactoryAdapterFactoryImpl implements NamedLockFactoryAdapterFactory, Service +{ + private static final String DEFAULT_FACTORY_NAME = LocalReadWriteLockNamedLockFactory.NAME; + + private static final String DEFAULT_NAME_MAPPER_NAME = GAVNameMapperProvider.NAME; + + private static final Map<String, NamedLockFactory> FACTORIES; + + private static final Map<String, NameMapper> NAME_MAPPERS; + + static + { + HashMap<String, NamedLockFactory> factories = new HashMap<>(); + factories.put( NoopNamedLockFactory.NAME, new NoopNamedLockFactory() ); + factories.put( LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory() ); + factories.put( LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory() ); + factories.put( FileLockNamedLockFactory.NAME, new FileLockNamedLockFactory() ); + FACTORIES = factories; + + HashMap<String, NameMapper> mappers = new HashMap<>(); + mappers.put( StaticNameMapperProvider.NAME, new StaticNameMapperProvider().get() ); + mappers.put( GAVNameMapperProvider.NAME, new GAVNameMapperProvider().get() ); + mappers.put( DiscriminatingNameMapperProvider.NAME, new DiscriminatingNameMapperProvider().get() ); + mappers.put( FileGAVNameMapperProvider.NAME, new FileGAVNameMapperProvider().get() ); + mappers.put( FileHashingGAVNameMapperProvider.NAME, new FileHashingGAVNameMapperProvider().get() ); + NAME_MAPPERS = mappers; + } Review Comment: I see, I only thought to create those when are needed - not in class static context. > Undo MRESOLVER-284 > ------------------ > > Key: MRESOLVER-291 > URL: https://issues.apache.org/jira/browse/MRESOLVER-291 > Project: Maven Resolver > Issue Type: Task > Components: Resolver > Reporter: Tamas Cservenak > Assignee: Tamas Cservenak > Priority: Major > Fix For: 1.9.1 > > > No semantics change, merely do not expect ctor config injection, use session > configuration params for everything as originally intended. > The MRESOLVER-284 "breaking" part should be undone. -- This message was sent by Atlassian Jira (v8.20.10#820010)