Class ClasspathURLStreamHandler

java.lang.Object
org.infinispan.commons.util.ClasspathURLStreamHandler
All Implemented Interfaces:
URLStreamHandlerFactory

public class ClasspathURLStreamHandler extends Object implements URLStreamHandlerFactory
A URLStreamHandlerFactory which can handle classpath: URI schemes. It will attempt to load resources from the thread's context classloader (if it exists) and then fallback to the system classloader. The factory must be registered as the URL stream handler factory using the register() method. On Java 9+, this class is available as a URLStreamHandlerProvider service loader implementation which, if present in the boot classpath, will be automatically registered and used by the URL class.
Since:
12.1
Author:
Tristan Tarrant <tristan@infinispan.org>
  • Constructor Details

    • ClasspathURLStreamHandler

      public ClasspathURLStreamHandler()
  • Method Details

    • register

      public static void register()
      Registers this URL handler as the JVM-wide URL stream handler. It can only be invoked once in the lifecycle of an application. Refer to the URL documentation for restrictions and alternative methods of registration.
    • createURLStreamHandler

      public URLStreamHandler createURLStreamHandler(String protocol)
      Specified by:
      createURLStreamHandler in interface URLStreamHandlerFactory