jdk/src/share/classes/javax/management/namespace/MBeanServerConnectionWrapper.java
changeset 1156 bbc2d15aaf7a
child 1222 78e3d021d528
equal deleted inserted replaced
1155:a9a142fcf1b5 1156:bbc2d15aaf7a
       
     1 /*
       
     2  * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 package javax.management.namespace;
       
    27 
       
    28 import com.sun.jmx.mbeanserver.Util;
       
    29 import java.io.IOException;
       
    30 import java.io.ObjectInputStream;
       
    31 import java.security.AccessController;
       
    32 import java.util.Set;
       
    33 
       
    34 import javax.management.Attribute;
       
    35 import javax.management.AttributeList;
       
    36 import javax.management.AttributeNotFoundException;
       
    37 import javax.management.InstanceAlreadyExistsException;
       
    38 import javax.management.InstanceNotFoundException;
       
    39 import javax.management.IntrospectionException;
       
    40 import javax.management.InvalidAttributeValueException;
       
    41 import javax.management.ListenerNotFoundException;
       
    42 import javax.management.MBeanException;
       
    43 import javax.management.MBeanInfo;
       
    44 import javax.management.MBeanRegistrationException;
       
    45 import javax.management.MBeanServer;
       
    46 import javax.management.MBeanServerConnection;
       
    47 import javax.management.NotCompliantMBeanException;
       
    48 import javax.management.NotificationFilter;
       
    49 import javax.management.NotificationListener;
       
    50 import javax.management.ObjectInstance;
       
    51 import javax.management.ObjectName;
       
    52 import javax.management.OperationsException;
       
    53 import javax.management.QueryExp;
       
    54 import javax.management.ReflectionException;
       
    55 import javax.management.loading.ClassLoaderRepository;
       
    56 
       
    57 /**
       
    58  * <p>An object of this class implements the MBeanServer interface
       
    59  * and, for each of its methods forwards the request to a wrapped
       
    60  * {@link MBeanServerConnection} object.
       
    61  * Some methods of the {@link MBeanServer} interface do not have
       
    62  * any equivalent in {@link MBeanServerConnection}. In that case, an
       
    63  * {@link UnsupportedOperationException} will be thrown.
       
    64  *
       
    65  * <p>A typical use of this class is to apply a {@link QueryExp} object locally,
       
    66  * on an MBean that resides in a remote MBeanServer. Since an
       
    67  * MBeanServerConnection is not an MBeanServer, it cannot be passed
       
    68  * to the <code>setMBeanServer()</code> method of the {@link QueryExp}
       
    69  * object. However, this object can.</p>
       
    70  *
       
    71  * @since 1.7
       
    72  */
       
    73 public class MBeanServerConnectionWrapper
       
    74         implements MBeanServer {
       
    75 
       
    76     private final MBeanServerConnection wrapped;
       
    77     private final ClassLoader defaultCl;
       
    78 
       
    79     /**
       
    80      * Construct a new object that implements {@link MBeanServer} by
       
    81      * forwarding its methods to the given {@link MBeanServerConnection}.
       
    82      * This constructor is equivalent to {@link #MBeanServerConnectionWrapper(
       
    83      * MBeanServerConnection, ClassLoader) MBeanServerConnectionWrapper(wrapped,
       
    84      * null)}.
       
    85      *
       
    86      * @param wrapped the {@link MBeanServerConnection} to which methods
       
    87      * are to be forwarded.  This parameter can be null, in which case the
       
    88      * {@code MBeanServerConnection} will typically be supplied by overriding
       
    89      * {@link #getMBeanServerConnection}.
       
    90      */
       
    91     public MBeanServerConnectionWrapper(MBeanServerConnection wrapped) {
       
    92         this(wrapped, null);
       
    93     }
       
    94 
       
    95     /**
       
    96      * Construct a new object that implements {@link MBeanServer} by
       
    97      * forwarding its methods to the given {@link MBeanServerConnection}.
       
    98      * The {@code defaultCl} parameter specifies the value to be returned
       
    99      * by {@link #getDefaultClassLoader}.  A null value is equivalent to
       
   100      * {@link Thread#getContextClassLoader()}.
       
   101      *
       
   102      * @param wrapped the {@link MBeanServerConnection} to which methods
       
   103      * are to be forwarded.  This parameter can be null, in which case the
       
   104      * {@code MBeanServerConnection} will typically be supplied by overriding
       
   105      * {@link #getMBeanServerConnection}.
       
   106      * @param defaultCl the value to be returned by {@link
       
   107      * #getDefaultClassLoader}.  A null value is equivalent to the current
       
   108      * thread's {@linkplain Thread#getContextClassLoader()}.
       
   109      */
       
   110     public MBeanServerConnectionWrapper(MBeanServerConnection wrapped,
       
   111             ClassLoader defaultCl) {
       
   112         this.wrapped = wrapped;
       
   113         this.defaultCl = (defaultCl == null) ?
       
   114             Thread.currentThread().getContextClassLoader() : defaultCl;
       
   115     }
       
   116 
       
   117     /**
       
   118      * Returns an MBeanServerConnection. This method is called each time
       
   119      * an operation must be invoked on the underlying MBeanServerConnection.
       
   120      * The default implementation returns the MBeanServerConnection that
       
   121      * was supplied to the constructor of this MBeanServerConnectionWrapper.
       
   122      **/
       
   123     protected MBeanServerConnection getMBeanServerConnection() {
       
   124         return wrapped;
       
   125     }
       
   126 
       
   127     /**
       
   128      * Returns the default class loader passed to the constructor.  If the
       
   129      * value passed was null, then the returned value will be the
       
   130      * {@linkplain Thread#getContextClassLoader() context class loader} at the
       
   131      * time this object was constructed.
       
   132      *
       
   133      * @return the ClassLoader that was passed to the constructor.
       
   134      **/
       
   135     public ClassLoader getDefaultClassLoader() {
       
   136         return defaultCl;
       
   137     }
       
   138 
       
   139     /**
       
   140      * <p>This method is called each time an IOException is raised when
       
   141      * trying to forward an operation to the underlying
       
   142      * MBeanServerConnection, as a result of calling
       
   143      * {@link #getMBeanServerConnection()} or as a result of invoking the
       
   144      * operation on the returned connection.  Since the methods in
       
   145      * {@link MBeanServer} are not declared to throw {@code IOException},
       
   146      * this method must return a {@code RuntimeException} to be thrown
       
   147      * instead.  Typically, the original {@code IOException} will be in the
       
   148      * {@linkplain Throwable#getCause() cause chain} of the {@code
       
   149      * RuntimeException}.</p>
       
   150      *
       
   151      * <p>Subclasses may redefine this method if they need to perform any
       
   152      * specific handling of IOException (logging etc...).</p>
       
   153      *
       
   154      * @param x The raised IOException.
       
   155      * @param method The name of the method in which the exception was
       
   156      *        raised. This is one of the methods of the MBeanServer
       
   157      *        interface.
       
   158      *
       
   159      * @return A RuntimeException that should be thrown by the caller.
       
   160      *         In this default implementation, this is a
       
   161      *         {@link RuntimeException} wrapping <var>x</var>.
       
   162      **/
       
   163     protected RuntimeException wrapIOException(IOException x, String method) {
       
   164         return Util.newRuntimeIOException(x);
       
   165     }
       
   166 
       
   167     // Take care of getMBeanServerConnection returning null.
       
   168     //
       
   169     private synchronized MBeanServerConnection connection()
       
   170         throws IOException {
       
   171         final MBeanServerConnection c = getMBeanServerConnection();
       
   172         if (c == null)
       
   173             throw new IOException("MBeanServerConnection unavailable");
       
   174         return c;
       
   175     }
       
   176 
       
   177     //--------------------------------------------
       
   178     //--------------------------------------------
       
   179     //
       
   180     // Implementation of the MBeanServer interface
       
   181     //
       
   182     //--------------------------------------------
       
   183     //--------------------------------------------
       
   184 
       
   185     /**
       
   186      * Forward this method to the
       
   187      * wrapped object.
       
   188      */
       
   189     public void addNotificationListener(ObjectName name,
       
   190                                         NotificationListener listener,
       
   191                                         NotificationFilter filter,
       
   192                                         Object handback)
       
   193         throws InstanceNotFoundException {
       
   194         try {
       
   195             connection().addNotificationListener(name, listener,
       
   196                                                  filter, handback);
       
   197         } catch (IOException x) {
       
   198             throw wrapIOException(x,"addNotificationListener");
       
   199         }
       
   200     }
       
   201 
       
   202     /**
       
   203      * Forward this method to the
       
   204      * wrapped object.
       
   205      */
       
   206     public void addNotificationListener(ObjectName name,
       
   207                                         ObjectName listener,
       
   208                                         NotificationFilter filter,
       
   209                                         Object handback)
       
   210         throws InstanceNotFoundException {
       
   211         try {
       
   212             connection().addNotificationListener(name, listener,
       
   213                                                  filter, handback);
       
   214         } catch (IOException x) {
       
   215             throw wrapIOException(x,"addNotificationListener");
       
   216         }
       
   217     }
       
   218 
       
   219     /**
       
   220      * Forward this method to the
       
   221      * wrapped object.
       
   222      */
       
   223     public ObjectInstance createMBean(String className, ObjectName name)
       
   224         throws
       
   225         ReflectionException,
       
   226         InstanceAlreadyExistsException,
       
   227         MBeanRegistrationException,
       
   228         MBeanException,
       
   229         NotCompliantMBeanException {
       
   230         try {
       
   231             return connection().createMBean(className, name);
       
   232         } catch (IOException x) {
       
   233             throw wrapIOException(x,"createMBean");
       
   234         }
       
   235     }
       
   236 
       
   237     /**
       
   238      * Forward this method to the
       
   239      * wrapped object.
       
   240      */
       
   241     public ObjectInstance createMBean(String className, ObjectName name,
       
   242                                       Object params[], String signature[])
       
   243         throws
       
   244         ReflectionException,
       
   245         InstanceAlreadyExistsException,
       
   246         MBeanRegistrationException,
       
   247         MBeanException,
       
   248         NotCompliantMBeanException {
       
   249         try {
       
   250             return connection().createMBean(className, name,
       
   251                                             params, signature);
       
   252         } catch (IOException x) {
       
   253             throw wrapIOException(x,"createMBean");
       
   254         }
       
   255     }
       
   256 
       
   257     /**
       
   258      * Forward this method to the
       
   259      * wrapped object.
       
   260      */
       
   261     public ObjectInstance createMBean(String className,
       
   262                                       ObjectName name,
       
   263                                       ObjectName loaderName)
       
   264         throws
       
   265         ReflectionException,
       
   266         InstanceAlreadyExistsException,
       
   267         MBeanRegistrationException,
       
   268         MBeanException,
       
   269         NotCompliantMBeanException,
       
   270         InstanceNotFoundException {
       
   271         try {
       
   272             return connection().createMBean(className, name, loaderName);
       
   273         } catch (IOException x) {
       
   274             throw wrapIOException(x,"createMBean");
       
   275         }
       
   276     }
       
   277 
       
   278     /**
       
   279      * Forward this method to the
       
   280      * wrapped object.
       
   281      */
       
   282     public ObjectInstance createMBean(String className,
       
   283                                       ObjectName name,
       
   284                                       ObjectName loaderName,
       
   285                                       Object params[],
       
   286                                       String signature[])
       
   287         throws
       
   288         ReflectionException,
       
   289         InstanceAlreadyExistsException,
       
   290         MBeanRegistrationException,
       
   291         MBeanException,
       
   292         NotCompliantMBeanException,
       
   293         InstanceNotFoundException {
       
   294         try {
       
   295             return connection().createMBean(className, name, loaderName,
       
   296                                             params, signature);
       
   297         } catch (IOException x) {
       
   298             throw wrapIOException(x,"createMBean");
       
   299         }
       
   300     }
       
   301 
       
   302     /**
       
   303      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   304      * be changed by subclasses.
       
   305      * @deprecated see {@link MBeanServer#deserialize(ObjectName,byte[])
       
   306      *                 MBeanServer}
       
   307      */
       
   308     @Deprecated
       
   309     public ObjectInputStream deserialize(ObjectName name, byte[] data)
       
   310         throws InstanceNotFoundException, OperationsException {
       
   311         throw new UnsupportedOperationException("deserialize");
       
   312     }
       
   313 
       
   314     /**
       
   315      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   316      * be changed by subclasses.
       
   317      * @deprecated see {@link MBeanServer#deserialize(String,byte[])
       
   318      *                 MBeanServer}
       
   319      */
       
   320     @Deprecated
       
   321     public ObjectInputStream deserialize(String className, byte[] data)
       
   322         throws OperationsException, ReflectionException {
       
   323         throw new UnsupportedOperationException("deserialize");
       
   324     }
       
   325 
       
   326     /**
       
   327      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   328      * be changed by subclasses.
       
   329      * @deprecated see {@link MBeanServer#deserialize(String,ObjectName,byte[])
       
   330      *                 MBeanServer}
       
   331      */
       
   332     @Deprecated
       
   333     public ObjectInputStream deserialize(String className,
       
   334                                          ObjectName loaderName,
       
   335                                          byte[] data)
       
   336         throws
       
   337         InstanceNotFoundException,
       
   338         OperationsException,
       
   339         ReflectionException {
       
   340         throw new UnsupportedOperationException("deserialize");
       
   341     }
       
   342 
       
   343     /**
       
   344      * Forward this method to the
       
   345      * wrapped object.
       
   346      */
       
   347     public Object getAttribute(ObjectName name, String attribute)
       
   348         throws
       
   349         MBeanException,
       
   350         AttributeNotFoundException,
       
   351         InstanceNotFoundException,
       
   352         ReflectionException {
       
   353         try {
       
   354             return connection().getAttribute(name, attribute);
       
   355         } catch (IOException x) {
       
   356             throw wrapIOException(x,"getAttribute");
       
   357         }
       
   358     }
       
   359 
       
   360     /**
       
   361      * Forward this method to the
       
   362      * wrapped object.
       
   363      */
       
   364     public AttributeList getAttributes(ObjectName name, String[] attributes)
       
   365         throws InstanceNotFoundException, ReflectionException {
       
   366         try {
       
   367             return connection().getAttributes(name, attributes);
       
   368         } catch (IOException x) {
       
   369             throw wrapIOException(x,"getAttributes");
       
   370         }
       
   371     }
       
   372 
       
   373     /**
       
   374      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   375      * be changed by subclasses.
       
   376      */
       
   377     public ClassLoader getClassLoader(ObjectName loaderName)
       
   378         throws InstanceNotFoundException {
       
   379         throw new UnsupportedOperationException("getClassLoader");
       
   380     }
       
   381 
       
   382     /**
       
   383      * Returns the {@linkplain #getDefaultClassLoader() default class loader}.
       
   384      * This behavior can be changed by subclasses.
       
   385      */
       
   386     public ClassLoader getClassLoaderFor(ObjectName mbeanName)
       
   387         throws InstanceNotFoundException {
       
   388         return getDefaultClassLoader();
       
   389     }
       
   390 
       
   391     /**
       
   392      * <p>Returns a {@link ClassLoaderRepository} based on the class loader
       
   393      * returned by {@link #getDefaultClassLoader()}.</p>
       
   394      * @return a {@link ClassLoaderRepository} that contains a single
       
   395      *         class loader, returned by {@link #getDefaultClassLoader()}.
       
   396      **/
       
   397     public ClassLoaderRepository getClassLoaderRepository() {
       
   398         // We return a new ClassLoaderRepository each time this method is
       
   399         // called. This is by design, because there's no guarantee that
       
   400         // getDefaultClassLoader() will always return the same class loader.
       
   401         return Util.getSingleClassLoaderRepository(getDefaultClassLoader());
       
   402     }
       
   403 
       
   404     /**
       
   405      * Forward this method to the
       
   406      * wrapped object.
       
   407      */
       
   408     public String getDefaultDomain() {
       
   409         try {
       
   410             return connection().getDefaultDomain();
       
   411         } catch (IOException x) {
       
   412             throw wrapIOException(x,"getDefaultDomain");
       
   413         }
       
   414     }
       
   415 
       
   416     /**
       
   417      * Forward this method to the
       
   418      * wrapped object.
       
   419      */
       
   420     public String[] getDomains() {
       
   421         try {
       
   422             return connection().getDomains();
       
   423         } catch (IOException x) {
       
   424             throw wrapIOException(x,"getDomains");
       
   425         }
       
   426     }
       
   427 
       
   428     /**
       
   429      * Forward this method to the
       
   430      * wrapped object.
       
   431      */
       
   432     public Integer getMBeanCount() {
       
   433         try {
       
   434             return connection().getMBeanCount();
       
   435         } catch (IOException x) {
       
   436             throw wrapIOException(x,"getMBeanCount");
       
   437         }
       
   438     }
       
   439 
       
   440     /**
       
   441      * Forward this method to the
       
   442      * wrapped object.
       
   443      */
       
   444     public MBeanInfo getMBeanInfo(ObjectName name)
       
   445         throws
       
   446         InstanceNotFoundException,
       
   447         IntrospectionException,
       
   448         ReflectionException {
       
   449         try {
       
   450             return connection().getMBeanInfo(name);
       
   451         } catch (IOException x) {
       
   452             throw wrapIOException(x,"getMBeanInfo");
       
   453         }
       
   454     }
       
   455 
       
   456     /**
       
   457      * Forward this method to the
       
   458      * wrapped object.
       
   459      */
       
   460     public ObjectInstance getObjectInstance(ObjectName name)
       
   461         throws InstanceNotFoundException {
       
   462         try {
       
   463             return connection().getObjectInstance(name);
       
   464         } catch (IOException x) {
       
   465             throw wrapIOException(x,"getObjectInstance");
       
   466         }
       
   467     }
       
   468 
       
   469     /**
       
   470      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   471      * be changed by subclasses.
       
   472      */
       
   473     public Object instantiate(String className)
       
   474         throws ReflectionException, MBeanException {
       
   475         throw new UnsupportedOperationException("instantiate");
       
   476     }
       
   477 
       
   478     /**
       
   479      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   480      * be changed by subclasses.
       
   481      */
       
   482     public Object instantiate(String className,
       
   483                               Object params[],
       
   484                               String signature[])
       
   485         throws ReflectionException, MBeanException {
       
   486         throw new UnsupportedOperationException("instantiate");
       
   487     }
       
   488 
       
   489     /**
       
   490      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   491      * be changed by subclasses.
       
   492      */
       
   493     public Object instantiate(String className, ObjectName loaderName)
       
   494         throws ReflectionException, MBeanException,
       
   495                InstanceNotFoundException {
       
   496         throw new UnsupportedOperationException("instantiate");
       
   497     }
       
   498 
       
   499     /**
       
   500      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   501      * be changed by subclasses.
       
   502      */
       
   503     public Object instantiate(String className, ObjectName loaderName,
       
   504                               Object params[], String signature[])
       
   505         throws ReflectionException, MBeanException,
       
   506                InstanceNotFoundException {
       
   507         throw new UnsupportedOperationException("instantiate");
       
   508     }
       
   509 
       
   510     /**
       
   511      * Forward this method to the
       
   512      * wrapped object.
       
   513      */
       
   514     public Object invoke(ObjectName name, String operationName,
       
   515                          Object params[], String signature[])
       
   516         throws
       
   517         InstanceNotFoundException,
       
   518         MBeanException,
       
   519         ReflectionException {
       
   520         try {
       
   521             return connection().invoke(name,operationName,params,signature);
       
   522         } catch (IOException x) {
       
   523             throw wrapIOException(x,"invoke");
       
   524         }
       
   525     }
       
   526 
       
   527     /**
       
   528      * Forward this method to the
       
   529      * wrapped object.
       
   530      */
       
   531     public boolean isInstanceOf(ObjectName name, String className)
       
   532         throws InstanceNotFoundException {
       
   533         try {
       
   534             return connection().isInstanceOf(name, className);
       
   535         } catch (IOException x) {
       
   536             throw wrapIOException(x,"isInstanceOf");
       
   537         }
       
   538     }
       
   539 
       
   540     /**
       
   541      * Forward this method to the
       
   542      * wrapped object.
       
   543      */
       
   544     public boolean isRegistered(ObjectName name) {
       
   545         try {
       
   546             return connection().isRegistered(name);
       
   547         } catch (IOException x) {
       
   548             throw wrapIOException(x,"isRegistered");
       
   549         }
       
   550     }
       
   551 
       
   552     /**
       
   553      * Forward this method to the
       
   554      * wrapped object.
       
   555      * If an IOException is raised, returns an empty Set.
       
   556      */
       
   557     public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
       
   558         try {
       
   559             return connection().queryMBeans(name, query);
       
   560         } catch (IOException x) {
       
   561             throw wrapIOException(x,"queryMBeans");
       
   562             //return Collections.emptySet();
       
   563         }
       
   564     }
       
   565 
       
   566     /**
       
   567      * Forward this method to the
       
   568      * wrapped object.
       
   569      * If an IOException is raised, returns an empty Set.
       
   570      */
       
   571     public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
       
   572         try {
       
   573             return connection().queryNames(name, query);
       
   574         } catch (IOException x) {
       
   575             throw wrapIOException(x,"queryNames");
       
   576             //return Collections.emptySet();
       
   577         }
       
   578     }
       
   579 
       
   580     /**
       
   581      * Throws an {@link UnsupportedOperationException}. This behavior can
       
   582      * be changed by subclasses.
       
   583      */
       
   584     public ObjectInstance registerMBean(Object object, ObjectName name)
       
   585         throws
       
   586         InstanceAlreadyExistsException,
       
   587         MBeanRegistrationException,
       
   588         NotCompliantMBeanException {
       
   589         throw new UnsupportedOperationException("registerMBean");
       
   590     }
       
   591 
       
   592     /**
       
   593      * Forward this method to the
       
   594      * wrapped object.
       
   595      */
       
   596     public void removeNotificationListener(ObjectName name,
       
   597                                            NotificationListener listener)
       
   598         throws InstanceNotFoundException, ListenerNotFoundException {
       
   599         try {
       
   600             connection().removeNotificationListener(name, listener);
       
   601         } catch (IOException x) {
       
   602             throw wrapIOException(x,"removeNotificationListener");
       
   603         }
       
   604     }
       
   605 
       
   606     /**
       
   607      * Forward this method to the
       
   608      * wrapped object.
       
   609      */
       
   610     public void removeNotificationListener(ObjectName name,
       
   611                                            NotificationListener listener,
       
   612                                            NotificationFilter filter,
       
   613                                            Object handback)
       
   614         throws InstanceNotFoundException, ListenerNotFoundException {
       
   615         try {
       
   616             connection().removeNotificationListener(name, listener,
       
   617                                                     filter, handback);
       
   618         } catch (IOException x) {
       
   619             throw wrapIOException(x,"removeNotificationListener");
       
   620         }
       
   621     }
       
   622 
       
   623     /**
       
   624      * Forward this method to the
       
   625      * wrapped object.
       
   626      */
       
   627     public void removeNotificationListener(ObjectName name,
       
   628                                            ObjectName listener)
       
   629         throws InstanceNotFoundException, ListenerNotFoundException {
       
   630         try {
       
   631             connection().removeNotificationListener(name, listener);
       
   632         } catch (IOException x) {
       
   633             throw wrapIOException(x,"removeNotificationListener");
       
   634         }
       
   635     }
       
   636 
       
   637     /**
       
   638      * Forward this method to the
       
   639      * wrapped object.
       
   640      */
       
   641     public void removeNotificationListener(ObjectName name,
       
   642                                            ObjectName listener,
       
   643                                            NotificationFilter filter,
       
   644                                            Object handback)
       
   645         throws InstanceNotFoundException, ListenerNotFoundException {
       
   646         try {
       
   647             connection().removeNotificationListener(name, listener,
       
   648                                                     filter, handback);
       
   649         } catch (IOException x) {
       
   650             throw wrapIOException(x,"removeNotificationListener");
       
   651         }
       
   652     }
       
   653 
       
   654     /**
       
   655      * Forward this method to the
       
   656      * wrapped object.
       
   657      */
       
   658     public void setAttribute(ObjectName name, Attribute attribute)
       
   659         throws
       
   660         InstanceNotFoundException,
       
   661         AttributeNotFoundException,
       
   662         InvalidAttributeValueException,
       
   663         MBeanException,
       
   664         ReflectionException {
       
   665         try {
       
   666             connection().setAttribute(name, attribute);
       
   667         } catch (IOException x) {
       
   668             throw wrapIOException(x,"setAttribute");
       
   669         }
       
   670     }
       
   671 
       
   672     /**
       
   673      * Forward this method to the
       
   674      * wrapped object.
       
   675      */
       
   676     public AttributeList setAttributes(ObjectName name,
       
   677                                        AttributeList attributes)
       
   678         throws InstanceNotFoundException, ReflectionException {
       
   679         try {
       
   680             return connection().setAttributes(name, attributes);
       
   681         } catch (IOException x) {
       
   682             throw wrapIOException(x,"setAttributes");
       
   683         }
       
   684     }
       
   685 
       
   686     /**
       
   687      * Forward this method to the
       
   688      * wrapped object.
       
   689      */
       
   690     public void unregisterMBean(ObjectName name)
       
   691         throws InstanceNotFoundException, MBeanRegistrationException {
       
   692         try {
       
   693             connection().unregisterMBean(name);
       
   694         } catch (IOException x) {
       
   695             throw wrapIOException(x,"unregisterMBean");
       
   696         }
       
   697     }
       
   698 
       
   699     //----------------
       
   700     // PRIVATE METHODS
       
   701     //----------------
       
   702 
       
   703 }