KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Arrays JavaDoc;
53 import java.util.Comparator JavaDoc;
54 import java.util.HashMap JavaDoc;
55
56 import org.apache.avalon.framework.configuration.Configurable;
57 import org.apache.avalon.framework.configuration.Configuration;
58 import org.apache.avalon.framework.configuration.ConfigurationException;
59 import org.apache.avalon.framework.configuration.DefaultConfiguration;
60 import org.apache.avalon.framework.logger.AbstractLogEnabled;
61
62 /**
63  * A InstrumentableProxy makes it easy for the InstrumentManager to manage
64  * Instrumentables and their Instruments.
65  * <p>
66  * Not Synchronized.
67  *
68  * @author <a HREF="mailto:leif@tanukisoftware.com">Leif Mortenson</a>
69  * @version CVS $Revision: 1.4 $ $Date: 2003/02/25 16:28:16 $
70  * @since 4.1
71  */

72 class InstrumentableProxy
73     extends AbstractLogEnabled
74     implements Configurable
75 {
76     /** InstrumentManager which owns the proxy. */
77     private DefaultInstrumentManager m_instrumentManager;
78     
79     /** The parent Instrumentable proxy or null if this is a top level
80      * Instrumentable. */

81     private InstrumentableProxy m_parentInstrumentableProxy;
82     
83     /** Configured flag. */
84     private boolean m_configured;
85
86     /** Registered flag. */
87     private boolean m_registered;
88
89     /** The name used to identify a Instrumentable. */
90     private String JavaDoc m_name;
91
92     /** The description of the Instrumentable. */
93     private String JavaDoc m_description;
94
95     /** The Descriptor for the Instrumentable. */
96     private InstrumentableDescriptorLocalImpl m_descriptor;
97
98     /** Map of the Child InstrumentableProxies owned by this InstrumentableProxy. */
99     private HashMap JavaDoc m_childInstrumentableProxies = new HashMap JavaDoc();
100
101     /** Optimized array of the child InstrumentableProxies. */
102     private InstrumentableProxy[] m_childInstrumentableProxyArray;
103
104     /** Optimized array of the child InstrumentableDescriptorLocals. */
105     private InstrumentableDescriptorLocal[] m_childInstrumentableDescriptorArray;
106
107     /** Map of the InstrumentProxies owned by this InstrumentableProxy. */
108     private HashMap JavaDoc m_instrumentProxies = new HashMap JavaDoc();
109
110     /** Optimized array of the InstrumentProxies. */
111     private InstrumentProxy[] m_instrumentProxyArray;
112
113     /** Optimized array of the InstrumentDescriptorLocals. */
114     private InstrumentDescriptorLocal[] m_instrumentDescriptorArray;
115     
116     /** State Version. */
117     private int m_stateVersion;
118
119     /*---------------------------------------------------------------
120      * Constructors
121      *-------------------------------------------------------------*/

122     /**
123      * Creates a new InstrumentableProxy.
124      *
125      * @param instrumentManager InstrumentManager which owns the proxy.
126      * @param parentInstrumentableProxy The parent Instrumentable proxy or null
127      * if this is a top level Instrumentable.
128      * @param name The name used to identify a Instrumentable.
129      * @param description The description of the the Instrumentable.
130      */

131     InstrumentableProxy( DefaultInstrumentManager instrumentManager,
132                          InstrumentableProxy parentInstrumentableProxy,
133                          String JavaDoc name,
134                          String JavaDoc description )
135     {
136         m_instrumentManager = instrumentManager;
137         m_parentInstrumentableProxy = parentInstrumentableProxy;
138         m_name = name;
139         m_description = description;
140
141         // Create the descriptor
142
m_descriptor = new InstrumentableDescriptorLocalImpl( this );
143     }
144
145     /*---------------------------------------------------------------
146      * Configurable Methods
147      *-------------------------------------------------------------*/

148     /**
149      * Configures the Instrumentable. Called from the ProfilerManager's
150      * configure method. The class does not need to be configured to
151      * function correctly.
152      *
153      * @param configuration Instrumentable configuration element from the
154      * ProfilerManager's configuration.
155      *
156      * @throws ConfigurationException If there are any configuration problems.
157      */

158     public void configure( Configuration configuration )
159         throws ConfigurationException
160     {
161         synchronized( this )
162         {
163             // The description is optional. Default to the description from the constructor.
164
m_description = configuration.getAttribute( "description", m_description );
165
166             if( getLogger().isDebugEnabled() )
167             {
168                 getLogger().debug( "Configuring Instrumentable: " + m_name + " as \"" +
169                                    m_description + "\"" );
170             }
171
172             m_configured = true;
173             
174             // Configure any child Instrumentables
175
Configuration[] childConfs = configuration.getChildren( "instrumentable" );
176             for( int i = 0; i < childConfs.length; i++ )
177             {
178                 Configuration childConf = childConfs[ i ];
179                 String JavaDoc childName = childConf.getAttribute( "name" );
180                 String JavaDoc fullChildName = m_name + "." + childName;
181
182                 InstrumentableProxy childProxy = new InstrumentableProxy(
183                     m_instrumentManager, this, fullChildName, childName );
184                 childProxy.enableLogging( getLogger() );
185                 childProxy.configure( childConf );
186                 m_childInstrumentableProxies.put( fullChildName, childProxy );
187
188                 // Clear the optimized arrays
189
m_childInstrumentableProxyArray = null;
190                 m_childInstrumentableDescriptorArray = null;
191             }
192             
193             // Configure any Instruments
194
Configuration[] instrumentConfs = configuration.getChildren( "instrument" );
195             for( int i = 0; i < instrumentConfs.length; i++ )
196             {
197                 Configuration instrumentConf = instrumentConfs[ i ];
198                 String JavaDoc instrumentName = instrumentConf.getAttribute( "name" );
199                 String JavaDoc fullInstrumentName = m_name + "." + instrumentName;
200
201                 InstrumentProxy instrumentProxy =
202                     new InstrumentProxy( this, fullInstrumentName, instrumentName );
203                 instrumentProxy.enableLogging( getLogger() );
204                 instrumentProxy.configure( instrumentConf );
205                 m_instrumentProxies.put( fullInstrumentName, instrumentProxy );
206
207                 // Clear the optimized arrays
208
m_instrumentProxyArray = null;
209                 m_instrumentDescriptorArray = null;
210             }
211         }
212     }
213
214     /*---------------------------------------------------------------
215      * Methods
216      *-------------------------------------------------------------*/

217     /**
218      * Returns instrumentManager which owns the proxy.
219      *
220      * @return InstrumentManager which owns the proxy.
221      */

222     DefaultInstrumentManager getInstrumentManager()
223     {
224         return m_instrumentManager;
225     }
226     
227     /**
228      * Returns the parent InstrumentableProxy or null if this is a top level
229      * proxy.
230      *
231      * @return The parent InstrumentableProxy or null.
232      */

233     InstrumentableProxy getParentInstrumentableProxy()
234     {
235         return m_parentInstrumentableProxy;
236     }
237     
238     /**
239      * Returns true if the instrumentable was configured in the instrumentables
240      * section of the configuration.
241      *
242      * @return True if configured.
243      */

244     boolean isConfigured()
245     {
246         return m_configured;
247     }
248
249     /**
250      * Returns true if the Instrumentable was registered with the Instrument
251      * Manager.
252      *
253      * @return True if registered.
254      */

255     boolean isRegistered()
256     {
257         return m_registered;
258     }
259     
260     /**
261      * Called by the InstrumentManager whenever an Instrumentable assigned to
262      * this proxy is registered.
263      */

264     void setRegistered()
265     {
266         m_registered = true;
267     }
268     
269     /**
270      * Gets the name for the Instrumentable. The Instrumentable Name is used to
271      * uniquely identify the Instrumentable during the configuration of the
272      * Profiler and to gain access to a InstrumentableDescriptor through a
273      * ProfilerManager.
274      *
275      * @return The name used to identify a Instrumentable.
276      */

277     String JavaDoc getName()
278     {
279         return m_name;
280     }
281
282     /**
283      * Sets the description for the instrumentable object. This description will
284      * be set during the configuration of the profiler if a configuration
285      * exists for this Instrumentable.
286      *
287      * @param description The description of the Instrumentable.
288      */

289     void setDescription( String JavaDoc description )
290     {
291         m_description = description;
292     }
293
294     /**
295      * Gets the description of the Instrumentable.
296      *
297      * @return The description of the Instrumentable.
298      */

299     String JavaDoc getDescription()
300     {
301         return m_description;
302     }
303
304     /**
305      * Returns a Descriptor for the Instrumentable.
306      *
307      * @return A Descriptor for the Instrumentable.
308      */

309     InstrumentableDescriptorLocal getDescriptor()
310     {
311         return m_descriptor;
312     }
313
314     /*---------------------------------------------------------------
315      * Methods (child Instrumentables)
316      *-------------------------------------------------------------*/

317     /**
318      * Adds a child InstrumentableProxy to the Instrumentable. This method
319      * will be called during the configuration phase of the Profiler if an
320      * element defining the child Instrumentable exists, or if the
321      * Instrumentable registers itself with the InstrumentManager as it
322      * is running.
323      * <p>
324      * This method should never be called for child Instrumentables which
325      * have already been added.
326      *
327      * @param childInstrumentableProxy Child InstrumentableProxy to be added.
328      */

329     void addChildInstrumentableProxy( InstrumentableProxy childInstrumentableProxy )
330     {
331         synchronized( this )
332         {
333             m_childInstrumentableProxies.put(
334                 childInstrumentableProxy.getName(), childInstrumentableProxy );
335
336             // Clear the optimized arrays
337
m_childInstrumentableProxyArray = null;
338             m_childInstrumentableDescriptorArray = null;
339         }
340         
341         stateChanged();
342     }
343
344     /**
345      * Returns a child InstrumentableProxy based on its name or the name of any
346      * of its children.
347      *
348      * @param childInstrumentableName Name of the child Instrumentable being
349      * requested.
350      *
351      * @return The requested child InstrumentableProxy or null if does not
352      * exist.
353      */

354     InstrumentableProxy getChildInstrumentableProxy( String JavaDoc childInstrumentableName )
355     {
356         synchronized( this )
357         {
358             String JavaDoc name = childInstrumentableName;
359             while( true )
360             {
361                 InstrumentableProxy proxy =
362                     (InstrumentableProxy)m_childInstrumentableProxies.get( name );
363                 if( proxy != null )
364                 {
365                     return proxy;
366                 }
367
368                 // Assume this is a child name and try looking with the parent name.
369
int pos = name.lastIndexOf( '.' );
370                 if( pos > 0 )
371                 {
372                     name = name.substring( 0, pos );
373                 }
374                 else
375                 {
376                     return null;
377                 }
378             }
379         }
380     }
381
382     /**
383      * Returns an array of Proxies to the child Instrumentables in this
384      * Instrumentable.
385      *
386      * @return An array of Proxies to the child Instrumentables in this
387      * Instrumentable.
388      */

389     InstrumentableProxy[] getChildInstrumentableProxies()
390     {
391         InstrumentableProxy[] proxies = m_childInstrumentableProxyArray;
392         if( proxies == null )
393         {
394             proxies = updateChildInstrumentableProxyArray();
395         }
396         
397         return proxies;
398     }
399
400     /**
401      * Returns an array of Descriptors for the child Instrumentables in this
402      * Instrumentable.
403      *
404      * @return An array of Descriptors for the child Instrumentables in this
405      * Instrumentable.
406      */

407     InstrumentableDescriptorLocal[] getChildInstrumentableDescriptors()
408     {
409         InstrumentableDescriptorLocal[] descriptors = m_childInstrumentableDescriptorArray;
410         if( descriptors == null )
411         {
412             descriptors = updateChildInstrumentableDescriptorArray();
413         }
414         
415         return descriptors;
416     }
417
418     /**
419      * Updates the cached array of child InstrumentableProxies taking
420      * synchronization into account.
421      *
422      * @return An array of the child InstrumentableProxies.
423      */

424     private InstrumentableProxy[] updateChildInstrumentableProxyArray()
425     {
426         synchronized( this )
427         {
428             m_childInstrumentableProxyArray =
429                 new InstrumentableProxy[ m_childInstrumentableProxies.size() ];
430             m_childInstrumentableProxies.values().toArray( m_childInstrumentableProxyArray );
431
432             // Sort the array. This is not a performance problem because this
433
// method is rarely called and doing it here saves cycles in the
434
// client.
435
Arrays.sort( m_childInstrumentableProxyArray, new Comparator JavaDoc()
436                 {
437                     public int compare( Object JavaDoc o1, Object JavaDoc o2 )
438                     {
439                         return ((InstrumentableProxy)o1).getDescription().
440                             compareTo( ((InstrumentableProxy)o2).getDescription() );
441                     }
442                     
443                     public boolean equals( Object JavaDoc obj )
444                     {
445                         return false;
446                     }
447                 } );
448             
449             return m_childInstrumentableProxyArray;
450         }
451     }
452
453     /**
454      * Updates the cached array of child InstrumentableDescriptorLocals taking
455      * synchronization into account.
456      *
457      * @return An array of the child InstrumentableDescriptorLocals.
458      */

459     private InstrumentableDescriptorLocal[] updateChildInstrumentableDescriptorArray()
460     {
461         synchronized( this )
462         {
463             if( m_childInstrumentableProxyArray == null )
464             {
465                 updateChildInstrumentableProxyArray();
466             }
467
468             m_childInstrumentableDescriptorArray =
469                 new InstrumentableDescriptorLocal[ m_childInstrumentableProxyArray.length ];
470             for( int i = 0; i < m_childInstrumentableProxyArray.length; i++ )
471             {
472                 m_childInstrumentableDescriptorArray[ i ] =
473                     m_childInstrumentableProxyArray[ i ].getDescriptor();
474             }
475
476             return m_childInstrumentableDescriptorArray;
477         }
478     }
479
480     /*---------------------------------------------------------------
481      * Methods (Instruments)
482      *-------------------------------------------------------------*/

483     /**
484      * Adds a InstrumentProxy to the Instrumentable. This method will be
485      * called during the configuration phase of the Profiler if an element
486      * defining the Instrument exists, or if the Instrument registers
487      * itself with the ProfilerManager as it is running.
488      * <p>
489      * This method should never be called for Instruments which have already
490      * been added.
491      *
492      * @param instrumentProxy InstrumentProxy to be added.
493      */

494     void addInstrumentProxy( InstrumentProxy instrumentProxy )
495     {
496         synchronized( this )
497         {
498             m_instrumentProxies.put( instrumentProxy.getName(), instrumentProxy );
499
500             // Clear the optimized arrays
501
m_instrumentProxyArray = null;
502             m_instrumentDescriptorArray = null;
503         }
504         
505         stateChanged();
506     }
507
508     /**
509      * Returns a InstrumentProxy based on its name or the name of any
510      * of its children.
511      *
512      * @param instrumentName Name of the Instrument being requested.
513      *
514      * @return The requested InstrumentProxy or null if does not exist.
515      */

516     InstrumentProxy getInstrumentProxy( String JavaDoc instrumentName )
517     {
518         synchronized( this )
519         {
520             String JavaDoc name = instrumentName;
521             while( true )
522             {
523                 InstrumentProxy proxy = (InstrumentProxy)m_instrumentProxies.get( name );
524                 if( proxy != null )
525                 {
526                     return proxy;
527                 }
528
529                 // Assume this is a child name and try looking with the parent name.
530
int pos = name.lastIndexOf( '.' );
531                 if( pos > 0 )
532                 {
533                     name = name.substring( 0, pos );
534                 }
535                 else
536                 {
537                     return null;
538                 }
539             }
540         }
541     }
542
543     /**
544      * Returns an array of Proxies to the Instruments in the Instrumentable.
545      *
546      * @return An array of Proxies to the Instruments in the Instrumentable.
547      */

548     InstrumentProxy[] getInstrumentProxies()
549     {
550         InstrumentProxy[] proxies = m_instrumentProxyArray;
551         if( proxies == null )
552         {
553             proxies = updateInstrumentProxyArray();
554         }
555         return proxies;
556     }
557
558     /**
559      * Returns an array of Descriptors for the Instruments in the Instrumentable.
560      *
561      * @return An array of Descriptors for the Instruments in the Instrumentable.
562      */

563     InstrumentDescriptorLocal[] getInstrumentDescriptors()
564     {
565         InstrumentDescriptorLocal[] descriptors = m_instrumentDescriptorArray;
566         if( descriptors == null )
567         {
568             descriptors = updateInstrumentDescriptorArray();
569         }
570         return descriptors;
571     }
572     
573     /**
574      * Returns the stateVersion of the instrumentable. The state version
575      * will be incremented each time any of the configuration of the
576      * instrumentable or any of its children is modified.
577      * Clients can use this value to tell whether or not anything has
578      * changed without having to do an exhaustive comparison.
579      *
580      * @return The state version of the instrumentable.
581      */

582     int getStateVersion()
583     {
584         return m_stateVersion;
585     }
586
587     /**
588      * Updates the cached array of InstrumentProxies taking
589      * synchronization into account.
590      *
591      * @return An array of the InstrumentProxies.
592      */

593     private InstrumentProxy[] updateInstrumentProxyArray()
594     {
595         synchronized( this )
596         {
597             m_instrumentProxyArray = new InstrumentProxy[ m_instrumentProxies.size() ];
598             m_instrumentProxies.values().toArray( m_instrumentProxyArray );
599
600             // Sort the array. This is not a performance problem because this
601
// method is rarely called and doing it here saves cycles in the
602
// client.
603
Arrays.sort( m_instrumentProxyArray, new Comparator JavaDoc()
604                 {
605                     public int compare( Object JavaDoc o1, Object JavaDoc o2 )
606                     {
607                         return ((InstrumentProxy)o1).getDescription().
608                             compareTo( ((InstrumentProxy)o2).getDescription() );
609                     }
610                     
611                     public boolean equals( Object JavaDoc obj )
612                     {
613                         return false;
614                     }
615                 } );
616             
617             return m_instrumentProxyArray;
618         }
619     }
620
621     /**
622      * Updates the cached array of InstrumentDescriptorLocals taking
623      * synchronization into account.
624      *
625      * @return An array of the InstrumentDescriptorLocals.
626      */

627     private InstrumentDescriptorLocal[] updateInstrumentDescriptorArray()
628     {
629         synchronized( this )
630         {
631             if( m_instrumentProxyArray == null )
632             {
633                 updateInstrumentProxyArray();
634             }
635
636             m_instrumentDescriptorArray =
637                 new InstrumentDescriptorLocal[ m_instrumentProxyArray.length ];
638             for( int i = 0; i < m_instrumentProxyArray.length; i++ )
639             {
640                 m_instrumentDescriptorArray[ i ] = m_instrumentProxyArray[ i ].getDescriptor();
641             }
642
643             return m_instrumentDescriptorArray;
644         }
645     }
646
647     /**
648      * Saves the current state into a Configuration.
649      *
650      * @return The state as a Configuration. Returns null if the configuration
651      * would not contain any information.
652      */

653     Configuration saveState()
654     {
655         boolean empty = true;
656         DefaultConfiguration state = new DefaultConfiguration( "instrumentable", "-" );
657         state.setAttribute( "name", m_name );
658
659         // Save the child Instrumentables
660
InstrumentableProxy[] childProxies = getChildInstrumentableProxies();
661         for( int i = 0; i < childProxies.length; i++ )
662         {
663             Configuration childState = childProxies[ i ].saveState();
664             if ( childState != null )
665             {
666                 empty = false;
667                 state.addChild( childState );
668             }
669         }
670
671         // Save the direct Instruments
672
InstrumentProxy[] proxies = getInstrumentProxies();
673         for( int i = 0; i < proxies.length; i++ )
674         {
675             Configuration childState = proxies[ i ].saveState();
676             if ( childState != null )
677             {
678                 empty = false;
679                 state.addChild( childState );
680             }
681         }
682
683         // Only return a state if it contains information.
684
if ( empty )
685         {
686             state = null;
687         }
688         return state;
689     }
690
691     /**
692      * Loads the state into the Instrumentable.
693      *
694      * @param state Configuration object to load state from.
695      *
696      * @throws ConfigurationException If there were any problems loading the
697      * state.
698      */

699     void loadState( Configuration state ) throws ConfigurationException
700     {
701         synchronized( this )
702         {
703             // Load the child Instrumentables
704
Configuration[] childConfs = state.getChildren( "instrumentable" );
705             for( int i = 0; i < childConfs.length; i++ )
706             {
707                 Configuration childConf = childConfs[ i ];
708                 String JavaDoc fullChildName = childConf.getAttribute( "name" );
709                 InstrumentableProxy childProxy = getChildInstrumentableProxy( fullChildName );
710                 if( childProxy == null )
711                 {
712                     // The child Instrumentable was in the state file, but has
713
// not yet been registered. It is possible that it will
714
// be registered at a later time. For now it needs to be
715
// created.
716
String JavaDoc childName = ( fullChildName.startsWith( m_name + "." ) ?
717                         fullChildName.substring( m_name.length() + 1 ) : "BADNAME." + fullChildName );
718                     
719                     childProxy = new InstrumentableProxy(
720                         m_instrumentManager, this, fullChildName, childName );
721                     childProxy.enableLogging( getLogger() );
722                     m_childInstrumentableProxies.put( fullChildName, childProxy );
723     
724                     // Clear the optimized arrays
725
m_childInstrumentableProxyArray = null;
726                     m_childInstrumentableDescriptorArray = null;
727                 }
728                 childProxy.loadState( childConf );
729             }
730             
731             // Load the direct Instruments
732
Configuration[] instrumentConfs = state.getChildren( "instrument" );
733             for( int i = 0; i < instrumentConfs.length; i++ )
734             {
735                 Configuration instrumentConf = instrumentConfs[ i ];
736                 String JavaDoc fullInstrumentName = instrumentConf.getAttribute( "name" );
737                 InstrumentProxy instrumentProxy = getInstrumentProxy( fullInstrumentName );
738                 if( instrumentProxy == null )
739                 {
740                     // The Instrument was in the state file, but has not yet been
741
// registered. It is possible that it will be registered
742
// at a later time. For now it needs to be created.
743
String JavaDoc instrumentName = ( fullInstrumentName.startsWith( m_name + "." ) ?
744                         fullInstrumentName.substring( m_name.length() + 1 ) : "BADNAME." + fullInstrumentName );
745                     
746                     instrumentProxy =
747                         new InstrumentProxy( this, fullInstrumentName, instrumentName );
748                     instrumentProxy.enableLogging( getLogger() );
749                     m_instrumentProxies.put( fullInstrumentName, instrumentProxy );
750     
751                     // Clear the optimized arrays
752
m_instrumentProxyArray = null;
753                     m_instrumentDescriptorArray = null;
754                 }
755                 instrumentProxy.loadState( instrumentConf );
756             }
757         }
758         
759         stateChanged();
760     }
761     
762     /**
763      * Called whenever the state of the instrumentable is changed.
764      */

765     protected void stateChanged()
766     {
767         m_stateVersion++;
768         
769         // Propagate to the parent
770
if ( m_parentInstrumentableProxy == null )
771         {
772             // This is a top level Instrumentable
773
m_instrumentManager.stateChanged();
774         }
775         else
776         {
777             m_parentInstrumentableProxy.stateChanged();
778         }
779     }
780 }
781
Popular Tags