KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > instrument > test > TestInstrumentProxy


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

19
20 package org.apache.excalibur.instrument.test;
21
22 import org.apache.excalibur.instrument.InstrumentProxy;
23
24 /**
25  * Dummy InstrumentProxy used to test instruments.
26  *
27  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
28  * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:34 $
29  */

30 public class TestInstrumentProxy
31     implements InstrumentProxy
32 {
33     private boolean m_active;
34     private int m_value;
35     
36     /*---------------------------------------------------------------
37      * InstrumentProxy Methods
38      *-------------------------------------------------------------*/

39     /**
40      * Used by classes being profiles so that they can avoid unnecessary
41      * code when the data from a Instrument is not being used.
42      *
43      * @return True if listeners are registered with the Instrument.
44      */

45     public boolean isActive()
46     {
47         return m_active;
48     }
49     
50     /**
51      * Increments the Instrument by a specified count. This method should be
52      * optimized to be extremely light weight when there are no registered
53      * CounterInstrumentListeners.
54      * <p>
55      * This method may throw an IllegalStateException if the proxy is not meant
56      * to handle calls to increment.
57      *
58      * @param count A positive integer to increment the counter by.
59      */

60     public void increment( int count )
61     {
62         m_value += count;
63     }
64     
65     /**
66      * Sets the current value of the Instrument. This method is optimized
67      * to be extremely light weight when there are no registered
68      * ValueInstrumentListeners.
69      * <p>
70      * This method may throw an IllegalStateException if the proxy is not meant
71      * to handle calls to setValue.
72      *
73      * @param value The new value for the Instrument.
74      */

75     public void setValue( int value )
76     {
77         m_value = value;
78     }
79     
80     /*---------------------------------------------------------------
81      * Methods
82      *-------------------------------------------------------------*/

83     /**
84      * Sets the activate flag on the proxy so that it will collect information.
85      */

86     public void activate()
87     {
88         m_active = true;
89     }
90     
91     /**
92      **/

93     public int getValue()
94     {
95         return m_value;
96     }
97 }
98
Popular Tags