From 18b83fe00ac7bf8a78fca164c8d34f5c12f58ef8 Mon Sep 17 00:00:00 2001 From: Kenney Westerhof Date: Thu, 18 Jan 2007 16:33:34 +0000 Subject: [PATCH] Use plugin realm to lookup plugin components - fixes custom lifecycle mappings git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@497491 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/DefaultPluginManager.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 3aef4f9a3f..4b1118fda2 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -1207,20 +1207,31 @@ public class DefaultPluginManager } } - public Object getPluginComponent( Plugin plugin, - String role, - String roleHint ) + public Object getPluginComponent( Plugin plugin, String role, String roleHint ) throws PluginManagerException, ComponentLookupException { - // XXX this needs the plugin realm! - return container.lookup( role, roleHint ); + ClassRealm pluginRealm = pluginCollector.getPluginDescriptor( plugin ).getClassRealm(); + + if ( pluginRealm == null ) + { + getLogger().warn( "getPluginComponent(" + plugin + ", " + role + "): descriptor is missing classRealm" ); + pluginRealm = DefaultPlexusContainer.getLookupRealm(); + } + + return container.lookup( role, roleHint, pluginRealm ); } - public Map getPluginComponents( Plugin plugin, - String role ) + public Map getPluginComponents( Plugin plugin, String role ) throws ComponentLookupException, PluginManagerException { - // XXX this needs the plugin realm! - return container.lookupMap( role ); + ClassRealm pluginRealm = pluginCollector.getPluginDescriptor( plugin ).getClassRealm(); + + if ( pluginRealm == null ) + { + getLogger().warn( "getPluginComponent(" + plugin + ", " + role + "): descriptor is missing classRealm" ); + pluginRealm = DefaultPlexusContainer.getLookupRealm(); + } + + return container.lookupMap( role, pluginRealm ); } }