KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > QueryEval


1 /*
2  * @(#)QueryEval.java 4.24 04/02/10
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.management;
9
10
11 // java import
12
import java.io.Serializable JavaDoc;
13
14 // RI import
15
import javax.management.MBeanServer JavaDoc;
16
17
18 /**
19  * Allows a query to be performed in the context of a specific MBean server.
20  *
21  * @since 1.5
22  */

23 public abstract class QueryEval implements Serializable JavaDoc {
24     
25     /* Serial version */
26     private static final long serialVersionUID = 2675899265640874796L;
27
28     private static ThreadLocal JavaDoc server = new InheritableThreadLocal JavaDoc();
29     
30     /**
31      * <p>Sets the MBean server on which the query is to be performed.
32      * The setting is valid for the thread performing the set.
33      * It is copied to any threads created by that thread at the moment
34      * of their creation.</p>
35      *
36      * <p>For historical reasons, this method is not static, but its
37      * behavior does not depend on the instance on which it is
38      * called.</p>
39      *
40      * @param s The MBean server on which the query is to be performed.
41      *
42      * @see #getMBeanServer
43      */

44     public void setMBeanServer(MBeanServer JavaDoc s) {
45     server.set(s);
46     }
47
48     /**
49      * <p>Return the MBean server that was most recently given to the
50      * {@link #setMBeanServer setMBeanServer} method by this thread.
51      * If this thread never called that method, the result is the
52      * value its parent thread would have obtained from
53      * <code>getMBeanServer</code> at the moment of the creation of
54      * this thread, or null if there is no parent thread.</p>
55      *
56      * @return the MBean server.
57      *
58      * @see #setMBeanServer
59      *
60      * @since.unbundled JMX 1.2
61      */

62     public static MBeanServer JavaDoc getMBeanServer() {
63     return (MBeanServer JavaDoc) server.get();
64     }
65 }
66
Popular Tags