1 8 9 package mx4j.server; 10 11 import java.io.ObjectInputStream ; 12 import java.util.Set ; 13 import javax.management.Attribute ; 14 import javax.management.AttributeList ; 15 import javax.management.AttributeNotFoundException ; 16 import javax.management.InstanceAlreadyExistsException ; 17 import javax.management.InstanceNotFoundException ; 18 import javax.management.IntrospectionException ; 19 import javax.management.InvalidAttributeValueException ; 20 import javax.management.ListenerNotFoundException ; 21 import javax.management.MBeanException ; 22 import javax.management.MBeanInfo ; 23 import javax.management.MBeanRegistrationException ; 24 import javax.management.MBeanServer ; 25 import javax.management.NotCompliantMBeanException ; 26 import javax.management.NotificationFilter ; 27 import javax.management.NotificationListener ; 28 import javax.management.ObjectInstance ; 29 import javax.management.ObjectName ; 30 import javax.management.OperationsException ; 31 import javax.management.QueryExp ; 32 import javax.management.ReflectionException ; 33 import javax.management.loading.ClassLoaderRepository ; 34 35 42 public class ChainedMBeanServer implements MBeanServer 43 { 44 private MBeanServer m_server; 45 46 50 public ChainedMBeanServer() 51 { 52 this(null); 53 } 54 55 58 public ChainedMBeanServer(MBeanServer server) 59 { 60 setMBeanServer(server); 61 } 62 63 66 protected synchronized MBeanServer getMBeanServer() 67 { 68 return m_server; 69 } 70 71 protected synchronized void setMBeanServer(MBeanServer server) 72 { 73 m_server = server; 74 } 75 76 public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback) 77 throws InstanceNotFoundException 78 { 79 getMBeanServer().addNotificationListener(observed, listener, filter, handback); 80 } 81 82 public void addNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, Object handback) 83 throws InstanceNotFoundException 84 { 85 getMBeanServer().addNotificationListener(observed, listener, filter, handback); 86 } 87 88 public ObjectInstance createMBean(String className, ObjectName objectName) 89 throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException 90 { 91 return getMBeanServer().createMBean(className, objectName); 92 } 93 94 public ObjectInstance createMBean(String className, ObjectName objectName, Object [] args, String [] parameters) 95 throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException 96 { 97 return getMBeanServer().createMBean(className, objectName, args, parameters); 98 } 99 100 public ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName) 101 throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException , InstanceNotFoundException 102 { 103 return getMBeanServer().createMBean(className, objectName, loaderName); 104 } 105 106 public ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName, Object [] args, String [] parameters) 107 throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException , InstanceNotFoundException 108 { 109 return getMBeanServer().createMBean(className, objectName, loaderName, args, parameters); 110 } 111 112 public ObjectInputStream deserialize(String className, byte[] bytes) 113 throws OperationsException , ReflectionException 114 { 115 return getMBeanServer().deserialize(className, bytes); 116 } 117 118 public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] bytes) 119 throws InstanceNotFoundException , OperationsException , ReflectionException 120 { 121 return getMBeanServer().deserialize(className, loaderName, bytes); 122 } 123 124 public ObjectInputStream deserialize(ObjectName objectName, byte[] bytes) 125 throws InstanceNotFoundException , OperationsException 126 { 127 return getMBeanServer().deserialize(objectName, bytes); 128 } 129 130 public Object getAttribute(ObjectName objectName, String attribute) 131 throws MBeanException , AttributeNotFoundException , InstanceNotFoundException , ReflectionException 132 { 133 return getMBeanServer().getAttribute(objectName, attribute); 134 } 135 136 public AttributeList getAttributes(ObjectName objectName, String [] attributes) 137 throws InstanceNotFoundException , ReflectionException 138 { 139 return getMBeanServer().getAttributes(objectName, attributes); 140 } 141 142 public String getDefaultDomain() 143 { 144 return getMBeanServer().getDefaultDomain(); 145 } 146 147 public String [] getDomains() 148 { 149 return getMBeanServer().getDomains(); 150 } 151 152 public Integer getMBeanCount() 153 { 154 return getMBeanServer().getMBeanCount(); 155 } 156 157 public MBeanInfo getMBeanInfo(ObjectName objectName) 158 throws InstanceNotFoundException , IntrospectionException , ReflectionException 159 { 160 return getMBeanServer().getMBeanInfo(objectName); 161 } 162 163 public ObjectInstance getObjectInstance(ObjectName objectName) 164 throws InstanceNotFoundException 165 { 166 return getMBeanServer().getObjectInstance(objectName); 167 } 168 169 public Object instantiate(String className) 170 throws ReflectionException , MBeanException 171 { 172 return getMBeanServer().instantiate(className); 173 } 174 175 public Object instantiate(String className, Object [] args, String [] parameters) 176 throws ReflectionException , MBeanException 177 { 178 return getMBeanServer().instantiate(className, args, parameters); 179 } 180 181 public Object instantiate(String className, ObjectName loaderName) 182 throws ReflectionException , MBeanException , InstanceNotFoundException 183 { 184 return getMBeanServer().instantiate(className, loaderName); 185 } 186 187 public Object instantiate(String className, ObjectName loaderName, Object [] args, String [] parameters) 188 throws ReflectionException , MBeanException , InstanceNotFoundException 189 { 190 return getMBeanServer().instantiate(className, loaderName, args, parameters); 191 } 192 193 public Object invoke(ObjectName objectName, String methodName, Object [] args, String [] parameters) 194 throws InstanceNotFoundException , MBeanException , ReflectionException 195 { 196 return getMBeanServer().invoke(objectName, methodName, args, parameters); 197 } 198 199 public boolean isInstanceOf(ObjectName objectName, String className) 200 throws InstanceNotFoundException 201 { 202 return getMBeanServer().isInstanceOf(objectName, className); 203 } 204 205 public boolean isRegistered(ObjectName objectname) 206 { 207 return getMBeanServer().isRegistered(objectname); 208 } 209 210 public Set queryMBeans(ObjectName patternName, QueryExp filter) 211 { 212 return getMBeanServer().queryMBeans(patternName, filter); 213 } 214 215 public Set queryNames(ObjectName patternName, QueryExp filter) 216 { 217 return getMBeanServer().queryNames(patternName, filter); 218 } 219 220 public ObjectInstance registerMBean(Object mbean, ObjectName objectName) 221 throws InstanceAlreadyExistsException , MBeanRegistrationException , NotCompliantMBeanException 222 { 223 return getMBeanServer().registerMBean(mbean, objectName); 224 } 225 226 public void removeNotificationListener(ObjectName observed, NotificationListener listener) 227 throws InstanceNotFoundException , ListenerNotFoundException 228 { 229 getMBeanServer().removeNotificationListener(observed, listener); 230 } 231 232 public void removeNotificationListener(ObjectName observed, ObjectName listener) 233 throws InstanceNotFoundException , ListenerNotFoundException 234 { 235 getMBeanServer().removeNotificationListener(observed, listener); 236 } 237 238 public void removeNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, Object handback) 239 throws InstanceNotFoundException , ListenerNotFoundException 240 { 241 getMBeanServer().removeNotificationListener(observed, listener, filter, handback); 242 } 243 244 public void removeNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback) 245 throws InstanceNotFoundException , ListenerNotFoundException 246 { 247 getMBeanServer().removeNotificationListener(observed, listener, filter, handback); 248 } 249 250 public void setAttribute(ObjectName objectName, Attribute attribute) 251 throws InstanceNotFoundException , AttributeNotFoundException , InvalidAttributeValueException , MBeanException , ReflectionException 252 { 253 getMBeanServer().setAttribute(objectName, attribute); 254 } 255 256 public AttributeList setAttributes(ObjectName objectName, AttributeList attributes) 257 throws InstanceNotFoundException , ReflectionException 258 { 259 return getMBeanServer().setAttributes(objectName, attributes); 260 } 261 262 public void unregisterMBean(ObjectName objectName) 263 throws InstanceNotFoundException , MBeanRegistrationException 264 { 265 getMBeanServer().unregisterMBean(objectName); 266 } 267 268 public ClassLoader getClassLoaderFor(ObjectName mbeanName) 269 throws InstanceNotFoundException 270 { 271 return getMBeanServer().getClassLoaderFor(mbeanName); 272 } 273 274 public ClassLoader getClassLoader(ObjectName loaderName) 275 throws InstanceNotFoundException 276 { 277 return getMBeanServer().getClassLoader(loaderName); 278 } 279 280 public ClassLoaderRepository getClassLoaderRepository() 281 { 282 return getMBeanServer().getClassLoaderRepository(); 283 } 284 } 285 | Popular Tags |