1 17 18 package org.apache.catalina.mbeans; 19 20 21 import java.beans.PropertyChangeEvent ; 22 import java.beans.PropertyChangeListener ; 23 import javax.management.MBeanException ; 24 25 import org.apache.catalina.Container; 26 import org.apache.catalina.ContainerEvent; 27 import org.apache.catalina.ContainerListener; 28 import org.apache.catalina.Context; 29 import org.apache.catalina.Engine; 30 import org.apache.catalina.Globals; 31 import org.apache.catalina.Host; 32 import org.apache.catalina.Lifecycle; 33 import org.apache.catalina.LifecycleEvent; 34 import org.apache.catalina.LifecycleListener; 35 import org.apache.catalina.Loader; 36 import org.apache.catalina.Manager; 37 import org.apache.catalina.Realm; 38 import org.apache.catalina.Server; 39 import org.apache.catalina.ServerFactory; 40 import org.apache.catalina.Service; 41 import org.apache.catalina.connector.Connector; 42 import org.apache.catalina.core.StandardContext; 43 import org.apache.catalina.core.StandardEngine; 44 import org.apache.catalina.core.StandardHost; 45 import org.apache.catalina.core.StandardServer; 46 import org.apache.catalina.core.StandardService; 47 import org.apache.catalina.deploy.ContextEnvironment; 48 import org.apache.catalina.deploy.ContextResource; 49 import org.apache.catalina.deploy.ContextResourceLink; 50 import org.apache.catalina.deploy.NamingResources; 51 import org.apache.commons.logging.Log; 52 import org.apache.commons.logging.LogFactory; 53 54 55 64 65 public class ServerLifecycleListener 66 implements ContainerListener, LifecycleListener, PropertyChangeListener { 67 68 private static Log log = LogFactory.getLog(ServerLifecycleListener.class); 69 70 71 73 74 77 protected String descriptors = null; 78 79 public String getDescriptors() { 80 return (this.descriptors); 81 } 82 83 public void setDescriptors(String descriptors) { 84 this.descriptors = descriptors; 85 } 86 87 88 90 91 97 public void containerEvent(ContainerEvent event) { 98 99 try { 100 String type = event.getType(); 101 if (Container.ADD_CHILD_EVENT.equals(type)) { 102 processContainerAddChild(event.getContainer(), 103 (Container) event.getData()); 104 } else if (Container.REMOVE_CHILD_EVENT.equals(type)) { 105 processContainerRemoveChild(event.getContainer(), 106 (Container) event.getData()); 107 } 108 } catch (Exception e) { 109 log.error("Exception processing event " + event, e); 110 } 111 112 } 113 114 115 117 118 123 public void lifecycleEvent(LifecycleEvent event) { 124 125 Lifecycle lifecycle = event.getLifecycle(); 126 if (Lifecycle.START_EVENT.equals(event.getType())) { 127 128 if (lifecycle instanceof Server) { 129 createMBeans(); 130 } 131 132 if( lifecycle instanceof Service ) { 134 try { 135 MBeanFactory factory = new MBeanFactory(); 136 createMBeans(factory); 137 createMBeans((Service)lifecycle); 138 } catch( Exception ex ) { 139 log.error("Create mbean factory"); 140 } 141 } 142 143 150 151 } else if (Lifecycle.STOP_EVENT.equals(event.getType())) { 152 try { 153 if (lifecycle instanceof Server) { 154 destroyMBeans((Server)lifecycle); 155 } 156 if (lifecycle instanceof Service) { 157 destroyMBeans((Service)lifecycle); 158 } 159 } catch (MBeanException t) { 160 161 Exception e = t.getTargetException(); 162 if (e == null) { 163 e = t; 164 } 165 log.error("destroyMBeans: MBeanException", e); 166 167 } catch (Throwable t) { 168 169 log.error("destroyMBeans: Throwable", t); 170 171 } 172 176 } 177 178 if ((Context.RELOAD_EVENT.equals(event.getType())) 179 || (Lifecycle.START_EVENT.equals(event.getType()))) { 180 181 if (lifecycle instanceof StandardContext) { 185 StandardContext context = (StandardContext)lifecycle; 188 if (context.getPrivileged()) { 189 context.getServletContext().setAttribute 190 (Globals.MBEAN_REGISTRY_ATTR, 191 MBeanUtils.createRegistry()); 192 context.getServletContext().setAttribute 193 (Globals.MBEAN_SERVER_ATTR, 194 MBeanUtils.createServer()); 195 } 196 } 197 198 } 199 200 } 201 202 203 205 206 212 public void propertyChange(PropertyChangeEvent event) { 213 214 if (event.getSource() instanceof Container) { 215 try { 216 processContainerPropertyChange((Container) event.getSource(), 217 event.getPropertyName(), 218 event.getOldValue(), 219 event.getNewValue()); 220 } catch (Exception e) { 221 log.error("Exception handling Container property change", e); 222 } 223 } else if (event.getSource() instanceof NamingResources) { 234 try { 235 processNamingResourcesPropertyChange 236 ((NamingResources) event.getSource(), 237 event.getPropertyName(), 238 event.getOldValue(), 239 event.getNewValue()); 240 } catch (Exception e) { 241 log.error("Exception handling NamingResources property change", e); 242 } 243 } else if (event.getSource() instanceof Server) { 244 try { 245 processServerPropertyChange((Server) event.getSource(), 246 event.getPropertyName(), 247 event.getOldValue(), 248 event.getNewValue()); 249 } catch (Exception e) { 250 log.error("Exception handing Server property change", e); 251 } 252 } else if (event.getSource() instanceof Service) { 253 try { 254 processServicePropertyChange((Service) event.getSource(), 255 event.getPropertyName(), 256 event.getOldValue(), 257 event.getNewValue()); 258 } catch (Exception e) { 259 log.error("Exception handing Service property change", e); 260 } 261 } 262 263 } 264 265 266 268 269 272 protected void createMBeans() { 273 274 try { 275 276 MBeanFactory factory = new MBeanFactory(); 277 createMBeans(factory); 278 createMBeans(ServerFactory.getServer()); 279 280 } catch (MBeanException t) { 281 282 Exception e = t.getTargetException(); 283 if (e == null) 284 e = t; 285 log.error("createMBeans: MBeanException", e); 286 287 } catch (Throwable t) { 288 289 log.error("createMBeans: Throwable", t); 290 291 } 292 293 } 294 295 296 303 protected void createMBeans(Connector connector) throws Exception { 304 305 310 } 311 312 313 320 protected void createMBeans(Context context) throws Exception { 321 322 context.addContainerListener(this); 327 if (context instanceof StandardContext) { 328 ((StandardContext) context).addPropertyChangeListener(this); 329 ((StandardContext) context).addLifecycleListener(this); 330 } 331 332 if (context.getPrivileged()) { 335 context.getServletContext().setAttribute 336 (Globals.MBEAN_REGISTRY_ATTR, 337 MBeanUtils.createRegistry()); 338 context.getServletContext().setAttribute 339 (Globals.MBEAN_SERVER_ATTR, 340 MBeanUtils.createServer()); 341 } 342 343 Loader cLoader = context.getLoader(); 345 if (cLoader != null) { 346 if (log.isDebugEnabled()) 347 log.debug("Creating MBean for Loader " + cLoader); 348 } 350 Manager cManager = context.getManager(); 351 if (cManager != null) { 352 if (log.isDebugEnabled()) 353 log.debug("Creating MBean for Manager " + cManager); 354 } 356 Realm hRealm = context.getParent().getRealm(); 357 Realm cRealm = context.getRealm(); 358 if ((cRealm != null) && (cRealm != hRealm)) { 359 if (log.isDebugEnabled()) 360 log.debug("Creating MBean for Realm " + cRealm); 361 } 363 364 NamingResources resources = context.getNamingResources(); 366 createMBeans(resources); 367 368 } 369 370 371 378 protected void createMBeans(ContextEnvironment environment) 379 throws Exception { 380 381 if (log.isDebugEnabled()) { 383 log.debug("Creating MBean for ContextEnvironment " + environment); 384 } 385 MBeanUtils.createMBean(environment); 386 387 } 388 389 390 397 protected void createMBeans(ContextResource resource) 398 throws Exception { 399 400 if (log.isDebugEnabled()) { 402 log.debug("Creating MBean for ContextResource " + resource); 403 } 404 MBeanUtils.createMBean(resource); 405 406 } 407 408 409 416 protected void createMBeans(ContextResourceLink resourceLink) 417 throws Exception { 418 419 if (log.isDebugEnabled()) { 421 log.debug("Creating MBean for ContextResourceLink " + resourceLink); 422 } 423 MBeanUtils.createMBean(resourceLink); 424 425 } 426 427 428 435 466 467 468 475 protected void createMBeans(Engine engine) throws Exception { 476 477 if (log.isDebugEnabled()) { 479 log.debug("Creating MBean for Engine " + engine); 480 } 481 engine.addContainerListener(this); 483 if (engine instanceof StandardEngine) { 484 ((StandardEngine) engine).addPropertyChangeListener(this); 485 } 486 487 Realm eRealm = engine.getRealm(); 489 if (eRealm != null) { 490 if (log.isDebugEnabled()) 491 log.debug("Creating MBean for Realm " + eRealm); 492 } 494 495 Container hosts[] = engine.findChildren(); 497 for (int j = 0; j < hosts.length; j++) { 498 createMBeans((Host) hosts[j]); 499 } 500 501 } 502 503 504 511 protected void createMBeans(Host host) throws Exception { 512 513 if (log.isDebugEnabled()) { 515 log.debug("Creating MBean for Host " + host); 516 } 517 host.addContainerListener(this); 519 if (host instanceof StandardHost) { 520 ((StandardHost) host).addPropertyChangeListener(this); 521 } 522 523 Realm eRealm = host.getParent().getRealm(); 525 Realm hRealm = host.getRealm(); 526 if ((hRealm != null) && (hRealm != eRealm)) { 527 if (log.isDebugEnabled()) 528 log.debug("Creating MBean for Realm " + hRealm); 529 } 531 532 Container contexts[] = host.findChildren(); 534 for (int k = 0; k < contexts.length; k++) { 535 createMBeans((Context) contexts[k]); 536 } 537 538 } 539 540 541 548 protected void createMBeans(MBeanFactory factory) throws Exception { 549 550 if (log.isDebugEnabled()) 552 log.debug("Creating MBean for MBeanFactory " + factory); 553 MBeanUtils.createMBean(factory); 554 555 } 556 557 558 564 protected void createMBeans(NamingResources resources) throws Exception { 565 566 if (log.isDebugEnabled()) { 568 log.debug("Creating MBean for NamingResources " + resources); 569 } 570 MBeanUtils.createMBean(resources); 571 resources.addPropertyChangeListener(this); 572 573 ContextEnvironment environments[] = resources.findEnvironments(); 575 for (int i = 0; i < environments.length; i++) { 576 createMBeans(environments[i]); 577 } 578 579 ContextResource cresources[] = resources.findResources(); 581 for (int i = 0; i < cresources.length; i++) { 582 createMBeans(cresources[i]); 583 } 584 585 ContextResourceLink cresourcelinks[] = resources.findResourceLinks(); 587 for (int i = 0; i < cresourcelinks.length; i++) { 588 createMBeans(cresourcelinks[i]); 589 } 590 591 } 592 593 594 601 protected void createMBeans(Server server) throws Exception { 602 603 if (log.isDebugEnabled()) 605 log.debug("Creating MBean for Server " + server); 606 if (server instanceof StandardServer) { 608 ((StandardServer) server).addPropertyChangeListener(this); 609 } 610 611 NamingResources resources = server.getGlobalNamingResources(); 613 if (resources != null) { 614 createMBeans(resources); 615 } 616 617 Service services[] = server.findServices(); 619 for (int i = 0; i < services.length; i++) { 620 if (services[i].getContainer().getClass().getName().equals 622 ("org.apache.catalina.connector.warp.WarpEngine")) { 623 if (log.isDebugEnabled()) { 624 log.debug("Skipping MBean for Service " + services[i]); 625 } 626 continue; 627 } 628 createMBeans(services[i]); 629 } 630 631 } 632 633 634 641 protected void createMBeans(Service service) throws Exception { 642 643 if (log.isDebugEnabled()) 645 log.debug("Creating MBean for Service " + service); 646 if (service instanceof StandardService) { 648 ((StandardService) service).addPropertyChangeListener(this); 649 } 650 651 Connector connectors[] = service.findConnectors(); 653 for (int j = 0; j < connectors.length; j++) { 654 createMBeans(connectors[j]); 655 } 656 657 Engine engine = (Engine) service.getContainer(); 659 if (engine != null) { 660 createMBeans(engine); 661 } 662 663 } 664 665 666 667 668 676 protected void destroyMBeans(Connector connector, Service service) 677 throws Exception { 678 679 684 } 685 686 687 695 protected void destroyMBeans(Context context) throws Exception { 696 697 context.removeContainerListener(this); 699 700 Realm hRealm = context.getParent().getRealm(); 702 Realm cRealm = context.getRealm(); 703 if ((cRealm != null) && (cRealm != hRealm)) { 704 if (log.isDebugEnabled()) 705 log.debug("Destroying MBean for Realm " + cRealm); 706 } 708 Manager cManager = context.getManager(); 709 if (cManager != null) { 710 if (log.isDebugEnabled()) 711 log.debug("Destroying MBean for Manager " + cManager); 712 } 714 Loader cLoader = context.getLoader(); 715 if (cLoader != null) { 716 if (log.isDebugEnabled()) 717 log.debug("Destroying MBean for Loader " + cLoader); 718 } 720 721 NamingResources resources = context.getNamingResources(); 723 if (resources != null) { 724 destroyMBeans(resources); 725 } 726 727 if (log.isDebugEnabled()) 729 log.debug("Destroying MBean for Context " + context); 730 if (context instanceof StandardContext) { 732 ((StandardContext) context). 733 removePropertyChangeListener(this); 734 } 735 736 } 737 738 739 746 protected void destroyMBeans(ContextEnvironment environment) 747 throws Exception { 748 749 if (log.isDebugEnabled()) { 751 log.debug("Destroying MBean for ContextEnvironment " + environment); 752 } 753 MBeanUtils.destroyMBean(environment); 754 755 } 756 757 758 765 protected void destroyMBeans(ContextResource resource) 766 throws Exception { 767 768 if (log.isDebugEnabled()) { 770 log.debug("Destroying MBean for ContextResource " + resource); 771 } 772 MBeanUtils.destroyMBean(resource); 773 774 } 775 776 777 784 protected void destroyMBeans(ContextResourceLink resourceLink) 785 throws Exception { 786 787 if (log.isDebugEnabled()) { 789 log.debug("Destroying MBean for ContextResourceLink " + resourceLink); 790 } 791 MBeanUtils.destroyMBean(resourceLink); 792 793 } 794 795 796 804 835 836 837 845 protected void destroyMBeans(Engine engine) throws Exception { 846 847 engine.removeContainerListener(this); 849 850 Container hosts[] = engine.findChildren(); 852 for (int k = 0; k < hosts.length; k++) { 853 destroyMBeans((Host) hosts[k]); 854 } 855 856 Realm eRealm = engine.getRealm(); 858 if (eRealm != null) { 859 if (log.isDebugEnabled()) 860 log.debug("Destroying MBean for Realm " + eRealm); 861 } 863 864 if (log.isDebugEnabled()) { 866 log.debug("Destroying MBean for Engine " + engine); 867 } 868 870 } 871 872 873 880 protected void destroyMBeans(Host host) throws Exception { 881 882 host.removeContainerListener(this); 884 885 Container contexts[] = host.findChildren(); 887 for (int k = 0; k < contexts.length; k++) { 888 destroyMBeans((Context) contexts[k]); 889 } 890 891 892 Realm eRealm = host.getParent().getRealm(); 894 Realm hRealm = host.getRealm(); 895 if ((hRealm != null) && (hRealm != eRealm)) { 896 if (log.isDebugEnabled()) 897 log.debug("Destroying MBean for Realm " + hRealm); 898 } 900 901 if (log.isDebugEnabled()) { 903 log.debug("Destroying MBean for Host " + host); 904 } 905 907 } 908 909 910 918 protected void destroyMBeans(NamingResources resources) throws Exception { 919 920 ContextResource cresources[] = resources.findResources(); 922 for (int i = 0; i < cresources.length; i++) { 923 destroyMBeans(cresources[i]); 924 } 925 926 ContextResourceLink cresourcelinks[] = resources.findResourceLinks(); 928 for (int i = 0; i < cresourcelinks.length; i++) { 929 destroyMBeans(cresourcelinks[i]); 930 } 931 932 ContextEnvironment environments[] = resources.findEnvironments(); 934 for (int i = 0; i < environments.length; i++) { 935 destroyMBeans(environments[i]); 936 } 937 938 if (log.isDebugEnabled()) { 940 log.debug("Destroying MBean for NamingResources " + resources); 941 } 942 MBeanUtils.destroyMBean(resources); 943 resources.removePropertyChangeListener(this); 944 945 } 946 947 948 956 protected void destroyMBeans(Server server) throws Exception { 957 958 NamingResources resources = server.getGlobalNamingResources(); 960 if (resources != null) { 961 destroyMBeans(resources); 962 } 963 964 Service services[] = server.findServices(); 966 for (int i = 0; i < services.length; i++) { 967 if (services[i].getContainer().getClass().getName().equals 969 ("org.apache.catalina.connector.warp.WarpEngine")) { 970 if (log.isDebugEnabled()) { 971 log.debug("Skipping MBean for Service " + services[i]); 972 } 973 continue; 974 } 975 destroyMBeans(services[i]); 976 } 977 978 if (log.isDebugEnabled()) { 980 log.debug("Destroying MBean for Server " + server); 981 } 982 if (server instanceof StandardServer) { 984 ((StandardServer) server).removePropertyChangeListener(this); 985 } 986 987 } 988 989 990 998 protected void destroyMBeans(Service service) throws Exception { 999 1000 Engine engine = (Engine) service.getContainer(); 1002 if (engine != null) { 1003 } 1005 1006 1012 if (log.isDebugEnabled()) { 1014 log.debug("Destroying MBean for Service " + service); 1015 } 1016 if (service instanceof StandardService) { 1018 ((StandardService) service).removePropertyChangeListener(this); 1019 } 1020 1021 } 1022 1023 1024 1030 protected void processContainerAddChild(Container parent, 1031 Container child) { 1032 1033 if (log.isDebugEnabled()) 1034 log.debug("Process addChild[parent=" + parent + ",child=" + child + "]"); 1035 1036 try { 1037 if (child instanceof Context) { 1038 createMBeans((Context) child); 1039 } else if (child instanceof Engine) { 1040 createMBeans((Engine) child); 1041 } else if (child instanceof Host) { 1042 createMBeans((Host) child); 1043 } 1044 } catch (MBeanException t) { 1045 Exception e = t.getTargetException(); 1046 if (e == null) 1047 e = t; 1048 log.error("processContainerAddChild: MBeanException", e); 1049 } catch (Throwable t) { 1050 log.error("processContainerAddChild: Throwable", t); 1051 } 1052 1053 } 1054 1055 1056 1057 1058 1068 protected void processContainerPropertyChange(Container container, 1069 String propertyName, 1070 Object oldValue, 1071 Object newValue) 1072 throws Exception { 1073 1074 if (log.isTraceEnabled()) { 1075 log.trace("propertyChange[container=" + container + 1076 ",propertyName=" + propertyName + 1077 ",oldValue=" + oldValue + 1078 ",newValue=" + newValue + "]"); 1079 } 1080 if ("loader".equals(propertyName)) { 1081 if (oldValue != null) { 1082 if (log.isDebugEnabled()) { 1083 log.debug("Removing MBean for Loader " + oldValue); 1084 } 1085 MBeanUtils.destroyMBean((Loader) oldValue); 1086 } 1087 if (newValue != null) { 1088 if (log.isDebugEnabled()) { 1089 log.debug("Creating MBean for Loader " + newValue); 1090 } 1091 MBeanUtils.createMBean((Loader) newValue); 1092 } 1093 } else if ("logger".equals(propertyName)) { 1094 if (oldValue != null) { 1095 if (log.isDebugEnabled()) { 1096 log.debug("Removing MBean for Logger " + oldValue); 1097 } 1098 } 1100 if (newValue != null) { 1101 if (log.isDebugEnabled()) { 1102 log.debug("Creating MBean for Logger " + newValue); 1103 } 1104 } 1106 } else if ("manager".equals(propertyName)) { 1107 if (oldValue != null) { 1108 if (log.isDebugEnabled()) { 1109 log.debug("Removing MBean for Manager " + oldValue); 1110 } 1111 } 1113 if (newValue != null) { 1114 if (log.isDebugEnabled()) { 1115 log.debug("Creating MBean for Manager " + newValue); 1116 } 1117 } 1119 } else if ("realm".equals(propertyName)) { 1120 if (oldValue != null) { 1121 if (log.isDebugEnabled()) { 1122 log.debug("Removing MBean for Realm " + oldValue); 1123 } 1124 MBeanUtils.destroyMBean((Realm) oldValue); 1125 } 1126 if (newValue != null) { 1127 if (log.isDebugEnabled()) { 1128 log.debug("Creating MBean for Realm " + newValue); 1129 } 1130 } 1132 } else if ("service".equals(propertyName)) { 1133 if (oldValue != null) { 1134 destroyMBeans((Service) oldValue); 1135 } 1136 if (newValue != null) { 1137 createMBeans((Service) newValue); 1138 } 1139 } 1140 1141 } 1142 1143 1144 1154 1229 1230 1231 1237 protected void processContainerRemoveChild(Container parent, 1238 Container child) { 1239 1240 if (log.isDebugEnabled()) 1241 log.debug("Process removeChild[parent=" + parent + ",child=" + 1242 child + "]"); 1243 1244 try { 1245 if (child instanceof Context) { 1246 Context context = (Context) child; 1247 if (context.getPrivileged()) { 1248 context.getServletContext().removeAttribute 1249 (Globals.MBEAN_REGISTRY_ATTR); 1250 context.getServletContext().removeAttribute 1251 (Globals.MBEAN_SERVER_ATTR); 1252 } 1253 if (log.isDebugEnabled()) 1254 log.debug(" Removing MBean for Context " + context); 1255 destroyMBeans(context); 1256 if (context instanceof StandardContext) { 1257 ((StandardContext) context). 1258 removePropertyChangeListener(this); 1259 } 1260 } else if (child instanceof Host) { 1261 Host host = (Host) child; 1262 destroyMBeans(host); 1263 if (host instanceof StandardHost) { 1264 ((StandardHost) host). 1265 removePropertyChangeListener(this); 1266 } 1267 } 1268 } catch (MBeanException t) { 1269 Exception e = t.getTargetException(); 1270 if (e == null) 1271 e = t; 1272 log.error("processContainerRemoveChild: MBeanException", e); 1273 } catch (Throwable t) { 1274 log.error("processContainerRemoveChild: Throwable", t); 1275 } 1276 1277 } 1278 1279 1280 1291 protected void processNamingResourcesPropertyChange 1292 (NamingResources resources, String propertyName, 1293 Object oldValue, Object newValue) 1294 throws Exception { 1295 1296 if (log.isTraceEnabled()) { 1297 log.trace("propertyChange[namingResources=" + resources + 1298 ",propertyName=" + propertyName + 1299 ",oldValue=" + oldValue + 1300 ",newValue=" + newValue + "]"); 1301 } 1302 1303 if ("environment".equals(propertyName)) { 1305 if (oldValue != null) { 1306 destroyMBeans((ContextEnvironment) oldValue); 1307 } 1308 if (newValue != null) { 1309 createMBeans((ContextEnvironment) newValue); 1310 } 1311 } else if ("resource".equals(propertyName)) { 1312 if (oldValue != null) { 1313 destroyMBeans((ContextResource) oldValue); 1314 } 1315 if (newValue != null) { 1316 createMBeans((ContextResource) newValue); 1317 } 1318 } else if ("resourceLink".equals(propertyName)) { 1319 if (oldValue != null) { 1320 destroyMBeans((ContextResourceLink) oldValue); 1321 } 1322 if (newValue != null) { 1323 createMBeans((ContextResourceLink) newValue); 1324 } 1325 } 1326 1327 } 1328 1329 1330 1340 protected void processServerPropertyChange(Server server, 1341 String propertyName, 1342 Object oldValue, 1343 Object newValue) 1344 throws Exception { 1345 1346 if (log.isTraceEnabled()) { 1347 log.trace("propertyChange[server=" + server + 1348 ",propertyName=" + propertyName + 1349 ",oldValue=" + oldValue + 1350 ",newValue=" + newValue + "]"); 1351 } 1352 if ("globalNamingResources".equals(propertyName)) { 1353 if (oldValue != null) { 1354 destroyMBeans((NamingResources) oldValue); 1355 } 1356 if (newValue != null) { 1357 createMBeans((NamingResources) newValue); 1358 } 1359 } else if ("service".equals(propertyName)) { 1360 if (oldValue != null) { 1361 destroyMBeans((Service) oldValue); 1362 } 1363 if (newValue != null) { 1364 createMBeans((Service) newValue); 1365 } 1366 } 1367 1368 } 1369 1370 1371 1381 protected void processServicePropertyChange(Service service, 1382 String propertyName, 1383 Object oldValue, 1384 Object newValue) 1385 throws Exception { 1386 1387 if (log.isTraceEnabled()) { 1388 log.trace("propertyChange[service=" + service + 1389 ",propertyName=" + propertyName + 1390 ",oldValue=" + oldValue + 1391 ",newValue=" + newValue + "]"); 1392 } 1393 if ("connector".equals(propertyName)) { 1394 if (oldValue != null) { 1395 destroyMBeans((Connector) oldValue, service); 1396 } 1397 if (newValue != null) { 1398 createMBeans((Connector) newValue); 1399 } 1400 } else if ("container".equals(propertyName)) { 1401 if (oldValue != null) { 1402 destroyMBeans((Engine) oldValue); 1403 } 1404 if (newValue != null) { 1405 createMBeans((Engine) newValue); 1406 } 1407 } 1408 1409 } 1410 1411 1412} 1413 | Popular Tags |