public static void registerStatistics ( String category , Statistics global , Map < String , Statistics > allStatistics ) { if ( category == null || category . length ( ) == 0 ) { throw new IllegalArgumentException ( "The category of the statistics cannot be empty" ) ; } if ( allStatistics == null || allStatistics . isEmpty ( ) ) { throw new IllegalArgumentException ( "The list of statistics " + category + " cannot be empty" ) ; } PrintWriter pw = null ; if ( PERSISTENCE_ENABLED ) { pw = initWriter ( category ) ; if ( pw == null ) { LOG . warn ( "Cannot create the print writer for the statistics " + category ) ; } } startIfNeeded ( ) ; synchronized ( JCRStatisticsManager . class ) { Map < String , StatisticsContext > tmpContexts = new HashMap < String , StatisticsContext > ( CONTEXTS ) ; StatisticsContext ctx = new StatisticsContext ( pw , global , allStatistics ) ; tmpContexts . put ( category , ctx ) ; if ( pw != null ) { // Define the file header printHeader ( ctx ) ; } CONTEXTS = Collections . unmodifiableMap ( tmpContexts ) ; } }
Register a new category of statistics to manage .