Skip to content

io microsphere net ServiceLoaderURLStreamHandlerFactory

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

ServiceLoaderURLStreamHandlerFactory

Type: Class | Module: microsphere-java-core | Package: io.microsphere.net | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/net/ServiceLoaderURLStreamHandlerFactory.java

Overview

A URLStreamHandlerFactory implementation that uses the JDK's ServiceLoader to load and compose multiple delegates for creating URLStreamHandler instances.

ServiceLoaderURLStreamHandlerFactory extends from DelegatingURLStreamHandlerFactory, 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 available URLStreamHandlerFactory implementations using the service loader mechanism.

  2. Composes them in prioritized order using a CompositeURLStreamHandlerFactory.

  3. Adds a fallback handler for extendable protocols, if any are found.

  4. Delegates creation of stream handlers to this composed factory chain.

Declaration

public class ServiceLoaderURLStreamHandlerFactory extends DelegatingURLStreamHandlerFactory

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

// Register the factory globally with the URL class
ServiceLoaderURLStreamHandlerFactory.attach();

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.net.ServiceLoaderURLStreamHandlerFactory;

API Reference

Public Methods

Method Description
attach Attach ServiceLoaderURLStreamHandlerFactory into URL

Method Details

attach

public static void attach()

Attach ServiceLoaderURLStreamHandlerFactory into URL URLUtils#attachURLStreamHandlerFactory(URLStreamHandlerFactory)

See Also

  • URLStreamHandlerFactory
  • ServiceLoader
  • CompositeURLStreamHandlerFactory
  • ExtendableProtocolURLStreamHandler

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally