001package org.apache.maven.artifact.handler.manager; 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 java.util.Map; 023import java.util.Set; 024import java.util.concurrent.ConcurrentHashMap; 025 026import org.apache.maven.artifact.handler.ArtifactHandler; 027import org.apache.maven.artifact.handler.DefaultArtifactHandler; 028import org.codehaus.plexus.component.annotations.Component; 029import org.codehaus.plexus.component.annotations.Requirement; 030 031/** 032 * @author Jason van Zyl 033 */ 034@Component( role = ArtifactHandlerManager.class ) 035public class DefaultArtifactHandlerManager 036 implements ArtifactHandlerManager 037{ 038 039 @Requirement( role = ArtifactHandler.class ) 040 private Map<String, ArtifactHandler> artifactHandlers; 041 042 private Map<String, ArtifactHandler> unmanagedHandlers = new ConcurrentHashMap<String, ArtifactHandler>(); 043 044 public ArtifactHandler getArtifactHandler( String type ) 045 { 046 ArtifactHandler handler = unmanagedHandlers.get( type ); 047 048 if ( handler == null ) 049 { 050 handler = artifactHandlers.get( type ); 051 052 if ( handler == null ) 053 { 054 handler = new DefaultArtifactHandler( type ); 055 } 056 } 057 058 return handler; 059 } 060 061 public void addHandlers( Map<String, ArtifactHandler> handlers ) 062 { 063 // legacy support for maven-gpg-plugin:1.0 064 unmanagedHandlers.putAll( handlers ); 065 } 066 067 @Deprecated 068 public Set<String> getHandlerTypes() 069 { 070 return artifactHandlers.keySet(); 071 } 072 073}