public StatsImpl getStats ( boolean recursive ) { // DO THIS METHOD NEED SYNCHRONIZED ACCESS? // When multiple threads get inside the method and stats tree is updated if ( recursive ) { /* * // if leaf then do not create myStatsWithChildren. Instead return myStats * if (children == null && !bStatsTreeNeedsUpdate) * { * // return myStats * if (myStats == null) * { * if (instance != null) * myStats = instance.getStats (instance.listStatistics(), null); * else * myStats = new StatsImpl("server", TYPE_SERVER, level, null, null); * } * * return myStats; * } * else */ // first time here if ( myStatsWithChildren == null ) { ArrayList dataMembers = null ; if ( instance != null ) dataMembers = instance . listStatistics ( ) ; ArrayList colMembers = null ; // return subcollection members // getStats from children ModuleItem [ ] items = children ( ) ; if ( items != null ) { colMembers = new ArrayList ( items . length ) ; for ( int i = 0 ; i < items . length ; i ++ ) { colMembers . add ( items [ i ] . getStats ( recursive ) ) ; } } if ( instance != null ) myStatsWithChildren = instance . getStats ( dataMembers , colMembers ) ; else myStatsWithChildren = new StatsImpl ( "server" , TYPE_SERVER , level , null , colMembers ) ; } else { updateStatisticsForStatsTree ( System . currentTimeMillis ( ) ) ; // update external & aggregate statistics } return myStatsWithChildren ; } // NON-RECURSIVE else { if ( myStats == null ) { if ( instance != null ) myStats = instance . getStats ( instance . listStatistics ( ) , null ) ; else myStats = new StatsImpl ( "server" , TYPE_SERVER , level , null , null ) ; } else { if ( instance != null ) instance . updateStatistics ( ) ; // update external & aggregate statistics myStats . setTime ( System . currentTimeMillis ( ) ) ; } return myStats ; } /* * ArrayList dataMembers = instance.listStatistics(); * ArrayList colMembers = null; // return subcollection members * * if (recursive) * { * ModuleItem[] items = children(); * * // getStats from children * if(items != null) * { * colMembers = new ArrayList(items.length); * for(int i=0; i<items.length; i++) * { * colMembers.add(items[i].getStats(recursive)); * } * } * } * * // return Stats - individual instance will return different XXXStats instance * // Note: construct dataMembers in ModuleItem and pass it to instance * // because getStats will be overwritten by subclasses * // and we don't want to duplicate the same code. * * return instance.getStats(dataMembers, colMembers); */ }
is updated .