Package io.microsphere.net
Class ServiceLoaderURLStreamHandlerFactory
- java.lang.Object
-
- io.microsphere.net.DelegatingURLStreamHandlerFactory
-
- io.microsphere.net.ServiceLoaderURLStreamHandlerFactory
-
- All Implemented Interfaces:
java.net.URLStreamHandlerFactory
public class ServiceLoaderURLStreamHandlerFactory extends DelegatingURLStreamHandlerFactory
AURLStreamHandlerFactoryimplementation that uses the JDK'sServiceLoaderto load and compose multiple delegates for creatingURLStreamHandlerinstances.ServiceLoaderURLStreamHandlerFactoryextends fromDelegatingURLStreamHandlerFactory, delegating to a composite chain of factories and handlers discovered via service loading. It ensures extensibility by allowing custom protocol handling through service provider implementations.Example Usage
// Register the factory globally with the URL class ServiceLoaderURLStreamHandlerFactory.attach();How It Works
1. Loads all availableURLStreamHandlerFactoryimplementations using the service loader mechanism.
2. Composes them in prioritized order using aCompositeURLStreamHandlerFactory.
3. Adds a fallback handler for extendable protocols, if any are found.
4. Delegates creation of stream handlers to this composed factory chain.- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
URLStreamHandlerFactory,ServiceLoader,CompositeURLStreamHandlerFactory,ExtendableProtocolURLStreamHandler
-
-
Constructor Summary
Constructors Constructor Description ServiceLoaderURLStreamHandlerFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidattach()-
Methods inherited from class io.microsphere.net.DelegatingURLStreamHandlerFactory
createURLStreamHandler, getDelegate
-
-