jdk/src/share/classes/javax/management/MBeanRegistration.java
author emcmanus
Tue, 09 Dec 2008 18:30:27 +0100
changeset 1705 08644ea24ce6
parent 1247 b4c26443dee5
child 4156 acaa49a2768a
permissions -rw-r--r--
6780803: Wrong parameter name in description of EventClient::addListeners() 6470295: Misleading exception message says context classloader when it isn't 6714954: Description of MBeanPermission checking in MBeanServer javadoc is inaccurate 6732037: Event Service spec needs more detail about Executor use 6740900: Specify that listeners invoked via SendNotification should not block 6778436: Typo in @NotificationInfos spec Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1247
b4c26443dee5 6754988: Update copyright year
xdono
parents: 1002
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    30
 * <p>Can be implemented by an MBean in order to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * carry out operations before and after being registered or unregistered from
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    32
 * the MBean Server.  An MBean can also implement this interface in order
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    33
 * to get a reference to the MBean Server and/or its name within that
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    34
 * MBean Server.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    35
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    36
 * <h4 id="injection">Resource injection</h4>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    37
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    38
 * <p>As an alternative to implementing {@code MBeanRegistration}, if all that
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    39
 * is needed is the MBean Server or ObjectName then an MBean can use
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    40
 * <em>resource injection</em>.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    41
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    42
 * <p>If a field in the MBean object has type {@link ObjectName} and has
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    43
 * the {@link javax.annotation.Resource &#64;Resource} annotation,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    44
 * then the {@code ObjectName} under which the MBean is registered is
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    45
 * assigned to that field during registration.  Likewise, if a field has type
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    46
 * {@link MBeanServer} and the <code>&#64;Resource</code> annotation, then it will
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    47
 * be set to the {@code MBeanServer} in which the MBean is registered.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    48
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    49
 * <p>For example:</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    50
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    51
 * <pre>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    52
 * public Configuration implements ConfigurationMBean {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    53
 *     &#64;Resource
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    54
 *     private volatile MBeanServer mbeanServer;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    55
 *     &#64;Resource
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    56
 *     private volatile ObjectName objectName;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    57
 *     ...
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    58
 *     void unregisterSelf() throws Exception {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    59
 *         mbeanServer.unregisterMBean(objectName);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    60
 *     }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    61
 * }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    62
 * </pre>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    63
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    64
 * <p>Resource injection can also be used on fields of type
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    65
 * {@link SendNotification} to simplify notification sending.  Such a field
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    66
 * will get a reference to an object of type {@code SendNotification} when
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    67
 * the MBean is registered, and it can use this reference to send notifications.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    68
 * For example:</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    69
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    70
 * <pre>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    71
 * public Configuration implements ConfigurationMBean {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    72
 *     &#64;Resource
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    73
 *     private volatile SendNotification sender;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    74
 *     ...
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    75
 *     private void updated() {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    76
 *         Notification n = new Notification(...);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    77
 *         sender.sendNotification(n);
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    78
 *     }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    79
 * }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    80
 * </pre>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    81
 *
1705
08644ea24ce6 6780803: Wrong parameter name in description of EventClient::addListeners()
emcmanus
parents: 1247
diff changeset
    82
 * <p>(Listeners may be invoked in the same thread as the caller of
08644ea24ce6 6780803: Wrong parameter name in description of EventClient::addListeners()
emcmanus
parents: 1247
diff changeset
    83
 * {@code sender.sendNotification}.)</p>
08644ea24ce6 6780803: Wrong parameter name in description of EventClient::addListeners()
emcmanus
parents: 1247
diff changeset
    84
 *
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    85
 * <p>A field to be injected must not be static.  It is recommended that
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    86
 * such fields be declared {@code volatile}.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    87
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    88
 * <p>It is also possible to use the <code>&#64;Resource</code> annotation on
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    89
 * methods. Such a method must have a {@code void} return type and a single
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    90
 * argument of the appropriate type, for example {@code ObjectName}.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    91
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    92
 * <p>Any number of fields and methods may have the <code>&#64;Resource</code>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    93
 * annotation.  All fields and methods with type {@code ObjectName}
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    94
 * (for example) will receive the same {@code ObjectName} value.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    95
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    96
 * <p>Resource injection is available for all types of MBeans, not just
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    97
 * Standard MBeans.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    98
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    99
 * <p>If an MBean implements the {@link DynamicWrapperMBean} interface then
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   100
 * resource injection happens on the object returned by that interface's
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   101
 * {@link DynamicWrapperMBean#getWrappedObject() getWrappedObject()} method
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   102
 * rather than on the MBean object itself.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   103
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   104
 * <p>Resource injection happens after the {@link #preRegister preRegister}
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   105
 * method is called (if any), and before the MBean is actually registered
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   106
 * in the MBean Server. If a <code>&#64;Resource</code> method throws
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   107
 * an exception, the effect is the same as if {@code preRegister} had
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   108
 * thrown the exception. In particular it will prevent the MBean from being
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   109
 * registered.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   110
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   111
 * <p>Resource injection can be used on a field or method where the type
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   112
 * is a parent of the injected type, if the injected type is explicitly
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   113
 * specified in the <code>&#64;Resource</code> annotation.  For example:</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   114
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   115
 * <pre>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   116
 *     &#64;Resource(type = MBeanServer.class)
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   117
 *     private volatile MBeanServerConnection mbsc;
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   118
 * </pre>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   119
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   120
 * <p>Formally, suppose <em>R</em> is the type in the <code>&#64;Resource</code>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   121
 * annotation and <em>T</em> is the type of the method parameter or field.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   122
 * Then one of <em>R</em> and <em>T</em> must be a subtype of the other
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   123
 * (or they must be the same type).  Injection happens if this subtype
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   124
 * is {@code MBeanServer}, {@code ObjectName}, or {@code SendNotification}.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   125
 * Otherwise the <code>&#64;Resource</code> annotation is ignored.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   126
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   127
 * <p>Resource injection in MBeans is new in version 2.0 of the JMX API.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
public interface MBeanRegistration   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Allows the MBean to perform any operations it needs before
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   136
     * being registered in the MBean Server.  If the name of the MBean
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * is not specified, the MBean can provide a name for its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * registration.  If any exception is raised, the MBean will not be
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   139
     * registered in the MBean Server.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   141
     * @param server The MBean Server in which the MBean will be registered.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @param name The object name of the MBean.  This name is null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * the name parameter to one of the <code>createMBean</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <code>registerMBean</code> methods in the {@link MBeanServer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * interface is null.  In that case, this method must return a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * non-null ObjectName for the new MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @return The name under which the MBean is to be registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * This value must not be null.  If the <code>name</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * parameter is not null, it will usually but not necessarily be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * the returned value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @exception java.lang.Exception This exception will be caught by
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
   155
     * the MBean Server and re-thrown as an {@link
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * MBeanRegistrationException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public ObjectName preRegister(MBeanServer server,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                                  ObjectName name) throws java.lang.Exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Allows the MBean to perform any operations needed after having been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * registered in the MBean server or after the registration has failed.
1002
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   164
     * <p>If the implementation of this method throws a {@link RuntimeException}
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   165
     * or an {@link Error}, the MBean Server will rethrow those inside
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   166
     * a {@link RuntimeMBeanException} or {@link RuntimeErrorException},
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   167
     * respectively. However, throwing an exception in {@code postRegister}
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   168
     * will not change the state of the MBean:
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   169
     * if the MBean was already registered ({@code registrationDone} is
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   170
     * {@code true}), the MBean will remain registered. </p>
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   171
     * <p>This might be confusing for the code calling {@code createMBean()}
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   172
     * or {@code registerMBean()}, as such code might assume that MBean
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   173
     * registration has failed when such an exception is raised.
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   174
     * Therefore it is recommended that implementations of
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   175
     * {@code postRegister} do not throw Runtime Exceptions or Errors if it
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   176
     * can be avoided.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @param registrationDone Indicates whether or not the MBean has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * been successfully registered in the MBean server. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * false means that the registration phase has failed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public void postRegister(Boolean registrationDone);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Allows the MBean to perform any operations it needs before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * being unregistered by the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @exception java.lang.Exception This exception will be caught by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * the MBean server and re-thrown as an {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * MBeanRegistrationException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public void preDeregister() throws java.lang.Exception ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Allows the MBean to perform any operations needed after having been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * unregistered in the MBean server.
1002
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   196
     * <p>If the implementation of this method throws a {@link RuntimeException}
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   197
     * or an {@link Error}, the MBean Server will rethrow those inside
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   198
     * a {@link RuntimeMBeanException} or {@link RuntimeErrorException},
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   199
     * respectively. However, throwing an excepption in {@code postDeregister}
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   200
     * will not change the state of the MBean:
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   201
     * the MBean was already successfully deregistered and will remain so. </p>
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   202
     * <p>This might be confusing for the code calling
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   203
     * {@code unregisterMBean()}, as it might assume that MBean deregistration
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   204
     * has failed. Therefore it is recommended that implementations of
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   205
     * {@code postDeregister} do not throw Runtime Exceptions or Errors if it
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   206
     * can be avoided.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    public void postDeregister();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
 }