From 7b9b88effc5a71831a5eb2d77500925070edb44d Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sat, 28 Aug 2010 11:29:44 +0000 Subject: [PATCH] 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 --- .../manager/ArtifactHandlerManager.java | 3 ++- .../manager/DefaultArtifactHandlerManager.java | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java index d4a04b4995..ab03db4163 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java @@ -33,5 +33,6 @@ public interface ArtifactHandlerManager ArtifactHandler getArtifactHandler( String type ); + @Deprecated void addHandlers( Map handlers ); -} \ No newline at end of file +} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java index e00044b9d0..2acb66b73b 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java @@ -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,16 +36,24 @@ import org.codehaus.plexus.component.annotations.Requirement; public class DefaultArtifactHandlerManager implements ArtifactHandlerManager { + @Requirement( role = ArtifactHandler.class ) private Map artifactHandlers; + private Map unmanagedHandlers = new ConcurrentHashMap(); + public ArtifactHandler getArtifactHandler( String type ) { - ArtifactHandler handler = artifactHandlers.get( type ); + ArtifactHandler handler = unmanagedHandlers.get( type ); if ( handler == null ) { - handler = new DefaultArtifactHandler( type ); + handler = artifactHandlers.get( type ); + + if ( handler == null ) + { + handler = new DefaultArtifactHandler( type ); + } } return handler; @@ -52,11 +61,14 @@ public class DefaultArtifactHandlerManager public void addHandlers( Map handlers ) { - artifactHandlers.putAll( handlers ); + // legacy support for maven-gpg-plugin:1.0 + unmanagedHandlers.putAll( handlers ); } + @Deprecated public Set getHandlerTypes() { return artifactHandlers.keySet(); } + }