KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > benchmark > Exclude


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.taglibs.benchmark;
17
18 import java.util.*;
19 import javax.servlet.*;
20 import javax.servlet.jsp.*;
21 import javax.servlet.jsp.tagext.*;
22
23 /**
24  *
25  * A tag handler for the <benchmark:exclude> tag, which excludes
26  * the time it takes to process its body from its nearest
27  * <benchmark:duration> ancestor's timer.
28  *
29  * @version 0.90
30  * @author Shawn Bayern
31  */

32
33 public class Exclude extends TagSupport {
34
35     private Duration p; // parent Duration tag handler
36

37     public void release() {
38     p = null;
39     }
40
41     public int doStartTag() throws JspException {
42     p = (Duration) findAncestorWithClass(this, Duration.class);
43     if (p == null)
44         throw new JspTagException(
45         "<exclude> must be enclosed within "
46         + "<duration>");
47     p.pauseTimer();
48     return EVAL_BODY_INCLUDE;
49     }
50
51     public int doEndTag() throws JspException {
52     p.restartTimer();
53     return EVAL_PAGE;
54     }
55 }
56
Popular Tags