public URLStreamHandler createURLStreamHandler(final String protocol)
   {
      // Check the handler map
      URLStreamHandler handler = (URLStreamHandler) handlerMap.get(protocol);
      if( handler != null )
         return handler;

      // Validate that createURLStreamHandler is not recursing
      String prevProtocol = (String) createURLStreamHandlerProtocol.get();
      if( prevProtocol != null && prevProtocol.equals(protocol) )
         return null;
      createURLStreamHandlerProtocol.set(protocol);

      // See if the handler pkgs definition has changed
      checkHandlerPkgs();

      // Search the handlerPkgs for a matching protocol handler
      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
      for(int p = 0; p < handlerPkgs.length; p ++)
      {
         try
         {
            // Form the standard protocol handler class name
            String classname = handlerPkgs[p] + "." + protocol + ".Handler";
            Class<?> type = null;

            try
            {
               type = ctxLoader.loadClass(classname);
            }
            catch(ClassNotFoundException e)
            {
               // Try our class loader
               type = Class.forName(classname);
            }

            if( type != null )
            {
               handler = (URLStreamHandler) type.newInstance();
               handlerMap.put(protocol, handler);
               log.trace("Found protocol:"+protocol+" handler:"+handler);
            }
         }
         catch (Throwable ignore)
         {
         }
      }

      createURLStreamHandlerProtocol.set(null);
      return handler;
   }
public URLStreamHandler createURLStreamHandler(final String protocol)
   {
      
      URLStreamHandler handler = (URLStreamHandler) handlerMap.get(protocol);
      if( handler != null )
         return handler;

      
      String prevProtocol = (String) createURLStreamHandlerProtocol.get();
      if( prevProtocol != null && prevProtocol.equals(protocol) )
         return null;
      createURLStreamHandlerProtocol.set(protocol);

      
      checkHandlerPkgs();

      
      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
      for(int p = 0; p < handlerPkgs.length; p ++)
      {
         try
         {
            
            String classname = handlerPkgs[p] + "." + protocol + ".Handler";
            Class<?> type = null;

            try
            {
               type = ctxLoader.loadClass(classname);
            }
            catch(ClassNotFoundException e)
            {
               
               type = Class.forName(classname);
            }

            if( type != null )
            {
               handler = (URLStreamHandler) type.newInstance();
               handlerMap.put(protocol, handler);
               log.trace("Found protocol:"+protocol+" handler:"+handler);
            }
         }
         catch (Throwable ignore)
         {
         }
      }

      createURLStreamHandlerProtocol.set(null);
      return handler;
   }
public URLStreamHandler createURLStreamHandler ( final String protocol ) { // Check the handler map URLStreamHandler handler = ( URLStreamHandler ) handlerMap . get ( protocol ) ; if ( handler != null ) return handler ; // Validate that createURLStreamHandler is not recursing String prevProtocol = ( String ) createURLStreamHandlerProtocol . get ( ) ; if ( prevProtocol != null && prevProtocol . equals ( protocol ) ) return null ; createURLStreamHandlerProtocol . set ( protocol ) ; // See if the handler pkgs definition has changed checkHandlerPkgs ( ) ; // Search the handlerPkgs for a matching protocol handler ClassLoader ctxLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; for ( int p = 0 ; p < handlerPkgs . length ; p ++ ) { try { // Form the standard protocol handler class name String classname = handlerPkgs [ p ] + "." + protocol + ".Handler" ; Class < ? > type = null ; try { type = ctxLoader . loadClass ( classname ) ; } catch ( ClassNotFoundException e ) { // Try our class loader type = Class . forName ( classname ) ; } if ( type != null ) { handler = ( URLStreamHandler ) type . newInstance ( ) ; handlerMap . put ( protocol , handler ) ; log . trace ( "Found protocol:" + protocol + " handler:" + handler ) ; } } catch ( Throwable ignore ) { } } createURLStreamHandlerProtocol . set ( null ) ; return handler ; }
Search the handlerPkgs for URLStreamHandler classes matching the
pkg + protocol + ".Handler" naming convention.

@param protocol The protocol to create a stream handler for
@return The protocol handler or null if not found
Search the handlerPkgs for URLStreamHandler classes matching the pkg + protocol + . Handler naming convention .