author | jmasa |
Fri, 08 Apr 2011 14:53:16 -0700 | |
changeset 9180 | 987b51bab2e2 |
parent 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.management; |
|
27 |
||
28 |
||
29 |
/** |
|
833 | 30 |
* <p>Can be implemented by an MBean in order to |
2 | 31 |
* carry out operations before and after being registered or unregistered from |
833 | 32 |
* the MBean Server. An MBean can also implement this interface in order |
33 |
* to get a reference to the MBean Server and/or its name within that |
|
34 |
* MBean Server.</p> |
|
35 |
* |
|
2 | 36 |
* @since 1.5 |
37 |
*/ |
|
38 |
public interface MBeanRegistration { |
|
39 |
||
40 |
||
41 |
/** |
|
42 |
* Allows the MBean to perform any operations it needs before |
|
833 | 43 |
* being registered in the MBean Server. If the name of the MBean |
2 | 44 |
* is not specified, the MBean can provide a name for its |
45 |
* registration. If any exception is raised, the MBean will not be |
|
833 | 46 |
* registered in the MBean Server. |
2 | 47 |
* |
833 | 48 |
* @param server The MBean Server in which the MBean will be registered. |
2 | 49 |
* |
50 |
* @param name The object name of the MBean. This name is null if |
|
51 |
* the name parameter to one of the <code>createMBean</code> or |
|
52 |
* <code>registerMBean</code> methods in the {@link MBeanServer} |
|
53 |
* interface is null. In that case, this method must return a |
|
54 |
* non-null ObjectName for the new MBean. |
|
55 |
* |
|
56 |
* @return The name under which the MBean is to be registered. |
|
57 |
* This value must not be null. If the <code>name</code> |
|
58 |
* parameter is not null, it will usually but not necessarily be |
|
59 |
* the returned value. |
|
60 |
* |
|
61 |
* @exception java.lang.Exception This exception will be caught by |
|
833 | 62 |
* the MBean Server and re-thrown as an {@link |
2 | 63 |
* MBeanRegistrationException}. |
64 |
*/ |
|
65 |
public ObjectName preRegister(MBeanServer server, |
|
66 |
ObjectName name) throws java.lang.Exception; |
|
67 |
||
68 |
/** |
|
69 |
* Allows the MBean to perform any operations needed after having been |
|
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 | 84 |
* @param registrationDone Indicates whether or not the MBean has |
85 |
* been successfully registered in the MBean server. The value |
|
86 |
* false means that the registration phase has failed. |
|
87 |
*/ |
|
88 |
public void postRegister(Boolean registrationDone); |
|
89 |
||
90 |
/** |
|
91 |
* Allows the MBean to perform any operations it needs before |
|
92 |
* being unregistered by the MBean server. |
|
93 |
* |
|
94 |
* @exception java.lang.Exception This exception will be caught by |
|
95 |
* the MBean server and re-thrown as an {@link |
|
96 |
* MBeanRegistrationException}. |
|
97 |
*/ |
|
98 |
public void preDeregister() throws java.lang.Exception ; |
|
99 |
||
100 |
/** |
|
101 |
* Allows the MBean to perform any operations needed after having been |
|
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 | 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 | 114 |
*/ |
115 |
public void postDeregister(); |
|
116 |
||
117 |
} |