001 /*
002 * Portions Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 /*
026 * @(#)author IBM Corp.
027 *
028 * Copyright IBM Corp. 1999-2000. All rights reserved.
029 */
030
031 package javax.management.modelmbean;
032
033 import javax.management.DynamicMBean;
034 import javax.management.InstanceNotFoundException;
035 import javax.management.MBeanException;
036 import javax.management.PersistentMBean;
037 import javax.management.RuntimeOperationsException;
038
039 /**
040 * This interface must be implemented by the ModelMBeans. An implementation of this interface
041 * must be shipped with every JMX Agent.
042 * <P>
043 * Java resources wishing to be manageable instantiate the ModelMBean using the MBeanServer's
044 * createMBean method. The resource then sets the ModelMBeanInfo (with Descriptors) for the ModelMBean
045 * instance. The attributes and operations exposed via the ModelMBeanInfo for the ModelMBean are accessible
046 * from MBeans, connectors/adaptors like other MBeans. Through the ModelMBeanInfo Descriptors, values and methods in
047 * the managed application can be defined and mapped to attributes and operations of the ModelMBean.
048 * This mapping can be defined during development in an XML formatted file or dynamically and
049 * programmatically at runtime.
050 * <P>
051 * Every ModelMBean which is instantiated in the MBeanServer becomes manageable:
052 * its attributes and operations
053 * become remotely accessible through the connectors/adaptors connected to that MBeanServer.
054 * A Java object cannot be registered in the MBeanServer unless it is a JMX compliant MBean.
055 * By instantiating a ModelMBean, resources are guaranteed that the MBean is valid.
056 * <P>
057 * MBeanException and RuntimeOperationsException must be thrown on every public method. This allows
058 * for wrapping exceptions from distributed communications (RMI, EJB, etc.). These exceptions do
059 * not have to be thrown by the implementation except in the scenarios described in the specification
060 * and javadoc.
061 *
062 * @since 1.5
063 */
064
065 public interface ModelMBean extends DynamicMBean, PersistentMBean,
066 ModelMBeanNotificationBroadcaster {
067
068 /**
069 * Initializes a ModelMBean object using ModelMBeanInfo passed in.
070 * This method makes it possible to set a customized ModelMBeanInfo on
071 * the ModelMBean as long as it is not registered with the MBeanServer.
072 * <br>
073 * Once the ModelMBean's ModelMBeanInfo (with Descriptors) are
074 * customized and set on the ModelMBean, the ModelMBean can be
075 * registered with the MBeanServer.
076 * <P>
077 * If the ModelMBean is currently registered, this method throws
078 * a {@link javax.management.RuntimeOperationsException} wrapping an
079 * {@link IllegalStateException}
080 *
081 * @param inModelMBeanInfo The ModelMBeanInfo object to be used
082 * by the ModelMBean.
083 *
084 * @exception MBeanException Wraps a distributed communication
085 * Exception.
086 * @exception RuntimeOperationsException
087 * <ul><li>Wraps an {@link IllegalArgumentException} if
088 * the MBeanInfo passed in parameter is null.</li>
089 * <li>Wraps an {@link IllegalStateException} if the ModelMBean
090 * is currently registered in the MBeanServer.</li>
091 * </ul>
092 *
093 **/
094 public void setModelMBeanInfo(ModelMBeanInfo inModelMBeanInfo)
095 throws MBeanException, RuntimeOperationsException;
096
097 /**
098 * Sets the instance handle of the object against which to
099 * execute all methods in this ModelMBean management interface
100 * (MBeanInfo and Descriptors).
101 *
102 * @param mr Object that is the managed resource
103 * @param mr_type The type of reference for the managed resource. Can be: ObjectReference,
104 * Handle, IOR, EJBHandle, RMIReference.
105 * If the MBeanServer cannot process the mr_type passed in, an InvalidTargetTypeException
106 * will be thrown.
107 *
108 *
109 * @exception MBeanException The initializer of the object has thrown an exception.
110 * @exception RuntimeOperationsException Wraps an IllegalArgumentException:
111 * The managed resource type passed in parameter is null.
112 * @exception InstanceNotFoundException The managed resource object could not be found
113 * @exception InvalidTargetObjectTypeException The managed resource type cannot be processed by the
114 * ModelMBean or JMX Agent.
115 */
116 public void setManagedResource(Object mr, String mr_type)
117 throws MBeanException, RuntimeOperationsException,
118 InstanceNotFoundException, InvalidTargetObjectTypeException;
119
120 }
|