Package org.apache.catalina.webresources
Class TomcatURLStreamHandlerFactory
- java.lang.Object
-
- org.apache.catalina.webresources.TomcatURLStreamHandlerFactory
-
- All Implemented Interfaces:
java.net.URLStreamHandlerFactory
public class TomcatURLStreamHandlerFactory extends java.lang.Object implements java.net.URLStreamHandlerFactory
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddUserFactory(java.net.URLStreamHandlerFactory factory)Since the JVM only allows a single call toURL.setURLStreamHandlerFactory(URLStreamHandlerFactory)and Tomcat needs to register a handler, provide a mechanism to allow applications to register their own handlers.java.net.URLStreamHandlercreateURLStreamHandler(java.lang.String protocol)static booleandisable()Prevent this this factory from registering with the JVM.static TomcatURLStreamHandlerFactorygetInstance()Obtain a reference to the singleton instance.booleanisRegistered()static booleanregister()Register this factory with the JVM.static voidrelease(java.lang.ClassLoader classLoader)Release references to any user provided factories that have been loaded using the provided class loader.
-
-
-
Method Detail
-
getInstance
public static TomcatURLStreamHandlerFactory getInstance()
Obtain a reference to the singleton instance. It is recommended that callers check the value ofisRegistered()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:
trueif the factory is already registered with the JVM or was successfully registered as a result of this call.falseif 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:
trueif the factory is already disabled or was successfully disabled as a result of this call.falseif the factory was already registered prior to this call.
-
release
public static void release(java.lang.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(java.net.URLStreamHandlerFactory factory)
Since the JVM only allows a single call toURL.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 java.net.URLStreamHandler createURLStreamHandler(java.lang.String protocol)
- Specified by:
createURLStreamHandlerin interfacejava.net.URLStreamHandlerFactory
-
-