author | emcmanus |
Wed, 21 Oct 2009 17:33:18 +0200 | |
changeset 4156 | acaa49a2768a |
parent 715 | f16baef3a20e |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2 | 1 |
/* |
715 | 2 |
* Copyright 1999-2008 Sun Microsystems, Inc. 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 |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
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 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package javax.management; |
|
27 |
||
28 |
// java import |
|
29 |
import java.io.Serializable; |
|
30 |
||
31 |
/** |
|
32 |
* Allows a query to be performed in the context of a specific MBean server. |
|
33 |
* |
|
34 |
* @since 1.5 |
|
35 |
*/ |
|
471
422ff0db58d3
6692027: Custom subclasses of QueryEval don't serialize
emcmanus
parents:
34
diff
changeset
|
36 |
public abstract class QueryEval implements Serializable { |
2 | 37 |
|
38 |
/* Serial version */ |
|
39 |
private static final long serialVersionUID = 2675899265640874796L; |
|
40 |
||
41 |
private static ThreadLocal<MBeanServer> server = |
|
42 |
new InheritableThreadLocal<MBeanServer>(); |
|
43 |
||
44 |
/** |
|
45 |
* <p>Sets the MBean server on which the query is to be performed. |
|
46 |
* The setting is valid for the thread performing the set. |
|
47 |
* It is copied to any threads created by that thread at the moment |
|
48 |
* of their creation.</p> |
|
49 |
* |
|
50 |
* <p>For historical reasons, this method is not static, but its |
|
51 |
* behavior does not depend on the instance on which it is |
|
52 |
* called.</p> |
|
53 |
* |
|
54 |
* @param s The MBean server on which the query is to be performed. |
|
55 |
* |
|
56 |
* @see #getMBeanServer |
|
57 |
*/ |
|
58 |
public void setMBeanServer(MBeanServer s) { |
|
59 |
server.set(s); |
|
60 |
} |
|
61 |
||
62 |
/** |
|
63 |
* <p>Return the MBean server that was most recently given to the |
|
64 |
* {@link #setMBeanServer setMBeanServer} method by this thread. |
|
65 |
* If this thread never called that method, the result is the |
|
66 |
* value its parent thread would have obtained from |
|
67 |
* <code>getMBeanServer</code> at the moment of the creation of |
|
68 |
* this thread, or null if there is no parent thread.</p> |
|
69 |
* |
|
70 |
* @return the MBean server. |
|
71 |
* |
|
72 |
* @see #setMBeanServer |
|
73 |
* |
|
74 |
*/ |
|
75 |
public static MBeanServer getMBeanServer() { |
|
76 |
return server.get(); |
|
77 |
} |
|
78 |
} |