1 29 30 package com.caucho.jmx.remote; 31 32 import com.caucho.hessian.client.HessianProxyFactory; 33 import com.caucho.hessian.jmx.JMXSerializerFactory; 34 import com.caucho.util.L10N; 35 import com.caucho.util.Log; 36 import com.caucho.vfs.IOExceptionWrapper; 37 38 import javax.management.*; 39 import java.io.IOException ; 40 import java.util.Set ; 41 import java.util.logging.Logger ; 42 43 46 public class HessianMBeanServerConnection 47 implements MBeanServerConnection 48 { 49 private static final L10N L = new L10N(HessianMBeanServerConnection.class); 50 private static final Logger log = Log.open(HessianMBeanServerConnection.class); 51 52 private String _url; 53 private RemoteJMX _jmxProxy; 54 55 58 public HessianMBeanServerConnection() 59 { 60 } 61 62 65 public HessianMBeanServerConnection(String url) 66 { 67 _url = url; 68 } 69 70 73 public void setProxy(RemoteJMX proxy) 74 { 75 _jmxProxy = proxy; 76 } 77 78 81 public MBeanInfo getMBeanInfo(ObjectName objectName) 82 throws InstanceNotFoundException, IntrospectionException, 83 ReflectionException, IOException 84 { 85 try { 86 return getProxy().getMBeanInfo(objectName.getCanonicalName()); 87 } 88 catch (JMException ex) { 89 if (ex instanceof InstanceNotFoundException) 90 throw (InstanceNotFoundException) ex; 91 92 if (ex instanceof IntrospectionException) 93 throw (IntrospectionException) ex; 94 95 if (ex instanceof ReflectionException) 96 throw (ReflectionException) ex; 97 98 throw new RuntimeException (ex); 99 } 100 } 101 102 public boolean isInstanceOf(ObjectName name, String className) 103 throws InstanceNotFoundException, IOException 104 { 105 106 if (true) throw new UnsupportedOperationException ("unimplemented"); 108 109 return false; 110 } 111 112 115 public Object getAttribute(ObjectName objectName, String attrName) 116 throws MBeanException, AttributeNotFoundException, 117 InstanceNotFoundException, ReflectionException, 118 IOException 119 { 120 try { 121 return getProxy().getAttribute(objectName.getCanonicalName(), attrName); 122 } 123 catch (JMException ex) { 124 if (ex instanceof MBeanException) 125 throw (MBeanException) ex; 126 127 if (ex instanceof AttributeNotFoundException) 128 throw (AttributeNotFoundException) ex; 129 130 if (ex instanceof InstanceNotFoundException) 131 throw (InstanceNotFoundException) ex; 132 133 if (ex instanceof ReflectionException) 134 throw (ReflectionException) ex; 135 136 throw new RuntimeException (ex); 137 } 138 } 139 140 public AttributeList getAttributes(ObjectName name, String [] attributes) 141 throws InstanceNotFoundException, ReflectionException, IOException 142 { 143 144 if (true) throw new UnsupportedOperationException ("unimplemented"); 146 147 return null; 148 } 149 150 public void setAttribute(ObjectName name, Attribute attribute) 151 throws 152 InstanceNotFoundException, 153 AttributeNotFoundException, 154 InvalidAttributeValueException, 155 MBeanException, 156 ReflectionException, 157 IOException 158 { 159 160 if (true) throw new UnsupportedOperationException ("unimplemented"); 162 163 164 } 165 166 public AttributeList setAttributes(ObjectName name, AttributeList attributes) 167 throws InstanceNotFoundException, ReflectionException, IOException 168 { 169 170 if (true) throw new UnsupportedOperationException ("unimplemented"); 172 173 return null; 174 } 175 176 public Object invoke(ObjectName name, 177 String operationName, 178 Object params[], 179 String signature[]) 180 throws 181 InstanceNotFoundException, 182 MBeanException, 183 ReflectionException, 184 IOException 185 { 186 187 if (true) throw new UnsupportedOperationException ("unimplemented"); 189 190 return null; 191 } 192 193 public String getDefaultDomain() 194 throws IOException 195 { 196 197 if (true) throw new UnsupportedOperationException ("unimplemented"); 199 200 return null; 201 } 202 203 public String [] getDomains() 204 throws IOException 205 { 206 207 if (true) throw new UnsupportedOperationException ("unimplemented"); 209 210 return new String [0]; 211 } 212 213 public void addNotificationListener(ObjectName name, 214 NotificationListener listener, 215 NotificationFilter filter, 216 Object handback) 217 throws InstanceNotFoundException, IOException 218 { 219 220 if (true) throw new UnsupportedOperationException ("unimplemented"); 222 223 224 } 225 226 public void addNotificationListener(ObjectName name, 227 ObjectName listener, 228 NotificationFilter filter, 229 Object handback) 230 throws InstanceNotFoundException, IOException 231 { 232 233 if (true) throw new UnsupportedOperationException ("unimplemented"); 235 236 237 } 238 239 public void removeNotificationListener(ObjectName name, ObjectName listener) 240 throws InstanceNotFoundException, ListenerNotFoundException, IOException 241 { 242 243 if (true) throw new UnsupportedOperationException ("unimplemented"); 245 246 247 } 248 249 public void removeNotificationListener(ObjectName name, 250 ObjectName listener, 251 NotificationFilter filter, 252 Object handback) 253 throws InstanceNotFoundException, ListenerNotFoundException, IOException 254 { 255 256 if (true) throw new UnsupportedOperationException ("unimplemented"); 258 259 260 } 261 262 public void removeNotificationListener(ObjectName name, 263 NotificationListener listener) 264 throws InstanceNotFoundException, ListenerNotFoundException, IOException 265 { 266 267 if (true) throw new UnsupportedOperationException ("unimplemented"); 269 270 271 } 272 273 public void removeNotificationListener(ObjectName name, 274 NotificationListener listener, 275 NotificationFilter filter, 276 Object handback) 277 throws InstanceNotFoundException, ListenerNotFoundException, IOException 278 { 279 280 if (true) throw new UnsupportedOperationException ("unimplemented"); 282 283 284 } 285 286 public ObjectInstance createMBean(String className, ObjectName name) 287 throws 288 ReflectionException, 289 InstanceAlreadyExistsException, 290 MBeanRegistrationException, 291 MBeanException, 292 NotCompliantMBeanException, 293 IOException 294 { 295 if (true) throw new UnsupportedOperationException ("unimplemented"); 297 298 return null; 299 } 300 301 public ObjectInstance createMBean(String className, 302 ObjectName name, 303 ObjectName loaderName) 304 throws 305 ReflectionException, 306 InstanceAlreadyExistsException, 307 MBeanRegistrationException, 308 MBeanException, 309 NotCompliantMBeanException, 310 InstanceNotFoundException, 311 IOException 312 { 313 314 if (true) throw new UnsupportedOperationException ("unimplemented"); 316 317 return null; 318 } 319 320 public ObjectInstance createMBean(String className, 321 ObjectName name, 322 Object params[], 323 String signature[]) 324 throws 325 ReflectionException, 326 InstanceAlreadyExistsException, 327 MBeanRegistrationException, 328 MBeanException, 329 NotCompliantMBeanException, 330 IOException 331 { 332 333 if (true) throw new UnsupportedOperationException ("unimplemented"); 335 336 return null; 337 } 338 339 public ObjectInstance createMBean(String className, 340 ObjectName name, 341 ObjectName loaderName, 342 Object params[], 343 String signature[]) 344 throws 345 ReflectionException, 346 InstanceAlreadyExistsException, 347 MBeanRegistrationException, 348 MBeanException, 349 NotCompliantMBeanException, 350 InstanceNotFoundException, 351 IOException 352 { 353 354 if (true) throw new UnsupportedOperationException ("unimplemented"); 356 357 return null; 358 } 359 360 public void unregisterMBean(ObjectName name) 361 throws InstanceNotFoundException, MBeanRegistrationException, IOException 362 { 363 364 if (true) throw new UnsupportedOperationException ("unimplemented"); 366 367 368 } 369 370 373 public ObjectInstance getObjectInstance(ObjectName objectName) 374 throws InstanceNotFoundException, IOException 375 { 376 MBeanInfo info = null; 377 378 try { 379 info = getMBeanInfo(objectName); 380 } 381 catch (IntrospectionException e) { 382 throw new IOExceptionWrapper(e); 383 } 384 catch (ReflectionException e) { 385 throw new IOExceptionWrapper(e); 386 } 387 388 String className = info.getClassName(); 389 390 return new ObjectInstance(objectName, className); 391 } 392 393 public Set queryMBeans(ObjectName name, QueryExp query) 394 throws IOException 395 { 396 397 if (true) throw new UnsupportedOperationException ("unimplemented"); 399 400 return null; 401 } 402 403 public Set queryNames(ObjectName name, QueryExp query) 404 throws IOException 405 { 406 407 if (true) throw new UnsupportedOperationException ("unimplemented"); 409 410 return null; 411 } 412 413 public boolean isRegistered(ObjectName name) 414 throws IOException 415 { 416 return true; 417 } 418 419 public Integer getMBeanCount() 420 throws IOException 421 { 422 423 if (true) throw new UnsupportedOperationException ("unimplemented"); 425 426 return null; 427 } 428 429 private RemoteJMX getProxy() 430 { 431 if (_jmxProxy == null) { 432 try { 433 HessianProxyFactory proxy = new HessianProxyFactory(); 434 proxy.getSerializerFactory().addFactory(new JMXSerializerFactory()); 435 _jmxProxy = (RemoteJMX) proxy.create(_url); 436 } catch (Exception e) { 437 throw new RuntimeException (e); 438 } 439 } 440 441 return _jmxProxy; 442 } 443 } 444 445 | Popular Tags |