You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/12/13 08:36:24 UTC

[GitHub] [maven-resolver] pzygielo commented on a change in pull request #138: Refactor selector

pzygielo commented on a change in pull request #138:
URL: https://github.com/apache/maven-resolver/pull/138#discussion_r767505822



##########
File path: maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/NamedLockFactorySelectorSupport.java
##########
@@ -0,0 +1,112 @@
+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 org.eclipse.aether.named.NamedLockFactory;
+import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory;
+
+import java.util.Map;
+
+/**
+ * Selector implementation support class: by extending this class one may override defaults, or provide completely
+ * alternative way of configuration. This implementation uses Java System properties to select factory and name mapper.
+ *
+ * @since TBD
+ */
+public abstract class NamedLockFactorySelectorSupport
+    implements NamedLockFactorySelector
+{
+    public static final String FACTORY_KEY = "aether.syncContext.named.factory";
+
+    public static final String NAME_MAPPER_KEY = "aether.syncContext.named.nameMapper";
+
+    private final NamedLockFactory namedLockFactory;
+
+    private final NameMapper nameMapper;
+
+    public NamedLockFactorySelectorSupport( final Map<String, NamedLockFactory> factories,
+                                            final String defaultFactoryName,
+                                            final Map<String, NameMapper> nameMappers,
+                                            final String defaultNameMapperName )
+    {
+        this.namedLockFactory = selectNamedLockFactory( factories, getFactoryName( defaultFactoryName ) );
+        this.nameMapper = selectNameMapper( nameMappers, getNameMapperName( defaultNameMapperName ) );
+    }
+
+    /**
+     * Returns the selected {@link NamedLockFactory}, never null.
+     */
+    @Override
+    public NamedLockFactory getSelectedNamedLockFactory()
+    {
+        return namedLockFactory;
+    }
+
+    /**
+     * Returns the selected {@link NameMapper}, never null.
+     */
+    @Override
+    public NameMapper getSelectedNameMapper()
+    {
+        return nameMapper;
+    }
+
+    /**
+     * Returns selected factory name (or sane default) using System property value of {@link #FACTORY_KEY} and defaults
+     * to {@link LocalReadWriteLockNamedLockFactory#NAME}.

Review comment:
       Here the default actually used is out of control of this class, so this comment does not seem right.




-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org