001/* DynamicMBean.java -- A management bean with a dynamic interface.
002   Copyright (C) 2006 Free Software Foundation, Inc.
003
004This file is part of GNU Classpath.
005
006GNU Classpath is free software; you can redistribute it and/or modify
007it under the terms of the GNU General Public License as published by
008the Free Software Foundation; either version 2, or (at your option)
009any later version.
010
011GNU Classpath is distributed in the hope that it will be useful, but
012WITHOUT ANY WARRANTY; without even the implied warranty of
013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014General Public License for more details.
015
016You should have received a copy of the GNU General Public License
017along with GNU Classpath; see the file COPYING.  If not, write to the
018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
01902110-1301 USA.
020
021Linking this library statically or dynamically with other modules is
022making a combined work based on this library.  Thus, the terms and
023conditions of the GNU General Public License cover the whole
024combination.
025
026As a special exception, the copyright holders of this library give you
027permission to link this library with independent modules to produce an
028executable, regardless of the license terms of these independent
029modules, and to copy and distribute the resulting executable under
030terms of your choice, provided that you also meet, for each linked
031independent module, the terms and conditions of the license of that
032module.  An independent module is a module which is not derived from
033or based on this library.  If you modify this library, you may extend
034this exception to your version of the library, but you are not
035obligated to do so.  If you do not wish to do so, delete this
036exception statement from your version. */
037
038package javax.management;
039
040/**
041 * Represents a management bean that provides a
042 * dynamic interface.  Users of a {@link DynamicMBean}
043 * may retrieve information about its attributes at
044 * runtime and use this information to dynamically
045 * obtain the corresponding values of these attributes.
046 *
047 * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
048 * @since 1.5
049 */
050public interface DynamicMBean
051{
052  
053  /**
054   * Obtains the value of the specified attribute of the
055   * management bean.  The management bean should perform
056   * a lookup for the named attribute, and return its value
057   * by calling the appropriate getter method, if possible.
058   *
059   * @param name the name of the attribute to retrieve.
060   * @return the value of the specified attribute.
061   * @throws AttributeNotFoundException if the name does not
062   *                                    correspond to an attribute
063   *                                    of the bean.
064   * @throws MBeanException if retrieving the attribute causes
065   *                        the bean to throw an exception (which
066   *                        becomes the cause of this exception).
067   * @throws ReflectionException if an exception occurred in trying
068   *                             to use the reflection interface
069   *                             to lookup the attribute.  The
070   *                             thrown exception is the cause of
071   *                             this exception.
072   * @see #setAttribute(String)
073   */
074  Object getAttribute(String name)
075    throws AttributeNotFoundException, MBeanException,
076           ReflectionException;
077
078  /**
079   * Obtains the values of each of the specified attributes
080   * of the management bean.  The returned list includes
081   * those attributes that were retrieved and their
082   * corresponding values.
083   *
084   * @param names the names of the attributes to retrieve.
085   * @return a list of the retrieved attributes.
086   * @see #setAttributes(AttributeList)
087   */
088  AttributeList getAttributes(String[] names);
089
090  /**
091   * Returns an information object which lists the attributes
092   * and actions associated with the management bean.
093   *
094   * @return a description of the management bean, including
095   *         all exposed attributes and actions.
096   */
097  MBeanInfo getMBeanInfo();
098
099  /**
100   * Invokes the specified action on the management bean using
101   * the supplied parameters.  The signature of the action is
102   * specified by a {@link String} array, which lists the classes
103   * corresponding to each parameter.  The class loader used to
104   * load these classes is the same as that used for loading the
105   * management bean itself.
106   * 
107   * @param name the name of the action to invoke.
108   * @param params the parameters used to call the action.
109   * @param signature the signature of the action.
110   * @return the return value of the action.
111   * @throws MBeanException if the action throws an exception.  The
112   *                        thrown exception is the cause of this
113   *                        exception.
114   * @throws ReflectionException if an exception occurred in trying
115   *                             to use the reflection interface
116   *                             to invoke the action.  The
117   *                             thrown exception is the cause of
118   *                             this exception.
119   */
120  Object invoke(String name, Object[] params, String[] signature)
121    throws MBeanException, ReflectionException;
122
123  /**
124   * Sets the value of the specified attribute of the
125   * management bean.  The management bean should perform
126   * a lookup for the named attribute, and sets its value
127   * using the associated setter method, if possible.
128   *
129   * @param attribute the attribute to set.
130   * @throws AttributeNotFoundException if the attribute does not
131   *                                    correspond to an attribute
132   *                                    of the bean.
133   * @throws InvalidAttributeValueException if the value is invalid
134   *                                        for this particular
135   *                                        attribute of the bean.
136   * @throws MBeanException if setting the attribute causes
137   *                        the bean to throw an exception (which
138   *                        becomes the cause of this exception).
139   * @throws ReflectionException if an exception occurred in trying
140   *                             to use the reflection interface
141   *                             to lookup the attribute.  The
142   *                             thrown exception is the cause of
143   *                             this exception.
144   * @see #getAttribute(String)
145   */
146  void setAttribute(Attribute attribute)
147    throws AttributeNotFoundException, InvalidAttributeValueException,
148           MBeanException, ReflectionException;
149
150  /**
151   * Sets the value of each of the specified attributes
152   * to that supplied by the {@link Attribute} object.
153   * The returned list contains the attributes that were
154   * set and their new values.
155   *
156   * @param attributes the attributes to set.
157   * @return a list of the changed attributes.
158   * @see #getAttributes(AttributeList)
159   */
160  AttributeList setAttributes(AttributeList attributes);
161
162}