public InterceptorBean createInterceptor ( StageLibraryTask stageLib , InterceptorDefinition definition , StageConfiguration stageConfiguration , StageDefinition stageDefinition , InterceptorCreatorContextBuilder contextBuilder , InterceptorCreator . InterceptorType interceptorType , List < Issue > issues ) { ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; InterceptorCreator . Context context = contextBuilder . buildFor ( definition . getLibraryDefinition ( ) . getName ( ) , definition . getKlass ( ) . getName ( ) , stageConfiguration , stageDefinition , interceptorType ) ; try { Thread . currentThread ( ) . setContextClassLoader ( definition . getStageClassLoader ( ) ) ; InterceptorCreator creator = definition . getDefaultCreator ( ) . newInstance ( ) ; Interceptor interceptor = creator . create ( context ) ; if ( interceptor == null ) { return null ; } return new InterceptorBean ( definition , interceptor , stageLib ) ; } catch ( IllegalAccessException | InstantiationException e ) { LOG . debug ( "Can't instantiate interceptor: {}" , e . toString ( ) , e ) ; IssueCreator issueCreator = IssueCreator . getStage ( stageDefinition . getName ( ) ) ; issues . add ( issueCreator . create ( CreationError . CREATION_000 , "interceptor" , definition . getKlass ( ) . getName ( ) , e . toString ( ) ) ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( classLoader ) ; } return null ; }
Create a default interceptor for given InterceptorDefinition . This method might return null as the underlying interface for default creation allows it as well - in such case no interceptor is needed .