KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > instrument > manager > InstrumentableDescriptorLocalImpl


1 /*
2
3  ============================================================================
4                    The Apache Software License, Version 1.1
5  ============================================================================
6  
7  Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
8  
9  Redistribution and use in source and binary forms, with or without modifica-
10  tion, are permitted provided that the following conditions are met:
11  
12  1. Redistributions of source code must retain the above copyright notice,
13     this list of conditions and the following disclaimer.
14  
15  2. Redistributions in binary form must reproduce the above copyright notice,
16     this list of conditions and the following disclaimer in the documentation
17     and/or other materials provided with the distribution.
18  
19  3. The end-user documentation included with the redistribution, if any, must
20     include the following acknowledgment: "This product includes software
21     developed by the Apache Software Foundation (http://www.apache.org/)."
22     Alternately, this acknowledgment may appear in the software itself, if
23     and wherever such third-party acknowledgments normally appear.
24  
25  4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
26     must not be used to endorse or promote products derived from this software
27     without prior written permission. For written permission, please contact
28     apache@apache.org.
29  
30  5. Products derived from this software may not be called "Apache", nor may
31     "Apache" appear in their name, without prior written permission of the
32     Apache Software Foundation.
33  
34  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
35  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
36  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37  APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
38  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
39  DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
40  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
41  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
43  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  
45  This software consists of voluntary contributions made by many individuals
46  on behalf of the Apache Software Foundation. For more information on the
47  Apache Software Foundation, please see <http://www.apache.org/>.
48  
49 */

50 package org.apache.excalibur.instrument.manager;
51
52 import org.apache.excalibur.instrument.manager.interfaces.InstrumentDescriptor;
53 import org.apache.excalibur.instrument.manager.interfaces.InstrumentableDescriptor;
54 import org.apache.excalibur.instrument.manager.interfaces.NoSuchInstrumentException;
55 import org.apache.excalibur.instrument.manager.interfaces.NoSuchInstrumentableException;
56
57 /**
58  * Describes a Instrumentable and acts as a Proxy to protect the original
59  * Instrumentable.
60  *
61  * @author <a HREF="mailto:leif@tanukisoftware.com">Leif Mortenson</a>
62  * @version CVS $Revision: 1.4 $ $Date: 2003/02/25 16:28:16 $
63  * @since 4.1
64  */

