private static Handler createHandler ( String className , Class baseClassOrInterface , Handler previousHandler , ServletContext servletContext ) { assert Handler . class . isAssignableFrom ( baseClassOrInterface ) : baseClassOrInterface . getName ( ) + " cannot be assigned to " + Handler . class . getName ( ) ; ClassLoader cl = DiscoveryUtils . getClassLoader ( ) ; try { Class handlerClass = cl . loadClass ( className ) ; if ( ! baseClassOrInterface . isAssignableFrom ( handlerClass ) ) { _log . error ( "Handler " + handlerClass . getName ( ) + " does not implement or extend " + baseClassOrInterface . getName ( ) ) ; return null ; } Handler handler = ( Handler ) handlerClass . newInstance ( ) ; return handler ; } catch ( ClassNotFoundException e ) { _log . error ( "Could not find Handler class " + className , e ) ; } catch ( InstantiationException e ) { _log . error ( "Could not instantiate Handler class " + className , e ) ; } catch ( IllegalAccessException e ) { _log . error ( "Could not instantiate Handler class " + className , e ) ; } return null ; }
Instantiates a handler based on the class name in the given HandlerConfig .