1 7 8 package com.sun.corba.se.impl.monitoring; 9 10 import java.util.Map ; 11 import java.util.HashMap ; 12 import java.util.Collection ; 13 import java.util.Iterator ; 14 15 import com.sun.corba.se.spi.monitoring.MonitoredObject; 16 import com.sun.corba.se.spi.monitoring.MonitoredAttribute; 17 18 public class MonitoredObjectImpl implements MonitoredObject { 19 private final String name; 20 private final String description; 21 22 private Map children = new HashMap (); 24 25 private Map monitoredAttributes = new HashMap (); 27 28 private MonitoredObject parent = null; 29 30 31 MonitoredObjectImpl( String name, String description ) { 33 this.name = name; 34 this.description = description; 35 } 36 37 public MonitoredObject getChild( String name ) { 38 synchronized( this ) { 39 return (MonitoredObject) children.get( name ); 40 } 41 } 42 43 public Collection getChildren( ) { 44 synchronized( this ) { 45 return children.values(); 46 } 47 } 48 49 public void addChild( MonitoredObject m ) { 50 if (m != null){ 51 synchronized( this ) { 52 children.put( m.getName(), m); 53 m.setParent( this ); 54 } 55 } 56 } 57 58 public void removeChild( String name ) { 59 if (name != null){ 60 synchronized( this ) { 61 children.remove( name ); 62 } 63 } 64 } 65 66 public synchronized MonitoredObject getParent( ) { 67 return parent; 68 } 69 70 public synchronized void setParent( MonitoredObject p ) { 71 parent = p; 72 } 73 74 public MonitoredAttribute getAttribute( String name ) { 75 synchronized( this ) { 76 return (MonitoredAttribute) monitoredAttributes.get( name ); 77 } 78 } 79 80 public Collection getAttributes( ) { 81 synchronized( this ) { 82 return monitoredAttributes.values(); 83 } 84 } 85 86 public void addAttribute( MonitoredAttribute value ) { 87 if (value != null) { 88 synchronized( this ) { 89 monitoredAttributes.put( value.getName(), value ); 90 } 91 } 92 } 93 94 public void removeAttribute( String name ) { 95 if (name != null) { 96 synchronized( this ) { 97 monitoredAttributes.remove( name ); 98 } 99 } 100 } 101 102 106 public void clearState( ) { 107 synchronized( this ) { 108 Iterator i = monitoredAttributes.values().iterator(); 109 while( i.hasNext( ) ) { 111 ((MonitoredAttribute)i.next()).clearState(); 112 } 113 i = children.values().iterator(); 114 while( i.hasNext() ) { 116 ((MonitoredObject)i.next()).clearState(); 117 } 118 } 119 } 120 121 public String getName( ) { 122 return name; 123 } 124 125 public String getDescription( ) { 126 return description; 127 } 128 } 129 130 131 132 133 134 | Popular Tags |