MBeanRegistration.java revision 2362
0N/A * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <p>Can be implemented by an MBean in order to 0N/A * carry out operations before and after being registered or unregistered from 0N/A * the MBean Server. An MBean can also implement this interface in order 0N/A * to get a reference to the MBean Server and/or its name within that 0N/A * Allows the MBean to perform any operations it needs before 0N/A * being registered in the MBean Server. If the name of the MBean 0N/A * is not specified, the MBean can provide a name for its 0N/A * registration. If any exception is raised, the MBean will not be 0N/A * registered in the MBean Server. 0N/A * @param server The MBean Server in which the MBean will be registered. 0N/A * @param name The object name of the MBean. This name is null if 0N/A * the name parameter to one of the <code>createMBean</code> or 0N/A * <code>registerMBean</code> methods in the {@link MBeanServer} 0N/A * interface is null. In that case, this method must return a 0N/A * non-null ObjectName for the new MBean. 0N/A * @return The name under which the MBean is to be registered. 0N/A * This value must not be null. If the <code>name</code> 0N/A * parameter is not null, it will usually but not necessarily be 0N/A * the returned value. 0N/A * @exception java.lang.Exception This exception will be caught by 0N/A * the MBean Server and re-thrown as an {@link 0N/A * MBeanRegistrationException}. 0N/A * Allows the MBean to perform any operations needed after having been 0N/A * registered in the MBean server or after the registration has failed. 0N/A * <p>If the implementation of this method throws a {@link RuntimeException} 0N/A * or an {@link Error}, the MBean Server will rethrow those inside 0N/A * a {@link RuntimeMBeanException} or {@link RuntimeErrorException}, 0N/A * respectively. However, throwing an exception in {@code postRegister} 0N/A * will not change the state of the MBean: 0N/A * if the MBean was already registered ({@code registrationDone} is 0N/A * {@code true}), the MBean will remain registered. </p> 0N/A * <p>This might be confusing for the code calling {@code createMBean()} 0N/A * or {@code registerMBean()}, as such code might assume that MBean 0N/A * registration has failed when such an exception is raised. 0N/A * Therefore it is recommended that implementations of 0N/A * {@code postRegister} do not throw Runtime Exceptions or Errors if it 0N/A * can be avoided.</p> 0N/A * @param registrationDone Indicates whether or not the MBean has 0N/A * been successfully registered in the MBean server. The value 0N/A * false means that the registration phase has failed. 0N/A * Allows the MBean to perform any operations it needs before 0N/A * being unregistered by the MBean server. 0N/A * @exception java.lang.Exception This exception will be caught by 0N/A * the MBean server and re-thrown as an {@link 0N/A * MBeanRegistrationException}. * Allows the MBean to perform any operations needed after having been * unregistered in the MBean server. * <p>If the implementation of this method throws a {@link RuntimeException} * or an {@link Error}, the MBean Server will rethrow those inside * a {@link RuntimeMBeanException} or {@link RuntimeErrorException}, * respectively. However, throwing an exception in {@code postDeregister} * will not change the state of the MBean: * the MBean was already successfully deregistered and will remain so. </p> * <p>This might be confusing for the code calling * {@code unregisterMBean()}, as it might assume that MBean deregistration * has failed. Therefore it is recommended that implementations of * {@code postDeregister} do not throw Runtime Exceptions or Errors if it