o Prevented crappy plugins from messing with container-managed artifact handlers

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@990345 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-08-28 11:29:44 +00:00
parent 53cd87f2d9
commit 7b9b88effc
2 changed files with 17 additions and 4 deletions

View File

@ -33,5 +33,6 @@ public interface ArtifactHandlerManager
ArtifactHandler getArtifactHandler( String type );
@Deprecated
void addHandlers( Map<String, ArtifactHandler> handlers );
}

View File

@ -21,6 +21,7 @@ package org.apache.maven.artifact.handler.manager;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
@ -35,28 +36,39 @@ import org.codehaus.plexus.component.annotations.Requirement;
public class DefaultArtifactHandlerManager
implements ArtifactHandlerManager
{
@Requirement( role = ArtifactHandler.class )
private Map<String, ArtifactHandler> artifactHandlers;
private Map<String, ArtifactHandler> unmanagedHandlers = new ConcurrentHashMap<String, ArtifactHandler>();
public ArtifactHandler getArtifactHandler( String type )
{
ArtifactHandler handler = artifactHandlers.get( type );
ArtifactHandler handler = unmanagedHandlers.get( type );
if ( handler == null )
{
handler = artifactHandlers.get( type );
if ( handler == null )
{
handler = new DefaultArtifactHandler( type );
}
}
return handler;
}
public void addHandlers( Map<String, ArtifactHandler> handlers )
{
artifactHandlers.putAll( handlers );
// legacy support for maven-gpg-plugin:1.0
unmanagedHandlers.putAll( handlers );
}
@Deprecated
public Set<String> getHandlerTypes()
{
return artifactHandlers.keySet();
}
}