Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ChainedMBeanServer.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Marc Wick.
00022  * Contributor(s): ______________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.controller.jmx;
00026 
00027 import java.io.ObjectInputStream;
00028 import java.util.Set;
00029 
00030 import javax.management.Attribute;
00031 import javax.management.AttributeList;
00032 import javax.management.AttributeNotFoundException;
00033 import javax.management.InstanceAlreadyExistsException;
00034 import javax.management.InstanceNotFoundException;
00035 import javax.management.IntrospectionException;
00036 import javax.management.InvalidAttributeValueException;
00037 import javax.management.ListenerNotFoundException;
00038 import javax.management.MBeanException;
00039 import javax.management.MBeanInfo;
00040 import javax.management.MBeanRegistrationException;
00041 import javax.management.MBeanServer;
00042 import javax.management.NotCompliantMBeanException;
00043 import javax.management.NotificationFilter;
00044 import javax.management.NotificationListener;
00045 import javax.management.ObjectInstance;
00046 import javax.management.ObjectName;
00047 import javax.management.OperationsException;
00048 import javax.management.QueryExp;
00049 import javax.management.ReflectionException;
00050 import javax.management.loading.ClassLoaderRepository;
00051 
00052 /**
00053  * Base class for chained MBeanServers. By default this class delegates all
00054  * method calls to the nested MBeanServer. Subclass it to add behavior to one or
00055  * more (or all) methods.
00056  * <p>
00057  * This class takes its origin in mx4j.server.ChainedMBeanServer
00058  * 
00059  * @author <a href="mailto:marc.wick@monte-bre.ch">Marc Wick </a>
00060  * @version 1.0
00061  */
00062 public class ChainedMBeanServer implements MBeanServer
00063 
00064 {
00065   private MBeanServer mbServer;
00066 
00067   /**
00068    * Creates a new ChainedMBeanServer that will delegate to an MBeanServer
00069    * specified using {@link #setMBeanServer}
00070    */
00071   public ChainedMBeanServer()
00072   {
00073     this(null);
00074   }
00075 
00076   /**
00077    * Creates a new ChainedMBeanServer that delegates to the specified
00078    * <code>MBeanServer</code>.
00079    * 
00080    * @param server MBeanServer
00081    */
00082   public ChainedMBeanServer(MBeanServer server)
00083   {
00084     setMBeanServer(server);
00085   }
00086 
00087   /**
00088    * Returns the nested MBeanServer
00089    */
00090   protected synchronized MBeanServer getMBeanServer()
00091   {
00092     return mbServer;
00093   }
00094 
00095   protected synchronized void setMBeanServer(MBeanServer server)
00096   {
00097     mbServer = server;
00098   }
00099 
00100   /**
00101    * @see javax.management.MBeanServerConnection#addNotificationListener(javax.management.ObjectName,
00102    *      javax.management.NotificationListener,
00103    *      javax.management.NotificationFilter, java.lang.Object)
00104    */
00105   public void addNotificationListener(ObjectName observed,
00106       NotificationListener listener, NotificationFilter filter, Object handback)
00107       throws InstanceNotFoundException
00108   {
00109     getMBeanServer().addNotificationListener(observed, listener, filter,
00110         handback);
00111   }
00112 
00113   /**
00114    * @see javax.management.MBeanServerConnection#addNotificationListener(javax.management.ObjectName,
00115    *      javax.management.ObjectName, javax.management.NotificationFilter,
00116    *      java.lang.Object)
00117    */
00118   public void addNotificationListener(ObjectName observed, ObjectName listener,
00119       NotificationFilter filter, Object handback)
00120       throws InstanceNotFoundException
00121   {
00122     getMBeanServer().addNotificationListener(observed, listener, filter,
00123         handback);
00124   }
00125 
00126   /**
00127    * @see javax.management.MBeanServerConnection#createMBean(java.lang.String,
00128    *      javax.management.ObjectName)
00129    */
00130   public ObjectInstance createMBean(String className, ObjectName objectName)
00131       throws ReflectionException, InstanceAlreadyExistsException,
00132       MBeanRegistrationException, MBeanException, NotCompliantMBeanException
00133   {
00134     return getMBeanServer().createMBean(className, objectName);
00135   }
00136 
00137   /**
00138    * @see javax.management.MBeanServerConnection#createMBean(java.lang.String,
00139    *      javax.management.ObjectName, java.lang.Object[], java.lang.String[])
00140    */
00141   public ObjectInstance createMBean(String className, ObjectName objectName,
00142       Object[] args, String[] parameters) throws ReflectionException,
00143       InstanceAlreadyExistsException, MBeanRegistrationException,
00144       MBeanException, NotCompliantMBeanException
00145   {
00146     return getMBeanServer()
00147         .createMBean(className, objectName, args, parameters);
00148   }
00149 
00150   /**
00151    * @see javax.management.MBeanServerConnection#createMBean(java.lang.String,
00152    *      javax.management.ObjectName, javax.management.ObjectName)
00153    */
00154   public ObjectInstance createMBean(String className, ObjectName objectName,
00155       ObjectName loaderName) throws ReflectionException,
00156       InstanceAlreadyExistsException, MBeanRegistrationException,
00157       MBeanException, NotCompliantMBeanException, InstanceNotFoundException
00158   {
00159     return getMBeanServer().createMBean(className, objectName, loaderName);
00160   }
00161 
00162   /**
00163    * @see javax.management.MBeanServerConnection#createMBean(java.lang.String,
00164    *      javax.management.ObjectName, javax.management.ObjectName,
00165    *      java.lang.Object[], java.lang.String[])
00166    */
00167   public ObjectInstance createMBean(String className, ObjectName objectName,
00168       ObjectName loaderName, Object[] args, String[] parameters)
00169       throws ReflectionException, InstanceAlreadyExistsException,
00170       MBeanRegistrationException, MBeanException, NotCompliantMBeanException,
00171       InstanceNotFoundException
00172   {
00173     return getMBeanServer().createMBean(className, objectName, loaderName,
00174         args, parameters);
00175   }
00176 
00177   /**
00178    * @see javax.management.MBeanServer#deserialize(java.lang.String, byte[])
00179    */
00180   public ObjectInputStream deserialize(String className, byte[] bytes)
00181       throws OperationsException, ReflectionException
00182   {
00183     return getMBeanServer().deserialize(className, bytes);
00184   }
00185 
00186   /**
00187    * @see javax.management.MBeanServer#deserialize(java.lang.String,
00188    *      javax.management.ObjectName, byte[])
00189    */
00190   public ObjectInputStream deserialize(String className, ObjectName loaderName,
00191       byte[] bytes) throws InstanceNotFoundException, OperationsException,
00192       ReflectionException
00193   {
00194     return getMBeanServer().deserialize(className, loaderName, bytes);
00195   }
00196 
00197   /**
00198    * @see javax.management.MBeanServer#deserialize(javax.management.ObjectName,
00199    *      byte[])
00200    */
00201   public ObjectInputStream deserialize(ObjectName objectName, byte[] bytes)
00202       throws InstanceNotFoundException, OperationsException
00203   {
00204     return getMBeanServer().deserialize(objectName, bytes);
00205   }
00206 
00207   /**
00208    * @see javax.management.MBeanServerConnection#getAttribute(javax.management.ObjectName,
00209    *      java.lang.String)
00210    */
00211   public Object getAttribute(ObjectName objectName, String attribute)
00212       throws MBeanException, AttributeNotFoundException,
00213       InstanceNotFoundException, ReflectionException
00214   {
00215     return getMBeanServer().getAttribute(objectName, attribute);
00216   }
00217 
00218   /**
00219    * @see javax.management.MBeanServerConnection#getAttributes(javax.management.ObjectName,
00220    *      java.lang.String[])
00221    */
00222   public AttributeList getAttributes(ObjectName objectName, String[] attributes)
00223       throws InstanceNotFoundException, ReflectionException
00224   {
00225     return getMBeanServer().getAttributes(objectName, attributes);
00226   }
00227 
00228   /**
00229    * @see javax.management.MBeanServerConnection#getDefaultDomain()
00230    */
00231   public String getDefaultDomain()
00232   {
00233     return getMBeanServer().getDefaultDomain();
00234   }
00235 
00236   /**
00237    * @see javax.management.MBeanServerConnection#getDomains()
00238    */
00239   public String[] getDomains()
00240   {
00241     return getMBeanServer().getDomains();
00242   }
00243 
00244   /**
00245    * @see javax.management.MBeanServerConnection#getMBeanCount()
00246    */
00247   public Integer getMBeanCount()
00248   {
00249     return getMBeanServer().getMBeanCount();
00250   }
00251 
00252   /**
00253    * @see javax.management.MBeanServerConnection#getMBeanInfo(javax.management.ObjectName)
00254    */
00255   public MBeanInfo getMBeanInfo(ObjectName objectName)
00256       throws InstanceNotFoundException, IntrospectionException,
00257       ReflectionException
00258   {
00259     return getMBeanServer().getMBeanInfo(objectName);
00260   }
00261 
00262   /**
00263    * @see javax.management.MBeanServerConnection#getObjectInstance(javax.management.ObjectName)
00264    */
00265   public ObjectInstance getObjectInstance(ObjectName objectName)
00266       throws InstanceNotFoundException
00267   {
00268     return getMBeanServer().getObjectInstance(objectName);
00269   }
00270 
00271   /**
00272    * @see javax.management.MBeanServer#instantiate(java.lang.String)
00273    */
00274   public Object instantiate(String className) throws ReflectionException,
00275       MBeanException
00276   {
00277     return getMBeanServer().instantiate(className);
00278   }
00279 
00280   /**
00281    * @see javax.management.MBeanServer#instantiate(java.lang.String,
00282    *      java.lang.Object[], java.lang.String[])
00283    */
00284   public Object instantiate(String className, Object[] args, String[] parameters)
00285       throws ReflectionException, MBeanException
00286   {
00287     return getMBeanServer().instantiate(className, args, parameters);
00288   }
00289 
00290   /**
00291    * @see javax.management.MBeanServer#instantiate(java.lang.String,
00292    *      javax.management.ObjectName)
00293    */
00294   public Object instantiate(String className, ObjectName loaderName)
00295       throws ReflectionException, MBeanException, InstanceNotFoundException
00296   {
00297     return getMBeanServer().instantiate(className, loaderName);
00298   }
00299 
00300   /**
00301    * @see javax.management.MBeanServer#instantiate(java.lang.String,
00302    *      javax.management.ObjectName, java.lang.Object[], java.lang.String[])
00303    */
00304   public Object instantiate(String className, ObjectName loaderName,
00305       Object[] args, String[] parameters) throws ReflectionException,
00306       MBeanException, InstanceNotFoundException
00307   {
00308     return getMBeanServer()
00309         .instantiate(className, loaderName, args, parameters);
00310   }
00311 
00312   /**
00313    * @see javax.management.MBeanServerConnection#invoke(javax.management.ObjectName,
00314    *      java.lang.String, java.lang.Object[], java.lang.String[])
00315    */
00316   public Object invoke(ObjectName objectName, String methodName, Object[] args,
00317       String[] parameters) throws InstanceNotFoundException, MBeanException,
00318       ReflectionException
00319   {
00320     return getMBeanServer().invoke(objectName, methodName, args, parameters);
00321   }
00322 
00323   /**
00324    * @see javax.management.MBeanServerConnection#isInstanceOf(javax.management.ObjectName,
00325    *      java.lang.String)
00326    */
00327   public boolean isInstanceOf(ObjectName objectName, String className)
00328       throws InstanceNotFoundException
00329   {
00330     return getMBeanServer().isInstanceOf(objectName, className);
00331   }
00332 
00333   /**
00334    * @see javax.management.MBeanServerConnection#isRegistered(javax.management.ObjectName)
00335    */
00336   public boolean isRegistered(ObjectName objectname)
00337   {
00338     return getMBeanServer().isRegistered(objectname);
00339   }
00340 
00341   /**
00342    * @see javax.management.MBeanServerConnection#queryMBeans(javax.management.ObjectName,
00343    *      javax.management.QueryExp)
00344    */
00345   public Set queryMBeans(ObjectName patternName, QueryExp filter)
00346   {
00347     return getMBeanServer().queryMBeans(patternName, filter);
00348   }
00349 
00350   /**
00351    * @see javax.management.MBeanServerConnection#queryNames(javax.management.ObjectName,
00352    *      javax.management.QueryExp)
00353    */
00354   public Set queryNames(ObjectName patternName, QueryExp filter)
00355   {
00356     return getMBeanServer().queryNames(patternName, filter);
00357   }
00358 
00359   /**
00360    * @see javax.management.MBeanServer#registerMBean(java.lang.Object,
00361    *      javax.management.ObjectName)
00362    */
00363   public ObjectInstance registerMBean(Object mbean, ObjectName objectName)
00364       throws InstanceAlreadyExistsException, MBeanRegistrationException,
00365       NotCompliantMBeanException
00366   {
00367     return getMBeanServer().registerMBean(mbean, objectName);
00368   }
00369 
00370   /**
00371    * @see javax.management.MBeanServerConnection#removeNotificationListener(javax.management.ObjectName,
00372    *      javax.management.NotificationListener)
00373    */
00374   public void removeNotificationListener(ObjectName observed,
00375       NotificationListener listener) throws InstanceNotFoundException,
00376       ListenerNotFoundException
00377   {
00378     getMBeanServer().removeNotificationListener(observed, listener);
00379   }
00380 
00381   /**
00382    * @see javax.management.MBeanServerConnection#removeNotificationListener(javax.management.ObjectName,
00383    *      javax.management.ObjectName)
00384    */
00385   public void removeNotificationListener(ObjectName observed,
00386       ObjectName listener) throws InstanceNotFoundException,
00387       ListenerNotFoundException
00388   {
00389     getMBeanServer().removeNotificationListener(observed, listener);
00390   }
00391 
00392   /**
00393    * @see javax.management.MBeanServerConnection#removeNotificationListener(javax.management.ObjectName,
00394    *      javax.management.ObjectName, javax.management.NotificationFilter,
00395    *      java.lang.Object)
00396    */
00397   public void removeNotificationListener(ObjectName observed,
00398       ObjectName listener, NotificationFilter filter, Object handback)
00399       throws InstanceNotFoundException, ListenerNotFoundException
00400   {
00401     getMBeanServer().removeNotificationListener(observed, listener, filter,
00402         handback);
00403   }
00404 
00405   /**
00406    * @see javax.management.MBeanServerConnection#removeNotificationListener(javax.management.ObjectName,
00407    *      javax.management.NotificationListener,
00408    *      javax.management.NotificationFilter, java.lang.Object)
00409    */
00410   public void removeNotificationListener(ObjectName observed,
00411       NotificationListener listener, NotificationFilter filter, Object handback)
00412       throws InstanceNotFoundException, ListenerNotFoundException
00413   {
00414     getMBeanServer().removeNotificationListener(observed, listener, filter,
00415         handback);
00416   }
00417 
00418   /**
00419    * @see javax.management.MBeanServerConnection#setAttribute(javax.management.ObjectName,
00420    *      javax.management.Attribute)
00421    */
00422   public void setAttribute(ObjectName objectName, Attribute attribute)
00423       throws InstanceNotFoundException, AttributeNotFoundException,
00424       InvalidAttributeValueException, MBeanException, ReflectionException
00425   {
00426     getMBeanServer().setAttribute(objectName, attribute);
00427   }
00428 
00429   /**
00430    * @see javax.management.MBeanServerConnection#setAttributes(javax.management.ObjectName,
00431    *      javax.management.AttributeList)
00432    */
00433   public AttributeList setAttributes(ObjectName objectName,
00434       AttributeList attributes) throws InstanceNotFoundException,
00435       ReflectionException
00436   {
00437     return getMBeanServer().setAttributes(objectName, attributes);
00438   }
00439 
00440   /**
00441    * @see javax.management.MBeanServerConnection#unregisterMBean(javax.management.ObjectName)
00442    */
00443   public void unregisterMBean(ObjectName objectName)
00444       throws InstanceNotFoundException, MBeanRegistrationException
00445   {
00446     getMBeanServer().unregisterMBean(objectName);
00447   }
00448 
00449   /**
00450    * @see javax.management.MBeanServer#getClassLoaderFor(javax.management.ObjectName)
00451    */
00452   public ClassLoader getClassLoaderFor(ObjectName mbeanName)
00453       throws InstanceNotFoundException
00454   {
00455     return getMBeanServer().getClassLoaderFor(mbeanName);
00456   }
00457 
00458   /**
00459    * @see javax.management.MBeanServer#getClassLoader(javax.management.ObjectName)
00460    */
00461   public ClassLoader getClassLoader(ObjectName loaderName)
00462       throws InstanceNotFoundException
00463   {
00464     return getMBeanServer().getClassLoader(loaderName);
00465   }
00466 
00467   /**
00468    * @see javax.management.MBeanServer#getClassLoaderRepository()
00469    */
00470   public ClassLoaderRepository getClassLoaderRepository()
00471   {
00472     return getMBeanServer().getClassLoaderRepository();
00473   }
00474 
00475 }

Generated on Mon Apr 11 22:01:29 2005 for C-JDBC by  doxygen 1.3.9.1