Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apache-maven/src/assembly/component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ under the License.
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>boot</outputDirectory>
<includes>
<include>org.codehaus.plexus:plexus-classworlds</include>
<include>org.apache.maven:maven-classworlds</include>
</includes>
</dependencySet>

<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<excludes>
<exclude>org.codehaus.plexus:plexus-classworlds</exclude>
<exclude>org.apache.maven:maven-classworlds</exclude>
</excludes>
</dependencySet>
</dependencySets>
Expand Down
2 changes: 1 addition & 1 deletion apache-maven/src/assembly/maven/bin/mvn
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ concat_lines() {

MAVEN_PROJECTBASEDIR="`find_maven_basedir "$@"`"
MAVEN_OPTS="$MAVEN_OPTS `concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config"`"
LAUNCHER_JAR=`echo "$MAVEN_HOME"/boot/plexus-classworlds-*.jar`
LAUNCHER_JAR=`echo "$MAVEN_HOME"/boot/maven-classworlds-*.jar`
LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher

# For Cygwin and MinGW, switch paths to Windows format before running java(1) command
Expand Down
2 changes: 1 addition & 1 deletion apache-maven/src/assembly/maven/bin/mvn.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ goto processArgs
:endHandleArgs
call :processArgs %*

for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set LAUNCHER_JAR="%%i"
for %%i in ("%MAVEN_HOME%"\boot\maven-classworlds-*) do set LAUNCHER_JAR="%%i"
set LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
if "%MAVEN_MAIN_CLASS%"=="" @set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ subject to the terms and conditions of the following licenses:
#* *##end
#* *###
#* *### Classworlds is in boot directory, not in lib
#* *##if ( $project.artifact.artifactId == "plexus-classworlds" )
#* *##if ( $project.artifact.artifactId == "maven-classworlds" )
#* *##set ( $directory = 'boot' )
#* *##end
#* *###
Expand Down
39 changes: 39 additions & 0 deletions api/maven-api-classworlds/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>

<artifactId>maven-api-classworlds</artifactId>
<name>Maven 4 API :: Classworlds</name>
<description>Maven 4 API for class loading realms and isolation.</description>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-annotations</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.api.classworlds;

import java.io.Closeable;
import java.net.URL;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.annotations.Nullable;

/**
* A class loading realm that provides isolated class loading with controlled imports and exports.
* <p>
* A ClassRealm represents an isolated class loading environment with its own classpath
* and controlled access to classes from other realms through imports.
* </p>
*
* @since 4.1.0
*/
@Experimental
public interface ClassRealm extends Closeable {

/**
* Returns the unique identifier for this realm.
*
* @return the realm identifier
*/
@Nonnull
String getId();

/**
* Returns the class world that contains this realm.
*
* @return the parent class world
*/
@Nonnull
ClassWorld getWorld();

/**
* Returns the underlying ClassLoader for this realm.
* <p>
* This method allows access to the actual ClassLoader implementation
* while maintaining API abstraction.
* </p>
*
* @return the underlying ClassLoader
*/
@Nonnull
ClassLoader getClassLoader();

/**
* Returns the class loading strategy used by this realm.
*
* @return the strategy
*/
@Nonnull
Strategy getStrategy();

/**
* Adds a URL to this realm's classpath.
*
* @param url the URL to add
*/
void addURL(@Nonnull URL url);

/**
* Returns the URLs in this realm's classpath.
*
* @return array of URLs in the classpath
*/
@Nonnull
URL[] getURLs();

/**
* Imports classes from the specified realm for the given package.
*
* @param realmId the identifier of the realm to import from
* @param packageName the package name to import (supports wildcards)
* @throws NoSuchRealmException if the specified realm doesn't exist
*/
void importFrom(@Nonnull String realmId, @Nonnull String packageName) throws NoSuchRealmException;

/**
* Imports classes from the specified class loader for the given package.
*
* @param classLoader the class loader to import from
* @param packageName the package name to import (supports wildcards)
*/
void importFrom(@Nonnull ClassLoader classLoader, @Nonnull String packageName);

/**
* Returns the class loader that would handle the specified class name through imports.
*
* @param name the class name
* @return the import class loader, or null if no import matches
*/
@Nullable
ClassLoader getImportClassLoader(@Nonnull String name);

// Note: getImportRealms method is not included in the API interface
// to avoid conflicts with the existing implementation signature

/**
* Sets the parent class loader for this realm.
*
* @param parentClassLoader the parent class loader, may be null
*/
void setParentClassLoader(@Nullable ClassLoader parentClassLoader);

/**
* Returns the parent class loader for this realm.
*
* @return the parent class loader, may be null
*/
@Nullable
ClassLoader getParentClassLoader();

// Note: setParentRealm method is not included in the API interface
// to avoid conflicts with the existing implementation signature

// Note: getParentRealm method is not included in the API interface
// to avoid conflicts with the existing implementation signature

// Note: createChildRealm method is not included in the API interface
// to avoid conflicts with the existing implementation signature

/**
* Loads a class from this realm only (not from imports or parent).
*
* @param name the class name
* @return the loaded class, or null if not found
*/
@Nullable
Class<?> loadClassFromSelf(@Nonnull String name);

/**
* Loads a class from imported realms/classloaders.
*
* @param name the class name
* @return the loaded class, or null if not found
*/
@Nullable
Class<?> loadClassFromImport(@Nonnull String name);

/**
* Loads a class from the parent class loader.
*
* @param name the class name
* @return the loaded class, or null if not found
*/
@Nullable
Class<?> loadClassFromParent(@Nonnull String name);

/**
* Loads a resource from this realm only (not from imports or parent).
*
* @param name the resource name
* @return the resource URL, or null if not found
*/
@Nullable
URL loadResourceFromSelf(@Nonnull String name);

/**
* Loads a resource from imported realms/classloaders.
*
* @param name the resource name
* @return the resource URL, or null if not found
*/
@Nullable
URL loadResourceFromImport(@Nonnull String name);

/**
* Loads a resource from the parent class loader.
*
* @param name the resource name
* @return the resource URL, or null if not found
*/
@Nullable
URL loadResourceFromParent(@Nonnull String name);
}
Loading
Loading