KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > tools > profiler > CategorizingProfilerPoint


1 /*
2  * Copyright (c) 1998-2005 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Sam
27  */

28
29
30 package com.caucho.tools.profiler;
31
32 import java.util.Collection JavaDoc;
33
34 /**
35  * Usage of the a ProfilerPoint returned by {@link #createProfilerPoint(String)}
36  * guarantees that this ProfilerPoint is an ancestor in the execution stack.
37  */

38 public class CategorizingProfilerPoint
39   extends ProfilerPoint
40 {
41   CategorizingProfilerPoint(ProfilerManager profilerManager, String JavaDoc name)
42   {
43     super(profilerManager, name);
44   }
45
46   public ProfilerPoint createProfilerPoint(String JavaDoc name)
47   {
48     return new ProfilerPointParentSettingDelegate(this, getProfilerManager().getProfilerPoint(name));
49   }
50
51   private static final class ProfilerPointParentSettingDelegate
52     extends ProfilerPoint
53   {
54     private final ProfilerPoint _parent;
55     private final ProfilerPoint _profilerPoint;
56
57     ProfilerPointParentSettingDelegate(ProfilerPoint parent, ProfilerPoint profilerPoint)
58     {
59       super(profilerPoint.getProfilerManager(), "ProfilerPointParentSettingDelegate{" + profilerPoint + "}");
60
61       assert parent != null;
62       assert profilerPoint != null;
63
64       _parent = parent;
65       _profilerPoint = profilerPoint;
66     }
67
68     public String JavaDoc getName()
69     {
70       return _profilerPoint.getName();
71     }
72
73     public Profiler start()
74     {
75       return _profilerPoint.start(_parent);
76     }
77
78     public Collection JavaDoc<ProfilerNode> getProfilerNodes()
79     {
80       return _profilerPoint.getProfilerNodes();
81     }
82
83     public ProfilerNode getProfilerNode(ProfilerNode parentNode)
84     {
85       return _profilerPoint.getProfilerNode(parentNode);
86     }
87
88     public void reset()
89     {
90       _profilerPoint.reset();
91     }
92   }
93 }
94
Popular Tags