protected static Interceptor createInterceptor ( InterceptorConfig config , Class baseClassOrInterface ) { assert Interceptor . class . isAssignableFrom ( baseClassOrInterface ) : baseClassOrInterface . getName ( ) + " cannot be assigned to " + Interceptor . class . getName ( ) ; ClassLoader cl = DiscoveryUtils . getClassLoader ( ) ; String className = config . getInterceptorClass ( ) ; try { Class interceptorClass = cl . loadClass ( className ) ; if ( ! baseClassOrInterface . isAssignableFrom ( interceptorClass ) ) { _log . error ( "Interceptor " + interceptorClass . getName ( ) + " does not implement or extend " + baseClassOrInterface . getName ( ) ) ; return null ; } Interceptor interceptor = ( Interceptor ) interceptorClass . newInstance ( ) ; interceptor . init ( config ) ; return interceptor ; } catch ( ClassNotFoundException e ) { _log . error ( "Could not find interceptor class " + className , e ) ; } catch ( InstantiationException e ) { _log . error ( "Could not instantiate interceptor class " + className , e ) ; } catch ( IllegalAccessException e ) { _log . error ( "Could not instantiate interceptor class " + className , e ) ; } return null ; }
Instantiates an interceptor using the class name in the given InterceptorConfig .