1 19 package org.netbeans.modules.j2ee.sun.util; 20 21 import java.util.Set ; 22 import java.io.IOException ; 23 24 25 import com.sun.appserv.management.util.jmx.MBeanServerConnection_Hook; 26 import javax.management.Attribute ; 27 import javax.management.AttributeList ; 28 import javax.management.AttributeNotFoundException ; 29 import javax.management.InstanceNotFoundException ; 30 import javax.management.IntrospectionException ; 31 import javax.management.InvalidAttributeValueException ; 32 import javax.management.MBeanException ; 33 import javax.management.MBeanInfo ; 34 import javax.management.MBeanServerConnection ; 35 import javax.management.ObjectName ; 36 import javax.management.QueryExp ; 37 import javax.management.ReflectionException ; 38 39 import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface; 40 41 import org.openide.util.NbBundle; 42 43 46 public class PluginRequestInterceptor 47 extends MBeanServerConnection_Hook { 48 49 final MBeanServerConnection_Hook.Hook myHook; 50 51 55 public PluginRequestInterceptor( 56 final SunDeploymentManagerInterface sunDplymtIntrface, 57 final MBeanServerConnection connection) { 58 super(connection); 59 this.myHook = new DebugCheckerHook(sunDplymtIntrface); 60 } 61 62 63 67 Hook getHook() { 68 return this.myHook; 69 } 70 71 72 75 public void setAttribute(ObjectName name, Attribute attribute) 76 throws InstanceNotFoundException , AttributeNotFoundException , 77 InvalidAttributeValueException , MBeanException , 78 ReflectionException , IOException { 79 getHook().preHook(null); 80 super.setAttribute(name, attribute); 81 } 82 83 84 88 public AttributeList setAttributes(ObjectName name, AttributeList attributes) 89 throws InstanceNotFoundException , ReflectionException , IOException { 90 getHook().preHook(null); 91 return super.setAttributes(name, attributes); 92 } 93 94 95 99 public Object getAttribute(ObjectName name, String attribute) 100 throws MBeanException , AttributeNotFoundException , 101 InstanceNotFoundException , ReflectionException , 102 IOException { 103 getHook().preHook(null); 104 return super.getAttribute(name, attribute); 105 } 106 107 108 111 public AttributeList getAttributes(ObjectName name, String [] attributes) 112 throws InstanceNotFoundException , ReflectionException , 113 IOException { 114 getHook().preHook(null); 115 return super.getAttributes(name, attributes); 116 } 117 118 119 122 public MBeanInfo getMBeanInfo(ObjectName name) 123 throws InstanceNotFoundException , IntrospectionException , 124 ReflectionException , IOException { 125 getHook().preHook(null); 126 return super.getMBeanInfo(name); 127 } 128 129 130 131 135 public Object invoke(ObjectName name, String operationName, 136 Object params[], String signature[]) 137 throws InstanceNotFoundException , MBeanException , 138 ReflectionException , IOException { 139 getHook().preHook(null); 140 return super.invoke(name, operationName, params, signature); 141 } 142 143 144 148 public Set queryNames(ObjectName name, QueryExp query) 149 throws IOException { 150 getHook().preHook(null); 151 return super.queryNames(name, query); 152 } 153 154 155 159 public Set queryMBeans(ObjectName name, QueryExp query) 160 throws IOException { 161 getHook().preHook(null); 162 return super.queryMBeans(name, query); 163 } 164 165 166 170 class DebugCheckerHook extends MBeanServerConnection_Hook.HookImpl { 171 172 private SunDeploymentManagerInterface sunDpmtMgr; 173 174 177 public DebugCheckerHook( 178 final SunDeploymentManagerInterface sunDplymtIntrface) { 179 this.sunDpmtMgr = sunDplymtIntrface; 180 } 181 182 183 186 public long preHook(final String methodName) { 187 return preHook(methodName, new Object [] {}); 188 } 189 190 191 194 public long preHook(final String methodName, final Object [] args) { 195 if(sunDpmtMgr.isSuspended()) { 196 GUIUtils.showInformation( 197 getLocalizedString("server_dbg_mode_notify")); 198 throw new RuntimeException ( 199 getLocalizedString("server_dbg_mode_notify")); 200 } 201 return super.preHook(methodName, args); 202 } 203 204 } 206 207 211 private static String getLocalizedString(final String bundleStrProp) { 212 return NbBundle.getMessage(PluginRequestInterceptor.class, 213 bundleStrProp); 214 } 215 } 216 | Popular Tags |