1 package org.apache.tools.ant.taskdefs.optional.jmx.connector.weblogic; 2 3 52 53 import java.io.ObjectInputStream ; 54 import java.util.Set ; 55 56 import javax.management.AttributeList ; 57 import javax.management.AttributeNotFoundException ; 58 import javax.management.InstanceAlreadyExistsException ; 59 import javax.management.InstanceNotFoundException ; 60 import javax.management.ListenerNotFoundException ; 61 import javax.management.MBeanException ; 62 import javax.management.MBeanRegistrationException ; 63 import javax.management.NotCompliantMBeanException ; 64 import javax.management.NotificationFilter ; 65 import javax.management.NotificationListener ; 66 import javax.management.ObjectInstance ; 67 import javax.management.ObjectName ; 68 import javax.management.OperationsException ; 69 import javax.management.QueryExp ; 70 import javax.management.ReflectionException ; 71 72 import weblogic.management.RemoteMBeanServer; 73 74 88 public class WebLogicMBeanServer implements javax.management.MBeanServer { 89 90 weblogic.management.RemoteMBeanServer remoteServer; 91 92 93 public WebLogicMBeanServer(RemoteMBeanServer remoteServer) { 94 this.remoteServer = remoteServer; 95 } 96 97 98 public Object invoke(ObjectName objectName, String methodName, Object [] values, String [] types) 99 throws InstanceNotFoundException , MBeanException , ReflectionException { 100 101 boolean hasSpecialParam = false; 108 for (int counter = 0; counter < types.length; counter++) { 109 try { 110 if (isSpecialType(types[counter])) { 111 hasSpecialParam = true; 112 break; 113 } 114 } catch (ClassNotFoundException x) { 115 throw new MBeanException (x); 116 } 117 } 118 119 if (!hasSpecialParam) { 120 return remoteServer.invoke(objectName,methodName,values,types); 121 } else{ 122 try { 130 return remoteServer.getMBeanHome().getMBean(objectName).invoke(methodName, values, types); 131 } catch (Exception x) { 132 throw new MBeanException (x); 133 } 134 } 135 } 136 137 public void setAttribute(ObjectName objectName, javax.management.Attribute attribute) 138 throws InstanceNotFoundException , AttributeNotFoundException , javax.management.InvalidAttributeValueException , MBeanException , ReflectionException { 139 140 try { 141 if (isSpecialType(attribute.getValue().getClass())) { 142 remoteServer.getMBeanHome().getMBean(objectName).setAttribute(attribute); 143 } else { 144 remoteServer.setAttribute(objectName, attribute); 145 } 146 } catch (Exception x) { 147 throw new MBeanException (x); 148 } 149 } 150 151 163 private boolean isSpecialType(String className) 164 throws ClassNotFoundException { 165 Class theClass = Thread.currentThread().getContextClassLoader().loadClass(className); 166 return isSpecialType(theClass); 167 } 168 169 private boolean isSpecialType(Class theClass) 170 throws ClassNotFoundException { 171 return ( (weblogic.management.WebLogicMBean.class.isAssignableFrom(theClass)) 172 || ( (theClass.isArray()) && (isSpecialType(theClass.getComponentType().getName()) )) ); 173 } 174 175 public void addNotificationListener(ObjectName objectName, NotificationListener notificationListener, NotificationFilter notificationFilter, Object obj) throws InstanceNotFoundException { 176 remoteServer.addNotificationListener(objectName, notificationListener, notificationFilter, obj); 177 } 178 179 public void addNotificationListener(ObjectName objectName, ObjectName objectName1, NotificationFilter notificationFilter, Object obj) throws InstanceNotFoundException { 180 remoteServer.addNotificationListener(objectName, objectName1, notificationFilter, obj); 181 } 182 183 public ObjectInstance createMBean(String str, ObjectName objectName) throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException { 184 return remoteServer.createMBean(str,objectName); 185 } 186 187 public ObjectInstance createMBean(String str, ObjectName objectName, ObjectName objectName2) throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException , InstanceNotFoundException { 188 return remoteServer.createMBean(str,objectName,objectName2); 189 } 190 191 public ObjectInstance createMBean(String str, ObjectName objectName, Object [] obj, String [] str3) throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException { 192 return remoteServer.createMBean(str,objectName,obj,str3); 193 } 194 195 public ObjectInstance createMBean(String str, ObjectName objectName, ObjectName objectName2, Object [] obj, String [] str4) throws ReflectionException , InstanceAlreadyExistsException , MBeanRegistrationException , MBeanException , NotCompliantMBeanException , InstanceNotFoundException { 196 return remoteServer.createMBean(str, objectName, objectName2, obj, str4); 197 } 198 199 public ObjectInputStream deserialize(String str, byte[] values) throws OperationsException , ReflectionException { 200 return remoteServer.deserialize(str, values); 201 } 202 203 public ObjectInputStream deserialize(ObjectName objectName, byte[] values) throws InstanceNotFoundException , OperationsException { 204 return remoteServer.deserialize(objectName, values); 205 } 206 207 public ObjectInputStream deserialize(String str, ObjectName objectName, byte[] values) throws InstanceNotFoundException , OperationsException , ReflectionException { 208 return remoteServer.deserialize(str, objectName, values); 209 } 210 211 public Object getAttribute(ObjectName objectName, String str) throws MBeanException , AttributeNotFoundException , InstanceNotFoundException , ReflectionException { 212 return remoteServer.getAttribute(objectName,str); 213 } 214 215 public AttributeList getAttributes(ObjectName objectName, String [] str) throws InstanceNotFoundException , ReflectionException { 216 return remoteServer.getAttributes(objectName,str); 217 } 218 219 public String getDefaultDomain() { 220 return remoteServer.getDefaultDomain(); 221 } 222 223 public Integer getMBeanCount() { 224 return remoteServer.getMBeanCount(); 225 } 226 227 public javax.management.MBeanInfo getMBeanInfo(ObjectName objectName) throws InstanceNotFoundException , javax.management.IntrospectionException , ReflectionException { 228 return remoteServer.getMBeanInfo(objectName); 229 } 230 231 public ObjectInstance getObjectInstance(ObjectName objectName) throws InstanceNotFoundException { 232 return remoteServer.getObjectInstance(objectName); 233 } 234 235 public Object instantiate(String str) throws ReflectionException , MBeanException { 236 return remoteServer.instantiate(str); 237 } 238 239 public Object instantiate(String str, ObjectName objectName) throws ReflectionException , MBeanException , InstanceNotFoundException { 240 return remoteServer.instantiate(str,objectName); 241 } 242 243 public Object instantiate(String str, Object [] obj, String [] str2) throws ReflectionException , MBeanException { 244 return remoteServer.instantiate(str,obj,str2); 245 } 246 247 public Object instantiate(String str, ObjectName objectName, Object [] obj, String [] str3) throws ReflectionException , MBeanException , InstanceNotFoundException { 248 return remoteServer.instantiate(str,objectName,obj,str3); 249 } 250 251 public boolean isInstanceOf(ObjectName objectName, String str) throws InstanceNotFoundException { 252 return remoteServer.isInstanceOf(objectName,str); 253 } 254 255 public boolean isRegistered(ObjectName objectName) { 256 return remoteServer.isRegistered(objectName); 257 } 258 259 public Set queryMBeans(ObjectName objectName, QueryExp queryExp) { 260 return remoteServer.queryMBeans(objectName,queryExp); 261 } 262 263 public Set queryNames(ObjectName objectName, QueryExp queryExp) { 264 return remoteServer.queryNames(objectName,queryExp); 265 } 266 267 public ObjectInstance registerMBean(Object obj, ObjectName objectName) throws InstanceAlreadyExistsException , MBeanRegistrationException , NotCompliantMBeanException { 268 return remoteServer.registerMBean(obj,objectName); 269 } 270 271 public void removeNotificationListener(ObjectName objectName, ObjectName objectName1) throws InstanceNotFoundException , ListenerNotFoundException { 272 remoteServer.removeNotificationListener(objectName,objectName1); 273 } 274 275 public void removeNotificationListener(ObjectName objectName, NotificationListener notificationListener) throws InstanceNotFoundException , ListenerNotFoundException { 276 remoteServer.removeNotificationListener(objectName,notificationListener); 277 } 278 279 public AttributeList setAttributes(ObjectName objectName, AttributeList attributeList) throws InstanceNotFoundException , ReflectionException { 280 return remoteServer.setAttributes(objectName,attributeList); 281 } 282 283 public void unregisterMBean(ObjectName objectName) throws InstanceNotFoundException , MBeanRegistrationException { 284 remoteServer.unregisterMBean(objectName); 285 } 286 287 } 288 296 | Popular Tags |