65 public class InstrumentableDescriptorLocalImpl
66     implements InstrumentableDescriptorLocal
67 {
68     /** InstrumentableProxy being described. */
69     private InstrumentableProxy m_instrumentableProxy;
70
71     /*---------------------------------------------------------------
72      * Constructors
73      *-------------------------------------------------------------*/

74     /**
75      * Creates a new InstrumentableDescriptorLocalImpl.
76      *
77      * @param instrumentableProxy InstrumentableProxy being described.
78      */

79     InstrumentableDescriptorLocalImpl( InstrumentableProxy instrumentableProxy )
80     {
81         m_instrumentableProxy = instrumentableProxy;
82     }
83
84     /*---------------------------------------------------------------
85      * InstrumentableDescriptor Methods
86      *-------------------------------------------------------------*/

87     /**
88      * Returns true if the Instrumentable was configured in the instrumentables
89      * section of the configuration.
90      *
91      * @return True if configured.
92      */

93     public boolean isConfigured()
94     {
95         return m_instrumentableProxy.isConfigured();
96     }
97
98     /**
99      * Returns true if the Instrumentable was registered with the Instrument
100      * Manager.
101      *
102      * @return True if registered.
103      */

104     public boolean isRegistered()
105     {
106         return m_instrumentableProxy.isRegistered();
107     }
108     
109     /**
110      * Gets the name for the Instrumentable. The Instrumentable Name is used to
111      * uniquely identify the Instrumentable during the configuration of the
112      * Profiler and to gain access to a InstrumentableDescriptor through a
113      * ProfilerManager.
114      *
115      * @return The name used to identify a Instrumentable.
116      */

117     public String JavaDoc getName()
118     {
119         return m_instrumentableProxy.getName();
120     }
121
122     /**
123      * Gets the description of the Instrumentable.
124      *
125      * @return The description of the Instrumentable.
126      */

127     public String JavaDoc getDescription()
128     {
129         return m_instrumentableProxy.getDescription();
130     }
131
132     /**
133      * Returns a child InstrumentableDescriptor based on its name or the name
134      * of any of its children.
135      *
136      * @param childInstrumentableName Name of the child Instrumentable being
137      * requested.
138      *
139      * @return A descriptor of the requested child Instrumentable.
140      *
141      * @throws NoSuchInstrumentableException If the specified Instrumentable
142      * does not exist.
143      */

144     public InstrumentableDescriptor getChildInstrumentableDescriptor(
145                                                 String JavaDoc childInstrumentableName )
146         throws NoSuchInstrumentableException
147     {
148         return getChildInstrumentableDescriptorLocal( childInstrumentableName );
149     }
150
151     /**
152      * Returns an array of Descriptors for the child Instrumentables registered
153      * by this Instrumentable.
154      *
155      * @return An array of Descriptors for the child Instrumentables registered
156      * by this Instrumentable.
157      */

158     public InstrumentableDescriptor[] getChildInstrumentableDescriptors()
159     {
160         return getChildInstrumentableDescriptorLocals();
161     }
162         
163     /**
164      * Returns a InstrumentDescriptor based on its name.
165      *
166      * @param instrumentName Name of the Instrument being requested.
167      *
168      * @return A Descriptor of the requested Instrument.
169      *
170      * @throws NoSuchInstrumentException If the specified Instrument does
171      * not exist.
172      */

173     public InstrumentDescriptor getInstrumentDescriptor( String JavaDoc instrumentName )
174         throws NoSuchInstrumentException
175     {
176         return getInstrumentDescriptorLocal( instrumentName );
177     }
178
179     /**
180      * Returns an array of Descriptors for the Instruments registered by this
181      * Instrumentable.
182      *
183      * @return An array of Descriptors for the Instruments registered by this
184      * Instrumentable.
185      */

186     public InstrumentDescriptor[] getInstrumentDescriptors()
187     {
188         return getInstrumentDescriptorLocals();
189     }
190     
191     /**
192      * Returns the stateVersion of the instrumentable. The state version
193      * will be incremented each time any of the configuration of the
194      * instrumentable or any of its children is modified.
195      * Clients can use this value to tell whether or not anything has
196      * changed without having to do an exhaustive comparison.
197      *
198      * @return The state version of the instrumentable.
199      */

200     public int getStateVersion()
201     {
202         return m_instrumentableProxy.getStateVersion();
203     }
204     
205     /*---------------------------------------------------------------
206      * InstrumentableDescriptorLocal Methods
207      *-------------------------------------------------------------*/

208     /**
209      * Returns a child InstrumentableDescriptorLocal based on its name or the
210      * name of any of its children.
211      *
212      * @param childInstrumentableName Name of the child Instrumentable being
213      * requested.
214      *
215      * @return A descriptor of the requested child Instrumentable.
216      *
217      * @throws NoSuchInstrumentableException If the specified Instrumentable
218      * does not exist.
219      */

220     public InstrumentableDescriptorLocal getChildInstrumentableDescriptorLocal(
221                                                     String JavaDoc childInstrumentableName )
222         throws NoSuchInstrumentableException
223     {
224         InstrumentableProxy instrumentableProxy =
225             m_instrumentableProxy.getChildInstrumentableProxy( childInstrumentableName );
226         if( instrumentableProxy == null )
227         {
228             throw new NoSuchInstrumentableException(
229                 "No child instrumentable can be found using name: " + childInstrumentableName );
230         }
231
232         return instrumentableProxy.getDescriptor();
233     }
234
235     /**
236      * Returns an array of Descriptors for the child Instrumentables registered
237      * by this Instrumentable.
238      *
239      * @return An array of Descriptors for the child Instrumentables registered
240      * by this Instrumentable.
241      */

242     public InstrumentableDescriptorLocal[] getChildInstrumentableDescriptorLocals()
243     {
244         return m_instrumentableProxy.getChildInstrumentableDescriptors();
245     }
246     
247     /**
248      * Returns a InstrumentDescriptorLocal based on its name.
249      *
250      * @param instrumentName Name of the Instrument being requested.
251      *
252      * @return A Descriptor of the requested Instrument.
253      *
254      * @throws NoSuchInstrumentException If the specified Instrument does
255      * not exist.
256      */

257     public InstrumentDescriptorLocal getInstrumentDescriptorLocal( String JavaDoc instrumentName )
258         throws NoSuchInstrumentException
259     {
260         InstrumentProxy instrumentProxy =
261             m_instrumentableProxy.getInstrumentProxy( instrumentName );
262         if( instrumentProxy == null )
263         {
264             throw new NoSuchInstrumentException(
265                 "No instrument can be found using name: " + instrumentName );
266         }
267
268         return instrumentProxy.getDescriptor();
269     }
270
271     /**
272      * Returns an array of Descriptors for the Instruments registered by this
273      * Instrumentable.
274      *
275      * @return An array of Descriptors for the Instruments registered by this
276      * Instrumentable.
277      */

278     public InstrumentDescriptorLocal[] getInstrumentDescriptorLocals()
279     {
280         return m_instrumentableProxy.getInstrumentDescriptors();
281     }
282 }
283
Popular Tags