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