From a789d4c28855cb2404afdcdad3e95896dc2a6551 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Thu, 21 Jan 2010 15:54:28 +0000 Subject: [PATCH] o Refactored code git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@901751 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/classrealm/ClassRealmManager.java | 7 +++++++ .../maven/classrealm/DefaultClassRealmManager.java | 9 +++++++-- .../maven/project/DefaultProjectBuildingHelper.java | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java index b72fe95460..20c5f23538 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/ClassRealmManager.java @@ -35,6 +35,13 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; public interface ClassRealmManager { + /** + * Gets the class realm hosting the Maven core. + * + * @return The class realm hosting the Maven core, never {@code null}. + */ + ClassRealm getCoreRealm(); + /** * Creates a new class realm for the specified project and its build extensions. * diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java index 1c4ad31e65..84bd1bc237 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java @@ -104,7 +104,7 @@ public class DefaultClassRealmManager } else { - classRealm.setParentRealm( container.getContainerRealm() ); + classRealm.setParentRealm( getCoreRealm() ); importMavenApi( classRealm ); } @@ -141,7 +141,7 @@ public class DefaultClassRealmManager */ private void importXpp3Dom( ClassRealm importingRealm ) { - ClassRealm coreRealm = container.getContainerRealm(); + ClassRealm coreRealm = getCoreRealm(); importingRealm.importFrom( coreRealm, "org.codehaus.plexus.util.xml.Xpp3Dom" ); importingRealm.importFrom( coreRealm, "org.codehaus.plexus.util.xml.pull.XmlPullParser" ); @@ -185,6 +185,11 @@ public class DefaultClassRealmManager importingRealm.importFromParent( "org.codehaus.plexus.PlexusContainerException" ); } + public ClassRealm getCoreRealm() + { + return container.getContainerRealm(); + } + public ClassRealm createProjectRealm( Model model ) { if ( model == null ) diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java index 772e81ac2c..7279fda2f4 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java @@ -439,7 +439,7 @@ public class DefaultProjectBuildingHelper if ( projectRealm == null ) { - projectRealm = container.getContainerRealm(); + projectRealm = classRealmManager.getCoreRealm(); } Thread.currentThread().setContextClassLoader( projectRealm );