Package io.microsphere.classloading
Interface URLClassPathHandle
-
- All Superinterfaces:
java.lang.Comparable<Prioritized>
,Prioritized
- All Known Implementing Classes:
AbstractURLClassPathHandle
,ClassicURLClassPathHandle
,ModernURLClassPathHandle
,NoOpURLClassPathHandle
,ServiceLoadingURLClassPathHandle
public interface URLClassPathHandle extends Prioritized
A strategy interface for handling URL Class-Path entries in aClassLoader
. Implementations of this interface can provide custom logic for interacting with URLs related to class loading, such as retrieving or removing URLs from a class loader.This interface extends
Prioritized
, allowing implementations to define their priority order. The default implementation ofgetPriority()
returnsPrioritized.MIN_PRIORITY
, making it the lowest priority unless overridden.Example Implementation
public class ClassicURLClassPathHandle implements URLClassPathHandle { private final int priority; public ClassicURLClassPathHandle(int priority) { this.priority = priority; } public boolean supports() { return true; // Always support classic handling } public boolean removeURL(ClassLoader classLoader, URL url) { // Custom logic to remove a URL from the class loader return false; // Placeholder implementation } public int getPriority() { return priority; // Custom priority } }
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ClassicURLClassPathHandle
,ModernURLClassPathHandle
,Prioritized
-
-
Field Summary
-
Fields inherited from interface io.microsphere.lang.Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default int
getPriority()
Get the prioritydefault java.net.URL[]
getURLs(java.lang.ClassLoader classLoader)
Get the Class-Path URLs from the specifiedClassLoader
default boolean
initializeLoaders(java.lang.ClassLoader classLoader)
Initialize the loaders of URL Class-Path fromURLClassLoader
boolean
removeURL(java.lang.ClassLoader classLoader, java.net.URL url)
Remove the Class-PathURL
from the specifiedClassLoader
boolean
supports()
Supports or not-
Methods inherited from interface io.microsphere.lang.Prioritized
compareTo
-
-
-
-
Method Detail
-
supports
boolean supports()
Supports or not- Returns:
- if supports, return
true
, otherwisefalse
-
getURLs
@Nonnull default java.net.URL[] getURLs(@Nullable java.lang.ClassLoader classLoader)
Get the Class-Path URLs from the specifiedClassLoader
- Parameters:
classLoader
- the specifiedClassLoader
- Returns:
- the non-null array of
URLs
-
initializeLoaders
default boolean initializeLoaders(@Nullable java.lang.ClassLoader classLoader)
Initialize the loaders of URL Class-Path fromURLClassLoader
- Parameters:
classLoader
-ClassLoader
- Returns:
true
if initialized, otherwisefalse
-
removeURL
boolean removeURL(@Nullable java.lang.ClassLoader classLoader, @Nullable java.net.URL url)
Remove the Class-PathURL
from the specifiedClassLoader
- Parameters:
classLoader
- the specifiedClassLoader
url
- the Class-PathURL
- Returns:
- if removed, return
true
, otherwisefalse
-
getPriority
default int getPriority()
Get the priority- Specified by:
getPriority
in interfacePrioritized
- Returns:
- the default value is
Prioritized.MIN_PRIORITY
-
-