protected ApplicationContext getApplicationContext ( JobExecutionContext context ) throws SchedulerException { final SchedulerContext schedulerContext = context . getScheduler ( ) . getContext ( ) ; ApplicationContext applicationContext = ( ApplicationContext ) schedulerContext . get ( APPLICATION_CONTEXT_KEY ) ; // show keys in context if ( applicationContext == null ) { logger . error ( APPLICATION_CONTEXT_KEY + " is empty in " + schedulerContext + ":" ) ; if ( schedulerContext . getKeys ( ) != null ) { for ( String key : schedulerContext . getKeys ( ) ) { Object value = schedulerContext . get ( key ) ; String valueText = value != null ? value . toString ( ) : "<NULL>" ; logger . info ( " {} = {}" , key , valueText ) ; } } } return applicationContext ; }
Obtains Spring s application context .