public static void register ( final String scheme , Class < ? extends URLStreamHandler > handlerType ) { if ( ! registeredSchemes . add ( scheme ) ) { throw new IllegalStateException ( "a scheme has already been registered for " + scheme ) ; } registerPackage ( "org.skife.url.generated" ) ; Enhancer e = new Enhancer ( ) ; e . setNamingPolicy ( new NamingPolicy ( ) { @ Override public String getClassName ( String prefix , String source , Object key , Predicate names ) { return "org.skife.url.generated." + scheme + ".Handler" ; } } ) ; e . setSuperclass ( handlerType ) ; e . setCallbackType ( NoOp . class ) ; e . createClass ( ) ; }
Used to register a handler for a scheme . The actual handler used will in fact be a runtime generated subclass of handlerType in order to abide by the naming rules for URL scheme handlers .