1 17 18 package org.apache.catalina.mbeans; 19 20 import javax.management.Attribute ; 21 import javax.management.AttributeNotFoundException ; 22 import javax.management.InstanceNotFoundException ; 23 import javax.management.MBeanException ; 24 import javax.management.ReflectionException ; 25 import javax.management.RuntimeOperationsException ; 26 import javax.management.modelmbean.InvalidTargetObjectTypeException ; 27 28 import org.apache.catalina.connector.Connector; 29 import org.apache.tomcat.util.IntrospectionUtils; 30 31 32 39 40 public class ConnectorMBean extends ClassNameMBean { 41 42 43 45 46 55 public ConnectorMBean() 56 throws MBeanException , RuntimeOperationsException { 57 58 super(); 59 60 } 61 62 63 65 66 78 public Object getAttribute(String name) throws AttributeNotFoundException , 79 MBeanException , ReflectionException { 80 81 Object attribute = null; 82 if (name == null) 84 throw new RuntimeOperationsException (new IllegalArgumentException ( 85 "Attribute name is null"), "Attribute name is null"); 86 87 Object result = null; 88 try { 89 Connector connector = (Connector) getManagedResource(); 90 result = IntrospectionUtils.getProperty(connector, name); 91 } catch (InstanceNotFoundException e) { 92 throw new MBeanException (e); 93 } catch (InvalidTargetObjectTypeException e) { 94 throw new MBeanException (e); 95 } 96 97 return result; 98 99 } 100 101 102 115 public void setAttribute(Attribute attribute) 116 throws AttributeNotFoundException , MBeanException , 117 ReflectionException { 118 119 if (attribute == null) 121 throw new RuntimeOperationsException (new IllegalArgumentException ( 122 "Attribute is null"), "Attribute is null"); 123 String name = attribute.getName(); 124 Object value = attribute.getValue(); 125 if (name == null) 126 throw new RuntimeOperationsException (new IllegalArgumentException ( 127 "Attribute name is null"), "Attribute name is null"); 128 129 try { 130 Connector connector = (Connector) getManagedResource(); 131 IntrospectionUtils.setProperty(connector, name, String.valueOf(value)); 132 } catch (InstanceNotFoundException e) { 133 throw new MBeanException (e); 134 } catch (InvalidTargetObjectTypeException e) { 135 throw new MBeanException (e); 136 } 137 138 } 139 140 141 } 142 | Popular Tags |