src/java.management/share/classes/javax/management/MBeanRegistration.java
author darcy
Wed, 23 Oct 2019 13:01:40 -0700
changeset 58766 54ffb15c4839
parent 47216 71c04702a3d5
permissions -rw-r--r--
8232442: Suppress warnings on non-serializable non-transient instance fields in java.management.* Reviewed-by: rriggs, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     2
 * Copyright (c) 1999, 2008, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    23
 * questions.
2
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
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public interface MBeanRegistration   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     * Allows the MBean to perform any operations it needs before
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    43
     * being registered in the MBean Server.  If the name of the MBean
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * is not specified, the MBean can provide a name for its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * registration.  If any exception is raised, the MBean will not be
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    46
     * registered in the MBean Server.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     *
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    48
     * @param server The MBean Server in which the MBean will be registered.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * @param name The object name of the MBean.  This name is null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * the name parameter to one of the <code>createMBean</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * <code>registerMBean</code> methods in the {@link MBeanServer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * interface is null.  In that case, this method must return a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * non-null ObjectName for the new MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * @return The name under which the MBean is to be registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * This value must not be null.  If the <code>name</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * parameter is not null, it will usually but not necessarily be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * the returned value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @exception java.lang.Exception This exception will be caught by
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    62
     * the MBean Server and re-thrown as an {@link
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * MBeanRegistrationException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public ObjectName preRegister(MBeanServer server,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                                  ObjectName name) throws java.lang.Exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Allows the MBean to perform any operations needed after having been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * 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
    71
     * <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
    72
     * 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
    73
     * a {@link RuntimeMBeanException} or {@link RuntimeErrorException},
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
    74
     * respectively. However, throwing an exception in {@code postRegister}
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
    75
     * will not change the state of the MBean:
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
    76
     * 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
    77
     * {@code true}), the MBean will remain registered. </p>
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
    78
     * <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
    79
     * 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
    80
     * 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
    81
     * Therefore it is recommended that implementations of
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
    82
     * {@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
    83
     * can be avoided.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param registrationDone Indicates whether or not the MBean has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * been successfully registered in the MBean server. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * false means that the registration phase has failed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public void postRegister(Boolean registrationDone);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * Allows the MBean to perform any operations it needs before
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * being unregistered by the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @exception java.lang.Exception This exception will be caught by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * the MBean server and re-thrown as an {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * MBeanRegistrationException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public void preDeregister() throws java.lang.Exception ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Allows the MBean to perform any operations needed after having been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * unregistered in the MBean server.
1002
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   103
     * <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
   104
     * 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
   105
     * a {@link RuntimeMBeanException} or {@link RuntimeErrorException},
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1705
diff changeset
   106
     * respectively. However, throwing an exception in {@code postDeregister}
1002
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   107
     * will not change the state of the MBean:
1e6a1b77f22a 6730926: Document that create/registerMBean can throw RuntimeMBeanException from postRegister
dfuchs
parents: 833
diff changeset
   108
     * 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
   109
     * <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
   110
     * {@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
   111
     * 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
   112
     * {@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
   113
     * can be avoided.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public void postDeregister();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 }