KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > util > PluginRequestInterceptor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.sun.util;
20
21 import java.util.Set JavaDoc;
22 import java.io.IOException JavaDoc;
23
24
25 import com.sun.appserv.management.util.jmx.MBeanServerConnection_Hook;
26 import javax.management.Attribute JavaDoc;
27 import javax.management.AttributeList JavaDoc;
28 import javax.management.AttributeNotFoundException JavaDoc;
29 import javax.management.InstanceNotFoundException JavaDoc;
30 import javax.management.IntrospectionException JavaDoc;
31 import javax.management.InvalidAttributeValueException JavaDoc;
32 import javax.management.MBeanException JavaDoc;
33 import javax.management.MBeanInfo JavaDoc;
34 import javax.management.MBeanServerConnection JavaDoc;
35 import javax.management.ObjectName JavaDoc;
36 import javax.management.QueryExp JavaDoc;
37 import javax.management.ReflectionException JavaDoc;
38
39 import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface;
40
41 import org.openide.util.NbBundle;
42
43 /**
44  *
45  */

46 public class PluginRequestInterceptor
47         extends MBeanServerConnection_Hook {
48
49     final MBeanServerConnection_Hook.Hook myHook;
50     
51     /**
52      *
53      *
54      */

55     public PluginRequestInterceptor(
56             final SunDeploymentManagerInterface sunDplymtIntrface,
57             final MBeanServerConnection JavaDoc connection) {
58         super(connection);
59         this.myHook = new DebugCheckerHook(sunDplymtIntrface);
60     }
61     
62
63     /**
64      *
65      *
66      */

67     Hook getHook() {
68         return this.myHook;
69     }
70     
71     
72     /**
73      *
74      */

75     public void setAttribute(ObjectName JavaDoc name, Attribute JavaDoc attribute)
76             throws InstanceNotFoundException JavaDoc, AttributeNotFoundException JavaDoc,
77             InvalidAttributeValueException JavaDoc, MBeanException JavaDoc,
78             ReflectionException JavaDoc, IOException JavaDoc {
79         getHook().preHook(null);
80         super.setAttribute(name, attribute);
81     }
82
83
84     /**
85      *
86      *
87      */

88     public AttributeList JavaDoc setAttributes(ObjectName JavaDoc name, AttributeList JavaDoc attributes)
89             throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc {
90        getHook().preHook(null);
91        return super.setAttributes(name, attributes);
92     }
93      
94     
95     /**
96      *
97      *
98      */

99     public Object JavaDoc getAttribute(ObjectName JavaDoc name, String JavaDoc attribute)
100             throws MBeanException JavaDoc, AttributeNotFoundException JavaDoc,
101             InstanceNotFoundException JavaDoc, ReflectionException JavaDoc,
102             IOException JavaDoc {
103         getHook().preHook(null);
104         return super.getAttribute(name, attribute);
105     }
106
107
108     /**
109      *
110      */

111     public AttributeList JavaDoc getAttributes(ObjectName JavaDoc name, String JavaDoc[] attributes)
112             throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc,
113             IOException JavaDoc {
114         getHook().preHook(null);
115         return super.getAttributes(name, attributes);
116     }
117      
118      
119     /**
120      *
121      */

122     public MBeanInfo JavaDoc getMBeanInfo(ObjectName JavaDoc name)
123             throws InstanceNotFoundException JavaDoc, IntrospectionException JavaDoc,
124             ReflectionException JavaDoc, IOException JavaDoc {
125         getHook().preHook(null);
126         return super.getMBeanInfo(name);
127     }
128
129      
130     
131     /**
132      *
133      *
134      */

135     public Object JavaDoc invoke(ObjectName JavaDoc name, String JavaDoc operationName,
136             Object JavaDoc params[], String JavaDoc signature[])
137             throws InstanceNotFoundException JavaDoc, MBeanException JavaDoc,
138             ReflectionException JavaDoc, IOException JavaDoc {
139        getHook().preHook(null);
140        return super.invoke(name, operationName, params, signature);
141     }
142
143     
144     /**
145      *
146      *
147      */

148     public Set JavaDoc queryNames(ObjectName JavaDoc name, QueryExp JavaDoc query)
149             throws IOException JavaDoc {
150         getHook().preHook(null);
151         return super.queryNames(name, query);
152     }
153
154     
155     /**
156      *
157      *
158      */

159     public Set JavaDoc queryMBeans(ObjectName JavaDoc name, QueryExp JavaDoc query)
160             throws IOException JavaDoc {
161         getHook().preHook(null);
162         return super.queryMBeans(name, query);
163     }
164     
165     
166     /**
167      *
168      *
169      */

170     class DebugCheckerHook extends MBeanServerConnection_Hook.HookImpl {
171
172         private SunDeploymentManagerInterface sunDpmtMgr;
173         
174         /**
175          *
176          */

177         public DebugCheckerHook(
178                 final SunDeploymentManagerInterface sunDplymtIntrface) {
179             this.sunDpmtMgr = sunDplymtIntrface;
180         }
181
182         
183         /**
184          *
185          */

186         public long preHook(final String JavaDoc methodName) {
187             return preHook(methodName, new Object JavaDoc[] {});
188         }
189
190         
191         /**
192          *
193          */

194         public long preHook(final String JavaDoc methodName, final Object JavaDoc[] args) {
195             if(sunDpmtMgr.isSuspended()) {
196                 GUIUtils.showInformation(
197                     getLocalizedString("server_dbg_mode_notify"));
198                 throw new RuntimeException JavaDoc(
199                     getLocalizedString("server_dbg_mode_notify"));
200             }
201             return super.preHook(methodName, args);
202         }
203         
204     } //end inner class
205

206          
207     /**
208      *
209      *
210      */

211     private static String JavaDoc getLocalizedString(final String JavaDoc bundleStrProp) {
212         return NbBundle.getMessage(PluginRequestInterceptor.class,
213                 bundleStrProp);
214     }
215 }
216
Popular Tags