KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > jmx > AppServerMBeanServerInterceptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.admin.jmx;
25
26 import java.util.Set JavaDoc;
27 import java.util.IdentityHashMap JavaDoc;
28
29 import javax.management.*;
30 import com.sun.jmx.mbeanserver.SunJmxMBeanServer;
31 import com.sun.jmx.interceptor.ForwardingMBeanServerInterceptor;
32 import java.io.IOException JavaDoc;
33
34 /**
35  * <p>An {@link MBeanServerInterceptor} that forwards every request
36  * unchanged to another {@link MBeanServerInterceptor}. This class is
37  * useful as a superclass for interceptors that override some its
38  * methods and perform some action before forwarding to the chained
39  * interceptor. Subclasses forward methods such as {@link
40  * #getAttribute} by calling <code>super.getAttribute(...)</code>.
41  * They may of course choose not to forward if appropriate.</p>
42  *
43  * <p>Any number of <code>ForwardingMBeanServerInterceptor</code>
44  * objects may be chained together on the path from the MBean server
45  * to its default {@link MBeanServerInterceptor}. This class provides
46  * convenience methods to manipulate such a chain.</p>
47  *
48  * <p>The same <code>ForwardingMBeanServerInterceptor</code> instance
49  * should not be inserted into more than one MBean server at a
50  * time.</p>
51  */

52 public final class AppServerMBeanServerInterceptor extends ForwardingMBeanServerInterceptor {
53     /**
54      * <p>Create a new <code>ForwardingMBeanServerInterceptor</code>
55      * that initially forwards its requests to nobody. {@link
56      * #setNextInterceptor} should be called before the interceptor is
57      * inserted into an MBean server. Otherwise, {@link
58      * NullPointerException} will be produced for every operation on
59      * that MBean server.</p>
60      */

61     protected AppServerMBeanServerInterceptor() {
62     }
63
64     public ObjectInstance createMBean(String JavaDoc className, ObjectName name,
65                       Object JavaDoc params[], String JavaDoc signature[])
66         throws ReflectionException, InstanceAlreadyExistsException,
67                MBeanRegistrationException, MBeanException,
68            NotCompliantMBeanException {
69                        System.out.println("AppServerMBeanServerInterceptor: createMBean");
70     return super.createMBean(className, name, params, signature);
71     }
72
73     public ObjectInstance createMBean(String JavaDoc className, ObjectName name,
74                       ObjectName loaderName, Object JavaDoc params[],
75                       String JavaDoc signature[])
76         throws ReflectionException, InstanceAlreadyExistsException,
77                MBeanRegistrationException, MBeanException,
78                NotCompliantMBeanException, InstanceNotFoundException {
79                        System.out.println("AppServerMBeanServerInterceptor: createMBean");
80     return super.createMBean(className, name, loaderName, params,
81                 signature);
82     }
83     
84      public ObjectInstance createMBean(String JavaDoc className, ObjectName name,
85                       ObjectName loaderName)
86         throws ReflectionException, InstanceAlreadyExistsException,
87            MBeanRegistrationException, MBeanException,
88            NotCompliantMBeanException, InstanceNotFoundException,
89            IOException JavaDoc {
90                        System.out.println("NYI: createMBean");
91                        return null;
92                        //FIXME: NYI??
93
}
94
95      public ObjectInstance createMBean(String JavaDoc className, ObjectName name)
96         throws ReflectionException, InstanceAlreadyExistsException,
97            MBeanRegistrationException, MBeanException,
98            NotCompliantMBeanException, IOException JavaDoc {
99                        System.out.println("NYI: createMBean");
100                    return null;
101                    //FXIME: NYI??
102
}
103          
104     public ObjectInstance registerMBean(Object JavaDoc object, ObjectName name)
105         throws InstanceAlreadyExistsException, MBeanRegistrationException,
106            NotCompliantMBeanException {
107                        System.out.println("AppServerMBeanServerInterceptor: registerMBean");
108     return super.registerMBean(object, name);
109     }
110
111     public void unregisterMBean(ObjectName name)
112         throws InstanceNotFoundException, MBeanRegistrationException {
113     super.unregisterMBean(name);
114     }
115
116     public Set JavaDoc queryMBeans(ObjectName name, QueryExp query) {
117     return super.queryMBeans(name, query);
118     }
119
120     public Set JavaDoc queryNames(ObjectName name, QueryExp query) {
121     return super.queryNames(name, query);
122     }
123
124     public boolean isRegistered(ObjectName name) {
125     return super.isRegistered(name);
126     }
127
128     public Object JavaDoc getAttribute(ObjectName name, String JavaDoc attribute)
129         throws MBeanException, AttributeNotFoundException,
130                InstanceNotFoundException, ReflectionException {
131         System.out.println("AppServerMBeanServerInterceptor: getAttrbute");
132         MBeanManufacturer.findPersistent(name);
133     return super.getAttribute(name, attribute);
134     }
135
136     public AttributeList getAttributes(ObjectName name, String JavaDoc[] attributes)
137         throws InstanceNotFoundException, ReflectionException {
138                 MBeanManufacturer.findPersistent(name);
139     return super.getAttributes(name, attributes);
140     }
141
142     public void setAttribute(ObjectName name, Attribute attribute)
143         throws InstanceNotFoundException, AttributeNotFoundException,
144            InvalidAttributeValueException, MBeanException,
145            ReflectionException {
146                        MBeanManufacturer.findPersistent(name);
147     super.setAttribute(name, attribute);
148     }
149
150     public AttributeList setAttributes(ObjectName name,
151                        AttributeList attributes)
152         throws InstanceNotFoundException, ReflectionException {
153     return super.setAttributes(name, attributes);
154     }
155
156     public Object JavaDoc invoke(ObjectName name, String JavaDoc operationName,
157              Object JavaDoc params[], String JavaDoc signature[])
158         throws InstanceNotFoundException, MBeanException,
159            ReflectionException {
160                        MBeanManufacturer.findPersistent(name);
161     return super.invoke(name, operationName, params, signature);
162     }
163  
164     public String JavaDoc getDefaultDomain() {
165     return super.getDefaultDomain();
166     }
167
168     public MBeanInfo getMBeanInfo(ObjectName name)
169         throws InstanceNotFoundException, IntrospectionException,
170                ReflectionException {
171         MBeanManufacturer.findPersistent(name);
172         
173     return super.getMBeanInfo(name);
174     }
175
176     public boolean isInstanceOf(ObjectName name, String JavaDoc className)
177         throws InstanceNotFoundException {
178                 System.out.println("isInstanceOF: ?? FIXME");
179     return super.isInstanceOf(name, className);
180     }
181
182     public ClassLoader JavaDoc getClassLoaderFor(ObjectName mbeanName)
183     throws InstanceNotFoundException {
184     return super.getClassLoaderFor(mbeanName);
185     }
186
187     public ClassLoader JavaDoc getClassLoader(ObjectName loaderName)
188     throws InstanceNotFoundException {
189     return super.getClassLoader(loaderName);
190     }
191
192     //FIXME: NYI!
193
private String JavaDoc mapName(String JavaDoc name) {
194         //replace dashes with underscores.
195
return name.replace('-', '_');
196     }
197 }
198
Popular Tags