KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > spi > monitoring > MonitoredAttributeBase


1 /*
2  * @(#)MonitoredAttributeBase.java 1.3 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package com.sun.corba.se.spi.monitoring;
8
9 import java.util.*;
10
11 /**
12  * <p>
13  *
14  * @author Hemanth Puttaswamy
15  * </p>
16  * <p>
17  * A Convenient class provided to help users extend and implement only
18  * getValue(), if there is no need to clear the state and the attribute is not
19  * writable.
20  *
21  * </p>
22  */

23 public abstract class MonitoredAttributeBase implements MonitoredAttribute {
24     String JavaDoc name;
25     MonitoredAttributeInfo attributeInfo;
26     /**
27      * Constructor.
28      */

29     public MonitoredAttributeBase( String JavaDoc name, MonitoredAttributeInfo info ) {
30         this.name = name;
31         this.attributeInfo = info;
32     }
33
34     
35     /**
36      * A Package Private Constructor for internal use only.
37      */

38     MonitoredAttributeBase( String JavaDoc name ) {
39         this.name = name;
40     }
41
42
43     /**
44      * A Package Private convenience method for setting MonitoredAttributeInfo
45      * for this Monitored Attribute.
46      */

47     void setMonitoredAttributeInfo( MonitoredAttributeInfo info ) {
48         this.attributeInfo = info;
49     }
50
51     /**
52      * If the concrete class decides not to provide the implementation of this
53      * method, then it's OK. Some of the examples where we may decide to not
54      * provide the implementation is the connection state. Irrespective of
55      * the call to clearState, the connection state will be showing the
56      * currect state of the connection.
57      * NOTE: This method is only used to clear the Monitored Attribute state,
58      * not the real state of the system itself.
59      */

60     public void clearState( ) {
61     }
62
63     /**
64      * This method should be implemented by the concrete class.
65      */

66     public abstract Object JavaDoc getValue( );
67
68     /**
69      * This method should be implemented by the concrete class only if the
70      * attribute is writable. If the attribute is not writable and if this
71      * method called, it will result in an IllegalStateException.
72      */

73     public void setValue( Object JavaDoc value ) {
74         if( !attributeInfo.isWritable() ) {
75             throw new IllegalStateException JavaDoc(
76                 "The Attribute " + name + " is not Writable..." );
77         }
78         throw new IllegalStateException JavaDoc(
79             "The method implementation is not provided for the attribute " +
80             name );
81     }
82
83     
84     /**
85      * Gets the MonitoredAttributeInfo for the attribute.
86      */

87     public MonitoredAttributeInfo getAttributeInfo( ) {
88         return attributeInfo;
89     }
90
91     /**
92      * Gets the name of the attribute.
93      */

94     public String JavaDoc getName( ) {
95         return name;
96     }
97 } // end MonitoredAttributeBase
98

99
100
101
Popular Tags