TomcatURLStreamHandlerFactory (Apache Tomcat 8.5.20 API Documentation)

org.apache.catalina.webresources

## Class TomcatURLStreamHandlerFactory

- java.lang.Object
- - org.apache.catalina.webresources.TomcatURLStreamHandlerFactory

- All Implemented Interfaces:
    URLStreamHandlerFactory

      public class TomcatURLStreamHandlerFactory
      extends Object
      implements URLStreamHandlerFactory

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addUserFactory(URLStreamHandlerFactory factory)` Since the JVM only allows a single call to `URL.setURLStreamHandlerFactory(URLStreamHandlerFactory)` and Tomcat needs to register a handler, provide a mechanism to allow applications to register their own handlers.
    `URLStreamHandler` | `createURLStreamHandler(String protocol)`
    `static boolean` | `disable()` Prevent this this factory from registering with the JVM.
    `static TomcatURLStreamHandlerFactory` | `getInstance()` Obtain a reference to the singleton instance.
    `boolean` | `isRegistered()`
    `static boolean` | `register()` Register this factory with the JVM.
    `static void` | `release(ClassLoader classLoader)` Release references to any user provided factories that have been loaded using the provided class loader.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getInstance

          public static TomcatURLStreamHandlerFactory getInstance()

      Obtain a reference to the singleton instance. It is recommended that callers check the value of `isRegistered()` before using the returned instance.
      Returns:
        A reference to the singleton instance

    - #### register

          public static boolean register()

      Register this factory with the JVM. May be called more than once. The implementation ensures that registration only occurs once.
      Returns:
        `true` if the factory is already registered with the JVM or was successfully registered as a result of this call. `false` if the factory was disabled prior to this call.

    - #### disable

          public static boolean disable()

      Prevent this this factory from registering with the JVM. May be called more than once.
      Returns:
        `true` if the factory is already disabled or was successfully disabled as a result of this call. `false` if the factory was already registered prior to this call.

    - #### release

          public static void release(ClassLoader classLoader)

      Release references to any user provided factories that have been loaded using the provided class loader. Called during web application stop to prevent memory leaks.
      Parameters:
        `classLoader` - The class loader to release

    - #### isRegistered

          public boolean isRegistered()

    - #### addUserFactory

          public void addUserFactory(URLStreamHandlerFactory factory)

      Since the JVM only allows a single call to `URL.setURLStreamHandlerFactory(URLStreamHandlerFactory)` and Tomcat needs to register a handler, provide a mechanism to allow applications to register their own handlers.
      Parameters:
        `factory` - The user provided factory to add to the factories Tomcat has already registered

    - #### createURLStreamHandler

          public URLStreamHandler createURLStreamHandler(String protocol)

      Specified by:
        `createURLStreamHandler` in interface `URLStreamHandlerFactory`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.