| 1 17 package org.apache.geronimo.system.jmx; 18 19 import java.util.Date ; 20 import java.util.Set ; 21 import javax.management.AttributeNotFoundException ; 22 import javax.management.InstanceNotFoundException ; 23 import javax.management.JMException ; 24 import javax.management.JMRuntimeException ; 25 import javax.management.MBeanServerConnection ; 26 import javax.management.ObjectName ; 27 28 import org.apache.geronimo.gbean.GBeanData; 29 import org.apache.geronimo.gbean.GBeanInfo; 30 import org.apache.geronimo.gbean.AbstractName; 31 import org.apache.geronimo.gbean.AbstractNameQuery; 32 import org.apache.geronimo.kernel.DependencyManager; 33 import org.apache.geronimo.kernel.GBeanAlreadyExistsException; 34 import org.apache.geronimo.kernel.GBeanNotFoundException; 35 import org.apache.geronimo.kernel.InternalKernelException; 36 import org.apache.geronimo.kernel.Kernel; 37 import org.apache.geronimo.kernel.NoSuchAttributeException; 38 import org.apache.geronimo.kernel.NoSuchOperationException; 39 import org.apache.geronimo.kernel.Naming; 40 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor; 41 import org.apache.geronimo.kernel.proxy.ProxyManager; 42 43 46 public class KernelDelegate implements Kernel { 47 private final MBeanServerConnection mbeanServer; 48 private final ProxyManager proxyManager; 49 50 public KernelDelegate(MBeanServerConnection mbeanServer) { 51 this.mbeanServer = mbeanServer; 52 proxyManager = new JMXProxyManager(this); 53 } 54 55 public Date getBootTime() { 56 return (Date ) getKernelAttribute("bootTime"); 57 } 58 59 public String getKernelName() { 60 return (String ) getKernelAttribute("kernelName"); 61 } 62 63 public Naming getNaming() { 64 return (Naming) getKernelAttribute("naming"); 65 } 66 67 public Object getGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 68 try { 69 return invokeKernel("getGBean", new Object [] {name}, new String [] {ObjectName .class.getName()}); 70 } catch (GBeanNotFoundException e) { 71 throw e; 72 } catch (RuntimeException e) { 73 throw e; 74 } catch (Exception e) { 75 throw new InternalKernelException(e); 76 } 77 } 78 79 public Object getGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 80 try { 81 return invokeKernel("getGBean", new Object [] {name}, new String [] {AbstractName.class.getName()}); 82 } catch (GBeanNotFoundException e) { 83 throw e; 84 } catch (RuntimeException e) { 85 throw e; 86 } catch (Exception e) { 87 throw new InternalKernelException(e); 88 } 89 } 90 91 public Object getGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 92 try { 93 return invokeKernel("getGBean", new Object [] {shortName}, new String [] {String .class.getName()}); 94 } catch (GBeanNotFoundException e) { 95 throw e; 96 } catch (RuntimeException e) { 97 throw e; 98 } catch (Exception e) { 99 throw new InternalKernelException(e); 100 } 101 } 102 103 public Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 104 try { 105 return invokeKernel("getGBean", new Object [] {type}, new String [] {Class .class.getName()}); 106 } catch (GBeanNotFoundException e) { 107 throw e; 108 } catch (RuntimeException e) { 109 throw e; 110 } catch (Exception e) { 111 throw new InternalKernelException(e); 112 } 113 } 114 115 public Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 116 try { 117 return invokeKernel("getGBean", new Object [] {shortName, type}, new String [] {String .class.getName(), Class .class.getName()}); 118 } catch (GBeanNotFoundException e) { 119 throw e; 120 } catch (RuntimeException e) { 121 throw e; 122 } catch (Exception e) { 123 throw new InternalKernelException(e); 124 } 125 } 126 127 public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException { 128 try { 129 invokeKernel("loadGBean", new Object [] {gbeanData, classLoader}, new String [] {GBeanData.class.getName(), ClassLoader .class.getName()}); 130 } catch (GBeanAlreadyExistsException e) { 131 throw e; 132 } catch (RuntimeException e) { 133 throw e; 134 } catch (Exception e) { 135 throw new InternalKernelException(e); 136 } 137 } 138 139 public void startGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 140 try { 141 invokeKernel("startGBean", new Object [] {name}, new String [] {AbstractName.class.getName()}); 142 } catch (GBeanNotFoundException e) { 143 throw e; 144 } catch (RuntimeException e) { 145 throw e; 146 } catch (Exception e) { 147 throw new InternalKernelException(e); 148 } 149 } 150 151 public void startGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 152 try { 153 invokeKernel("startGBean", new Object [] {shortName}, new String [] {String .class.getName()}); 154 } catch (GBeanNotFoundException e) { 155 throw e; 156 } catch (RuntimeException e) { 157 throw e; 158 } catch (Exception e) { 159 throw new InternalKernelException(e); 160 } 161 } 162 163 public void startGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 164 try { 165 invokeKernel("startGBean", new Object [] {type}, new String [] {Class .class.getName()}); 166 } catch (GBeanNotFoundException e) { 167 throw e; 168 } catch (RuntimeException e) { 169 throw e; 170 } catch (Exception e) { 171 throw new InternalKernelException(e); 172 } 173 } 174 175 public void startGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 176 try { 177 invokeKernel("startGBean", new Object [] {shortName, type}, new String [] {String .class.getName(), Class .class.getName()}); 178 } catch (GBeanNotFoundException e) { 179 throw e; 180 } catch (RuntimeException e) { 181 throw e; 182 } catch (Exception e) { 183 throw new InternalKernelException(e); 184 } 185 } 186 187 public void startRecursiveGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 188 try { 189 invokeKernel("startRecursiveGBean", new Object [] {name}, new String [] {AbstractName.class.getName()}); 190 } catch (GBeanNotFoundException e) { 191 throw e; 192 } catch (RuntimeException e) { 193 throw e; 194 } catch (Exception e) { 195 throw new InternalKernelException(e); 196 } 197 } 198 199 public void startRecursiveGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 200 try { 201 invokeKernel("startRecursiveGBean", new Object [] {shortName}, new String [] {String .class.getName()}); 202 } catch (GBeanNotFoundException e) { 203 throw e; 204 } catch (RuntimeException e) { 205 throw e; 206 } catch (Exception e) { 207 throw new InternalKernelException(e); 208 } 209 } 210 211 public void startRecursiveGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 212 try { 213 invokeKernel("startRecursiveGBean", new Object [] {type}, new String [] {Class .class.getName()}); 214 } catch (GBeanNotFoundException e) { 215 throw e; 216 } catch (RuntimeException e) { 217 throw e; 218 } catch (Exception e) { 219 throw new InternalKernelException(e); 220 } 221 } 222 223 public void startRecursiveGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 224 try { 225 invokeKernel("startRecursiveGBean", new Object [] {shortName, type}, new String [] {String .class.getName(), Class .class.getName()}); 226 } catch (GBeanNotFoundException e) { 227 throw e; 228 } catch (RuntimeException e) { 229 throw e; 230 } catch (Exception e) { 231 throw new InternalKernelException(e); 232 } 233 } 234 235 public boolean isRunning(AbstractName name) { 236 try { 237 return ((Boolean ) invokeKernel("isRunning", new Object []{name}, new String []{AbstractName.class.getName()})).booleanValue(); 238 } catch (RuntimeException e) { 239 throw e; 240 } catch (Exception e) { 241 throw new InternalKernelException(e); 242 } 243 } 244 245 public boolean isRunning(String shortName) { 246 try { 247 return ((Boolean ) invokeKernel("isRunning", new Object []{shortName}, new String []{String .class.getName()})).booleanValue(); 248 } catch (RuntimeException e) { 249 throw e; 250 } catch (Exception e) { 251 throw new InternalKernelException(e); 252 } 253 } 254 255 public boolean isRunning(Class type) { 256 try { 257 return ((Boolean ) invokeKernel("isRunning", new Object []{type}, new String []{Class .class.getName()})).booleanValue(); 258 } catch (RuntimeException e) { 259 throw e; 260 } catch (Exception e) { 261 throw new InternalKernelException(e); 262 } 263 } 264 265 public boolean isRunning(String shortName, Class type) { 266 try { 267 return ((Boolean ) invokeKernel("isRunning", new Object []{shortName, type}, new String []{String .class.getName(), Class .class.getName()})).booleanValue(); 268 } catch (RuntimeException e) { 269 throw e; 270 } catch (Exception e) { 271 throw new InternalKernelException(e); 272 } 273 } 274 275 276 public void stopGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 277 try { 278 invokeKernel("stopGBean", new Object [] {name}, new String [] {AbstractName.class.getName()}); 279 } catch (GBeanNotFoundException e) { 280 throw e; 281 } catch (RuntimeException e) { 282 throw e; 283 } catch (Exception e) { 284 throw new InternalKernelException(e); 285 } 286 } 287 288 public void stopGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 289 try { 290 invokeKernel("stopGBean", new Object [] {shortName}, new String [] {String .class.getName()}); 291 } catch (GBeanNotFoundException e) { 292 throw e; 293 } catch (RuntimeException e) { 294 throw e; 295 } catch (Exception e) { 296 throw new InternalKernelException(e); 297 } 298 } 299 300 public void stopGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 301 try { 302 invokeKernel("stopGBean", new Object [] {type}, new String [] {Class .class.getName()}); 303 } catch (GBeanNotFoundException e) { 304 throw e; 305 } catch (RuntimeException e) { 306 throw e; 307 } catch (Exception e) { 308 throw new InternalKernelException(e); 309 } 310 } 311 312 public void stopGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 313 try { 314 invokeKernel("stopGBean", new Object [] {shortName, type}, new String [] {String .class.getName(), Class .class.getName()}); 315 } catch (GBeanNotFoundException e) { 316 throw e; 317 } catch (RuntimeException e) { 318 throw e; 319 } catch (Exception e) { 320 throw new InternalKernelException(e); 321 } 322 } 323 324 public void unloadGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 325 try { 326 invokeKernel("unloadGBean", new Object [] {name}, new String [] {AbstractName.class.getName()}); 327 } catch (GBeanNotFoundException e) { 328 throw e; 329 } catch (RuntimeException e) { 330 throw e; 331 } catch (Exception e) { 332 throw new InternalKernelException(e); 333 } 334 } 335 336 public void unloadGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 337 try { 338 invokeKernel("unloadGBean", new Object [] {shortName}, new String [] {String .class.getName()}); 339 } catch (GBeanNotFoundException e) { 340 throw e; 341 } catch (RuntimeException e) { 342 throw e; 343 } catch (Exception e) { 344 throw new InternalKernelException(e); 345 } 346 } 347 348 public void unloadGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 349 try { 350 invokeKernel("unloadGBean", new Object [] {type}, new String [] {Class .class.getName()}); 351 } catch (GBeanNotFoundException e) { 352 throw e; 353 } catch (RuntimeException e) { 354 throw e; 355 } catch (Exception e) { 356 throw new InternalKernelException(e); 357 } 358 } 359 360 public void unloadGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException { 361 try { 362 invokeKernel("unloadGBean", new Object [] {shortName, type}, new String [] {String .class.getName(), Class .class.getName()}); 363 } catch (GBeanNotFoundException e) { 364 throw e; 365 } catch (RuntimeException e) { 366 throw e; 367 } catch (Exception e) { 368 throw new InternalKernelException(e); 369 } 370 } 371 372 public int getGBeanState(ObjectName name) throws GBeanNotFoundException { 373 try { 374 return ((Integer ) invokeKernel("getGBeanState", new Object []{name}, new String []{ObjectName .class.getName()})).intValue(); 375 } catch (GBeanNotFoundException e) { 376 throw e; 377 } catch (RuntimeException e) { 378 throw e; 379 } catch (Exception e) { 380 throw new InternalKernelException(e); 381 } 382 } 383 384 public int getGBeanState(AbstractName name) throws GBeanNotFoundException { 385 try { 386 return ((Integer ) invokeKernel("getGBeanState", new Object []{name}, new String []{AbstractName.class.getName()})).intValue(); 387 } catch (GBeanNotFoundException e) { 388 throw e; 389 } catch (RuntimeException e) { 390 throw e; 391 } catch (Exception e) { 392 throw new InternalKernelException(e); 393 } 394 } 395 396 public int getGBeanState(String shortName) throws GBeanNotFoundException { 397 try { 398 return ((Integer ) invokeKernel("getGBeanState", new Object []{shortName}, new String []{String .class.getName()})).intValue(); 399 } catch (GBeanNotFoundException e) { 400 throw e; 401 } catch (RuntimeException e) { 402 throw e; 403 } catch (Exception e) { 404 throw new InternalKernelException(e); 405 } 406 } 407 408 public int getGBeanState(Class type) throws GBeanNotFoundException { 409 try { 410 return ((Integer ) invokeKernel("getGBeanState", new Object []{type}, new String []{Class .class.getName()})).intValue(); 411 } catch (GBeanNotFoundException e) { 412 throw e; 413 } catch (RuntimeException e) { 414 throw e; 415 } catch (Exception e) { 416 throw new InternalKernelException(e); 417 } 418 } 419 420 public int getGBeanState(String shortName, Class type) throws GBeanNotFoundException { 421 try { 422 return ((Integer ) invokeKernel("getGBeanState", new Object []{shortName, type}, new String []{String .class.getName(), Class .class.getName()})).intValue(); 423 } catch (GBeanNotFoundException e) { 424 throw e; 425 } catch (RuntimeException e) { 426 throw e; 427 } catch (Exception e) { 428 throw new InternalKernelException(e); 429 } 430 } 431 432 public long getGBeanStartTime(AbstractName name) throws GBeanNotFoundException { 433 try { 434 return ((Long ) invokeKernel("getGBeanStartTime", new Object []{name}, new String []{AbstractName.class.getName()})).longValue(); 435 } catch (GBeanNotFoundException e) { 436 throw e; 437 } catch (RuntimeException e) { 438 throw e; 439 } catch (Exception e) { 440 throw new InternalKernelException(e); 441 } 442 } 443 444 public long getGBeanStartTime(String shortName) throws GBeanNotFoundException { 445 try { 446 return ((Long ) invokeKernel("getGBeanStartTime", new Object []{shortName}, new String []{String .class.getName()})).longValue(); 447 } catch (GBeanNotFoundException e) { 448 throw e; 449 } catch (RuntimeException e) { 450 throw e; 451 } catch (Exception e) { 452 throw new InternalKernelException(e); 453 } 454 } 455 456 public long getGBeanStartTime(Class type) throws GBeanNotFoundException { 457 try { 458 return ((Long ) invokeKernel("getGBeanStartTime", new Object []{type}, new String []{Class .class.getName()})).longValue(); 459 } catch (GBeanNotFoundException e) { 460 throw e; 461 } catch (RuntimeException e) { 462 throw e; 463 } catch (Exception e) { 464 throw new InternalKernelException(e); 465 } 466 } 467 468 public long getGBeanStartTime(String shortName, Class type) throws GBeanNotFoundException { 469 try { 470 return ((Long ) invokeKernel("getGBeanStartTime", new Object []{shortName, type}, new String []{String .class.getName(), Class .class.getName()})).longValue(); 471 } catch (GBeanNotFoundException e) { 472 throw e; 473 } catch (RuntimeException e) { 474 throw e; 475 } catch (Exception e) { 476 throw new InternalKernelException(e); 477 } 478 } 479 480 public Object getAttribute(ObjectNam
|