Top Fields Constructors Methods
org.apache.catalina.webresources

public Class TomcatURLStreamHandlerFactory

extends Object
implements URLStreamHandlerFactory
Class Inheritance
All Implemented Interfaces
java.net.URLStreamHandlerFactory
Imports
java.net.URL, .URLStreamHandler, .URLStreamHandlerFactory, java.util.List, java.util.concurrent.CopyOnWriteArrayList, org.apache.catalina.webresources.war.Handler

Field Summary

Modifier and TypeField and Description
private static final String
private static volatile TomcatURLStreamHandlerFactory
private final boolean
private final List<URLStreamHandlerFactory>
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
addUserFactory(URLStreamHandlerFactory
The user provided factory to add to the factories Tomcat has already registered
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.

public URLStreamHandler
createURLStreamHandler(String
the protocol ("ftp", "http", "nntp", etc.).
protocol
)

Implements java.net.URLStreamHandlerFactory.createURLStreamHandler.

Creates a new URLStreamHandler instance with the specified protocol.

public static boolean

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.
disable
()

Prevent this this factory from registering with the JVM.

public static TomcatURLStreamHandlerFactory

Returns:

A reference to the singleton instance
getInstance
()

Obtain a reference to the singleton instance.

private static TomcatURLStreamHandlerFactory
getInstanceInternal(boolean register)

public boolean
public static boolean

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.
register
()

Register this factory with the JVM.

public static void
release(ClassLoader
The class loader to release
classLoader
)

Release references to any user provided factories that have been loaded using the provided class loader.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLASSPATH_PROTOCOLback to summary
private static final String CLASSPATH_PROTOCOL
instanceback to summary
private static volatile TomcatURLStreamHandlerFactory instance
registeredback to summary
private final boolean registered
userFactoriesback to summary
private final List<URLStreamHandlerFactory> userFactories
WAR_PROTOCOLback to summary
private static final String WAR_PROTOCOL

Constructor Detail

TomcatURLStreamHandlerFactoryback to summary
private TomcatURLStreamHandlerFactory(boolean register)

Method Detail

addUserFactoryback to summary
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:URLStreamHandlerFactory

The user provided factory to add to the factories Tomcat has already registered

createURLStreamHandlerback to summary
public URLStreamHandler createURLStreamHandler(String protocol)

Implements java.net.URLStreamHandlerFactory.createURLStreamHandler.

Doc from java.net.URLStreamHandlerFactory.createURLStreamHandler.

Creates a new URLStreamHandler instance with the specified protocol.

Parameters
protocol:String

the protocol ("ftp", "http", "nntp", etc.).

Returns:URLStreamHandler

a URLStreamHandler for the specific protocol, or null if this factory cannot create a handler for the specific protocol

Annotations
@Override
disableback to summary
public static boolean disable()

Prevent this this factory from registering with the JVM. May be called more than once.

Returns:boolean

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.

getInstanceback to summary
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:TomcatURLStreamHandlerFactory

A reference to the singleton instance

getInstanceInternalback to summary
private static TomcatURLStreamHandlerFactory getInstanceInternal(boolean register)
isRegisteredback to summary
public boolean isRegistered()
registerback to summary
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:boolean

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.

releaseback to summary
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:ClassLoader

The class loader to release