Package org.apache.maven.classrealm
Class DefaultClassRealmManager
java.lang.Object
org.apache.maven.classrealm.DefaultClassRealmManager
- All Implemented Interfaces:
ClassRealmManager
Manages the class realms used by Maven. Warning: This is an internal utility class that is only
public for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted
without prior notice.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
private final org.codehaus.plexus.classworlds.realm.ClassRealm
private final List<ClassRealmManagerDelegate>
private final org.codehaus.plexus.logging.Logger
private final org.codehaus.plexus.classworlds.realm.ClassRealm
private static final ClassLoader
During normal command line build, ClassWorld is loaded by jvm system classloader, which only includes plexus-classworlds jar and possibly javaagent classes, see https://issues.apache.org/jira/browse/MNG-4747.Patterns of artifacts provided by maven core and exported via maven api realm.private final org.codehaus.plexus.classworlds.ClassWorld
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultClassRealmManager
(org.codehaus.plexus.logging.Logger logger, org.codehaus.plexus.PlexusContainer container, List<ClassRealmManagerDelegate> delegates, CoreExports exports) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
callDelegates
(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm, ClassRealmRequest.RealmType type, ClassLoader parent, List<String> parentImports, Map<String, ClassLoader> foreignImports, List<ClassRealmConstituent> constituents) org.codehaus.plexus.classworlds.realm.ClassRealm
createExtensionRealm
(Plugin plugin, List<org.eclipse.aether.artifact.Artifact> artifacts) Creates a new class realm for the specified build extension.org.codehaus.plexus.classworlds.realm.ClassRealm
createPluginRealm
(Plugin plugin, ClassLoader parent, List<String> parentImports, Map<String, ClassLoader> foreignImports, List<org.eclipse.aether.artifact.Artifact> artifacts) Creates a new class realm for the specified plugin.org.codehaus.plexus.classworlds.realm.ClassRealm
createProjectRealm
(Model model, List<org.eclipse.aether.artifact.Artifact> artifacts) Creates a new class realm for the specified project and its build extensions.private org.codehaus.plexus.classworlds.realm.ClassRealm
createRealm
(String baseRealmId, ClassRealmRequest.RealmType type, ClassLoader parent, List<String> parentImports, Map<String, ClassLoader> foreignImports, List<org.eclipse.aether.artifact.Artifact> artifacts) Creates a new class realm with the specified parent and imports.org.codehaus.plexus.classworlds.realm.ClassRealm
Gets the class realm hosting the Maven core.private String
getId
(ClassLoader classLoader) private static String
private static String
getId
(ClassRealmConstituent constituent) private static String
getId
(org.eclipse.aether.artifact.Artifact artifact) private static String
private static String
org.codehaus.plexus.classworlds.realm.ClassRealm
Gets the class realm exposing the Maven API.private boolean
isProvidedArtifact
(org.eclipse.aether.artifact.Artifact artifact) private org.codehaus.plexus.classworlds.realm.ClassRealm
populateRealm
(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm, List<ClassRealmConstituent> constituents) private void
wireRealm
(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm, List<String> parentImports, Map<String, ClassLoader> foreignImports)
-
Field Details
-
API_REALMID
- See Also:
-
PARENT_CLASSLOADER
During normal command line build, ClassWorld is loaded by jvm system classloader, which only includes plexus-classworlds jar and possibly javaagent classes, see https://issues.apache.org/jira/browse/MNG-4747.Using ClassWorld to determine plugin/extensions realm parent classloaders gives m2e and integration test harness flexibility to load multiple version of maven into dedicated classloaders without assuming state of jvm system classloader.
-
logger
private final org.codehaus.plexus.logging.Logger logger -
world
private final org.codehaus.plexus.classworlds.ClassWorld world -
containerRealm
private final org.codehaus.plexus.classworlds.realm.ClassRealm containerRealm -
delegates
-
mavenApiRealm
private final org.codehaus.plexus.classworlds.realm.ClassRealm mavenApiRealm -
providedArtifacts
Patterns of artifacts provided by maven core and exported via maven api realm. These artifacts are filtered from plugin and build extensions realms to avoid presence of duplicate and possibly conflicting classes on classpath.
-
-
Constructor Details
-
DefaultClassRealmManager
@Inject public DefaultClassRealmManager(org.codehaus.plexus.logging.Logger logger, org.codehaus.plexus.PlexusContainer container, List<ClassRealmManagerDelegate> delegates, CoreExports exports)
-
-
Method Details
-
newRealm
-
getMavenApiRealm
public org.codehaus.plexus.classworlds.realm.ClassRealm getMavenApiRealm()Description copied from interface:ClassRealmManager
Gets the class realm exposing the Maven API. This is basically a restricted view on the Maven core realm.- Specified by:
getMavenApiRealm
in interfaceClassRealmManager
- Returns:
- The class realm exposing the Maven API, never
null
.
-
createRealm
private org.codehaus.plexus.classworlds.realm.ClassRealm createRealm(String baseRealmId, ClassRealmRequest.RealmType type, ClassLoader parent, List<String> parentImports, Map<String, ClassLoader> foreignImports, List<org.eclipse.aether.artifact.Artifact> artifacts) Creates a new class realm with the specified parent and imports.- Parameters:
baseRealmId
- The base id to use for the new realm, must not benull
.type
- The type of the class realm, must not benull
.parent
- The parent realm for the new realm, may benull
.parentImports
- The packages/types to import from the parent realm, may benull
.foreignImports
- The packages/types to import from foreign realms, may benull
.artifacts
- The artifacts to add to the realm, may benull
. Unresolved artifacts (i.e. with a missing file) will automatically be excluded from the realm.- Returns:
- The created class realm, never
null
.
-
getCoreRealm
public org.codehaus.plexus.classworlds.realm.ClassRealm getCoreRealm()Description copied from interface:ClassRealmManager
Gets the class realm hosting the Maven core.- Specified by:
getCoreRealm
in interfaceClassRealmManager
- Returns:
- The class realm hosting the Maven core, never
null
.
-
createProjectRealm
public org.codehaus.plexus.classworlds.realm.ClassRealm createProjectRealm(Model model, List<org.eclipse.aether.artifact.Artifact> artifacts) Description copied from interface:ClassRealmManager
Creates a new class realm for the specified project and its build extensions.- Specified by:
createProjectRealm
in interfaceClassRealmManager
- Parameters:
model
- The model of the project for which to create a realm, must not benull
.artifacts
- The artifacts to add to the class realm, may benull
. Unresolved artifacts (i.e. with a missing file) will automatically be excluded from the realm.- Returns:
- The new project realm, never
null
.
-
getKey
-
createExtensionRealm
public org.codehaus.plexus.classworlds.realm.ClassRealm createExtensionRealm(Plugin plugin, List<org.eclipse.aether.artifact.Artifact> artifacts) Description copied from interface:ClassRealmManager
Creates a new class realm for the specified build extension.- Specified by:
createExtensionRealm
in interfaceClassRealmManager
- Parameters:
plugin
- The extension plugin for which to create a realm, must not benull
.artifacts
- The artifacts to add to the class realm, may benull
. Unresolved artifacts (i.e. with a missing file) will automatically be excluded from the realm.- Returns:
- The new extension realm, never
null
.
-
isProvidedArtifact
private boolean isProvidedArtifact(org.eclipse.aether.artifact.Artifact artifact) -
createPluginRealm
public org.codehaus.plexus.classworlds.realm.ClassRealm createPluginRealm(Plugin plugin, ClassLoader parent, List<String> parentImports, Map<String, ClassLoader> foreignImports, List<org.eclipse.aether.artifact.Artifact> artifacts) Description copied from interface:ClassRealmManager
Creates a new class realm for the specified plugin.- Specified by:
createPluginRealm
in interfaceClassRealmManager
- Parameters:
plugin
- The plugin for which to create a realm, must not benull
.parent
- The parent realm for the new realm, may benull
.parentImports
- The packages/types to import from the parent realm, may benull
.foreignImports
- The packages/types to import from foreign realms, may benull
.artifacts
- The artifacts to add to the class realm, may benull
. Unresolved artifacts (i.e. with a missing file) will automatically be excluded from the realm.- Returns:
- The new plugin realm, never
null
.
-
getKey
-
getId
-
getId
-
getId
-
callDelegates
private void callDelegates(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm, ClassRealmRequest.RealmType type, ClassLoader parent, List<String> parentImports, Map<String, ClassLoader> foreignImports, List<ClassRealmConstituent> constituents) -
populateRealm
private Set<String> populateRealm(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm, List<ClassRealmConstituent> constituents) -
wireRealm
private void wireRealm(org.codehaus.plexus.classworlds.realm.ClassRealm classRealm, List<String> parentImports, Map<String, ClassLoader> foreignImports) -
getId
-