private static void addTriggers ( ) { if ( ! PERSISTENCE_ENABLED ) { return ; } Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( "JCRStatisticsManager-Hook" ) { @ Override public void run ( ) { printData ( ) ; } } ) ; Thread t = new Thread ( "JCRStatisticsManager-Writer" ) { @ Override public void run ( ) { while ( true ) { try { sleep ( PERSISTENCE_TIMEOUT ) ; } catch ( InterruptedException e ) { LOG . debug ( "InterruptedException" , e ) ; } printData ( ) ; } } } ; t . setDaemon ( true ) ; t . start ( ) ; }
Add all the triggers that will keep the file up to date only if the persistence is enabled .