1 8 9 package mx4j.tools.remote; 10 11 import java.io.IOException ; 12 import java.util.Set ; 13 import javax.management.Attribute ; 14 import javax.management.AttributeList ; 15 import javax.management.AttributeNotFoundException ; 16 import javax.management.InstanceAlreadyExistsException ; 17 import javax.management.InstanceNotFoundException ; 18 import javax.management.IntrospectionException ; 19 import javax.management.InvalidAttributeValueException ; 20 import javax.management.ListenerNotFoundException ; 21 import javax.management.MBeanException ; 22 import javax.management.MBeanInfo ; 23 import javax.management.MBeanRegistrationException ; 24 import javax.management.MBeanServerConnection ; 25 import javax.management.NotCompliantMBeanException ; 26 import javax.management.NotificationFilter ; 27 import javax.management.ObjectInstance ; 28 import javax.management.ObjectName ; 29 import javax.management.QueryExp ; 30 import javax.management.ReflectionException ; 31 import javax.security.auth.Subject ; 32 33 42 public abstract class JMXConnectionMBeanServerConnection implements MBeanServerConnection 43 { 44 private final JMXConnection connection; 45 private final Subject delegate; 46 47 protected JMXConnectionMBeanServerConnection(JMXConnection connection, Subject delegate) 48 { 49 this.connection = connection; 50 this.delegate = delegate; 51 } 52 53 protected JMXConnection getConnection() 54 { 55 return connection; 56 } 57 58 protected Subject getDelegateSubject() 59 { 60 return delegate; 61 } 62 63 public MBeanInfo getMBeanInfo(ObjectName objectName) throws InstanceNotFoundException , IntrospectionException , ReflectionException , IOException 64 { 65 return getConnection().getMBeanInfo(objectName, getDelegateSubject()); 66 } 67 68 public boolean isInstanceOf(ObjectName objectName, String className) throws InstanceNotFoundException , IOException 69 { 70 return getConnection().isInstanceOf(objectName, className, getDelegateSubject()); 71 } 72 73 public String [] getDomains() throws IOException 74 { 75 return getConnection().getDomains(getDelegateSubject()); 76 } 77 78 public String getDefaultDomain() throws IOException 79 { 80 return getConnection().getDefaultDomain(getDelegateSubject()); 81 } 82 83 public ObjectInstance createMBean(String className, ObjectName objectName) throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException , IOException 84 { 85 return createMBean(className, objectName, null, null); 86 } 87 88 public ObjectInstance createMBean(String className, ObjectName objectName, Object [] args, String [] parameters) throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException , IOException 89 { 90 return getConnection().createMBean(className, objectName, args, parameters, getDelegateSubject()); 91 } 92 93 public ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName) throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException , InstanceNotFoundException , IOException 94 { 95 return createMBean(className, objectName, loaderName, null, null); 96 } 97 98 public ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName, Object [] args, String [] parameters) throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException , InstanceNotFoundException , IOException 99 { 100 return getConnection().createMBean(className, objectName, loaderName, args, parameters, getDelegateSubject()); 101 } 102 103 public void unregisterMBean(ObjectName objectName) throws InstanceNotFoundException , MBeanRegistrationException , IOException 104 { 105 getConnection().unregisterMBean(objectName, getDelegateSubject()); 106 } 107 108 public Object getAttribute(ObjectName objectName, String attribute) throws MBeanException , AttributeNotFoundException , InstanceNotFoundException , ReflectionException , IOException 109 { 110 return getConnection().getAttribute(objectName, attribute, getDelegateSubject()); 111 } 112 113 public void setAttribute(ObjectName objectName, Attribute attribute) throws InstanceNotFoundException , AttributeNotFoundException , InvalidAttributeValueException , MBeanException , ReflectionException , IOException 114 { 115 getConnection().setAttribute(objectName, attribute, getDelegateSubject()); 116 } 117 118 public AttributeList getAttributes(ObjectName objectName, String [] attributes) throws InstanceNotFoundException , ReflectionException , IOException 119 { 120 return getConnection().getAttributes(objectName, attributes, getDelegateSubject()); 121 } 122 123 public AttributeList setAttributes(ObjectName objectName, AttributeList attributes) throws InstanceNotFoundException , ReflectionException , IOException 124 { 125 return getConnection().setAttributes(objectName, attributes, getDelegateSubject()); 126 } 127 128 public Object invoke(ObjectName objectName, String methodName, Object [] args, String [] parameters) throws InstanceNotFoundException , MBeanException , ReflectionException , IOException 129 { 130 return getConnection().invoke(objectName, methodName, args, parameters, getDelegateSubject()); 131 } 132 133 public Integer getMBeanCount() throws IOException 134 { 135 return getConnection().getMBeanCount(getDelegateSubject()); 136 } 137 138 public boolean isRegistered(ObjectName objectName) throws IOException 139 { 140 return getConnection().isRegistered(objectName, getDelegateSubject()); 141 } 142 143 public ObjectInstance getObjectInstance(ObjectName objectName) throws InstanceNotFoundException , IOException 144 { 145 return getConnection().getObjectInstance(objectName, getDelegateSubject()); 146 } 147 148 public Set queryMBeans(ObjectName patternName, QueryExp filter) throws IOException 149 { 150 return getConnection().queryMBeans(patternName, filter, getDelegateSubject()); 151 } 152 153 public Set queryNames(ObjectName patternName, QueryExp filter) throws IOException 154 { 155 return getConnection().queryNames(patternName, filter, getDelegateSubject()); 156 } 157 158 public void addNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException , IOException 159 { 160 getConnection().addNotificationListener(observed, listener, filter, handback, getDelegateSubject()); 161 } 162 163 public void removeNotificationListener(ObjectName observed, ObjectName listener) throws InstanceNotFoundException , ListenerNotFoundException , IOException 164 { 165 getConnection().removeNotificationListener(observed, listener, getDelegateSubject()); 166 } 167 168 public void removeNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException , ListenerNotFoundException , IOException 169 { 170 getConnection().removeNotificationListener(observed, listener, filter, handback, getDelegateSubject()); 171 } 172 } 173 | Popular Tags |