Skip to content

io microsphere net MutableURLStreamHandlerFactory

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

MutableURLStreamHandlerFactory

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

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

Overview

A mutable and non-thread-safe implementation of URLStreamHandlerFactory that allows dynamic registration and retrieval of URLStreamHandler instances for specific protocols.

This class provides methods to add, remove, and retrieve URL stream handlers dynamically at runtime, making it suitable for environments where protocol handling needs to be modified or extended programmatically.

Example Usage

`MutableURLStreamHandlerFactory factory = new MutableURLStreamHandlerFactory();

// Add a custom handler for the "myproto" protocol
factory.addURLStreamHandler("myproto", new MyCustomURLStreamHandler());

// Retrieve a registered handler
URLStreamHandler handler = factory.getURLStreamHandler("myproto");

// Remove a handler
factory.removeURLStreamHandler("myproto");

// Clear all handlers
factory.clearHandlers();
`

Note: This class is not thread-safe. Concurrent access from multiple threads should be externally synchronized.

Declaration

public class MutableURLStreamHandlerFactory<H extends URLStreamHandler> implements URLStreamHandlerFactory

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

MutableURLStreamHandlerFactory factory = new MutableURLStreamHandlerFactory();

// Add a custom handler for the "myproto" protocol
factory.addURLStreamHandler("myproto", new MyCustomURLStreamHandler());

// Retrieve a registered handler
URLStreamHandler handler = factory.getURLStreamHandler("myproto");

// Remove a handler
factory.removeURLStreamHandler("myproto");

// Clear all handlers
factory.clearHandlers();

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.MutableURLStreamHandlerFactory;

API Reference

Public Methods

Method Description
addURLStreamHandler Constructs a new instance
removeURLStreamHandler Removes the handler for the specified protocol
getURLStreamHandler Retrieves the handler for the specified protocol
getHandlers Retrieves all handlers
createURLStreamHandler
clearHandlers Clears all handlers

Method Details

addURLStreamHandler

public MutableURLStreamHandlerFactory addURLStreamHandler(String protocol, H handler)

Constructs a new instance / public MutableURLStreamHandlerFactory() { this(null); }

/** Constructs a new instance with the specified handlers

See Also

  • URLStreamHandlerFactory
  • URLStreamHandler

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