1 17 18 package org.apache.catalina.mbeans; 19 20 21 import javax.management.MBeanException ; 22 import javax.management.MBeanServer ; 23 import javax.management.RuntimeOperationsException ; 24 25 import org.apache.catalina.Valve; 26 import org.apache.catalina.core.StandardHost; 27 import org.apache.tomcat.util.modeler.BaseModelMBean; 28 import org.apache.tomcat.util.modeler.ManagedBean; 29 import org.apache.tomcat.util.modeler.Registry; 30 31 32 39 40 public class StandardHostMBean extends BaseModelMBean { 41 42 45 private static MBeanServer mserver = MBeanUtils.createServer(); 46 47 49 50 59 public StandardHostMBean() 60 throws MBeanException , RuntimeOperationsException { 61 62 super(); 63 64 } 65 66 67 69 70 71 73 74 81 public void addAlias(String alias) 82 throws Exception { 83 84 StandardHost host = (StandardHost) this.resource; 85 host.addAlias(alias); 86 87 } 88 89 90 95 public String [] findAliases() 96 throws Exception { 97 98 StandardHost host = (StandardHost) this.resource; 99 return host.findAliases(); 100 101 } 102 103 104 109 public String [] getValves() 110 throws Exception { 111 112 Registry registry = MBeanUtils.createRegistry(); 113 StandardHost host = (StandardHost) this.resource; 114 String mname = MBeanUtils.createManagedName(host); 115 ManagedBean managed = registry.findManagedBean(mname); 116 String domain = null; 117 if (managed != null) { 118 domain = managed.getDomain(); 119 } 120 if (domain == null) 121 domain = mserver.getDefaultDomain(); 122 Valve [] valves = host.getValves(); 123 String [] mbeanNames = new String [valves.length]; 124 for (int i = 0; i < valves.length; i++) { 125 mbeanNames[i] = 126 MBeanUtils.createObjectName(domain, valves[i]).toString(); 127 } 128 129 return mbeanNames; 130 131 } 132 133 134 141 public void removeAlias(String alias) 142 throws Exception { 143 144 StandardHost host = (StandardHost) this.resource; 145 host.removeAlias(alias); 146 147 } 148 149 150 } 151 | Popular Tags |