001package org.eclipse.aether.internal.impl.synccontext.named; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.eclipse.aether.named.NamedLockFactory; 023import org.eclipse.aether.named.providers.FileLockNamedLockFactory; 024import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory; 025import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory; 026import org.eclipse.aether.named.providers.NoopNamedLockFactory; 027 028import javax.inject.Inject; 029import javax.inject.Named; 030import javax.inject.Singleton; 031import java.util.HashMap; 032import java.util.Map; 033 034/** 035 * Simple selector implementation that uses {@link LocalReadWriteLockNamedLockFactory} and {@link GAVNameMapper} as 036 * default name lock factory and name mapper. 037 * 038 * @since 1.7.3 039 */ 040@Singleton 041@Named 042public final class SimpleNamedLockFactorySelector 043 extends NamedLockFactorySelectorSupport 044{ 045 private static final Map<String, NamedLockFactory> FACTORIES; 046 047 private static final Map<String, NameMapper> NAME_MAPPERS; 048 049 static 050 { 051 FACTORIES = new HashMap<>(); 052 FACTORIES.put( NoopNamedLockFactory.NAME, new NoopNamedLockFactory() ); 053 FACTORIES.put( LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory() ); 054 FACTORIES.put( LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory() ); 055 FACTORIES.put( FileLockNamedLockFactory.NAME, new FileLockNamedLockFactory() ); 056 057 NAME_MAPPERS = new HashMap<>(); 058 NAME_MAPPERS.put( StaticNameMapper.NAME, new StaticNameMapper() ); 059 NAME_MAPPERS.put( GAVNameMapper.NAME, new GAVNameMapper() ); 060 NAME_MAPPERS.put( DiscriminatingNameMapper.NAME, new DiscriminatingNameMapper( new GAVNameMapper() ) ); 061 NAME_MAPPERS.put( FileGAVNameMapper.NAME, new FileGAVNameMapper() ); 062 } 063 064 /** 065 * Default constructor for ServiceLocator. 066 */ 067 public SimpleNamedLockFactorySelector() 068 { 069 this( FACTORIES, NAME_MAPPERS ); 070 } 071 072 @Inject 073 public SimpleNamedLockFactorySelector( final Map<String, NamedLockFactory> factories, 074 final Map<String, NameMapper> nameMappers ) 075 { 076 super( 077 factories, 078 LocalReadWriteLockNamedLockFactory.NAME, 079 nameMappers, 080 GAVNameMapper.NAME 081 ); 082 } 083}