KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > server > MBeanMetaData


1 /*
2  * Copyright (C) MX4J.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.server;
10
11 import java.security.AccessController JavaDoc;
12 import java.security.PrivilegedAction JavaDoc;
13 import javax.management.MBeanInfo JavaDoc;
14 import javax.management.ObjectInstance JavaDoc;
15 import javax.management.ObjectName JavaDoc;
16
17 import mx4j.MX4JSystemKeys;
18
19 /**
20  * Objects of this class hold metadata information about MBeans.
21  *
22  * @author <a HREF="mailto:biorn_steedom@users.sourceforge.net">Simone Bordet</a>
23  * @version $Revision: 1.5 $
24  * @see Factory
25  */

26 public interface MBeanMetaData
27 {
28    /**
29     * Sets the MBean instance
30     *
31     * @see #getMBean
32     */

33    public void setMBean(Object JavaDoc mbean);
34
35    /**
36     * Returns the MBean instance
37     *
38     * @see #setMBean
39     */

40    public Object JavaDoc getMBean();
41
42    /**
43     * Sets the classloader for the MBean
44     *
45     * @see #getClassLoader
46     */

47    public void setClassLoader(ClassLoader JavaDoc loader);
48
49    /**
50     * Returns the classloader for the MBean
51     *
52     * @see #setClassLoader
53     */

54    public ClassLoader JavaDoc getClassLoader();
55
56    /**
57     * Sets the ObjectName of the MBean
58     *
59     * @see #getObjectName
60     */

61    public void setObjectName(ObjectName JavaDoc name);
62
63    /**
64     * Returns the ObjectName of the MBean
65     *
66     * @see #setObjectName
67     */

68    public ObjectName JavaDoc getObjectName();
69
70    /**
71     * Sets the MBeanInfo of the MBean
72     *
73     * @see #getMBeanInfo
74     */

75    public void setMBeanInfo(MBeanInfo JavaDoc info);
76
77    /**
78     * Returns the MBeanInfo of the MBean
79     *
80     * @see #setMBeanInfo
81     */

82    public MBeanInfo JavaDoc getMBeanInfo();
83
84    /**
85     * Sets the management interface of the standard MBean
86     *
87     * @see #getMBeanInterface
88     */

89    public void setMBeanInterface(Class JavaDoc management);
90
91    /**
92     * Returns the management interface of the standard MBean
93     *
94     * @see #setMBeanInterface
95     */

96    public Class JavaDoc getMBeanInterface();
97
98    /**
99     * Sets whether the MBean is standard
100     *
101     * @see #isMBeanStandard
102     */

103    public void setMBeanStandard(boolean value);
104
105    /**
106     * Returns whether the MBean is standard
107     *
108     * @see #setMBeanStandard
109     */

110    public boolean isMBeanStandard();
111
112    /**
113     * Sets whether the MBean is dynamic
114     *
115     * @see #isMBeanDynamic
116     */

117    public void setMBeanDynamic(boolean value);
118
119    /**
120     * Returns whether the MBean is dynamic
121     *
122     * @see #setMBeanDynamic
123     */

124    public boolean isMBeanDynamic();
125
126    /**
127     * Sets the MBeanInvoker of the standard MBean
128     *
129     * @see #getMBeanInvoker
130     */

131    public void setMBeanInvoker(MBeanInvoker invoker);
132
133    /**
134     * Returns the MBeanInvoker of the standard MBean
135     *
136     * @see #getMBeanInvoker
137     */

138    public MBeanInvoker getMBeanInvoker();
139
140    /**
141     * Returns the ObjectInstance of the MBean
142     *
143     * @see #getMBeanInfo
144     * @see #getObjectName
145     */

146    public ObjectInstance JavaDoc getObjectInstance();
147
148    /**
149     * Factory class that creates instance of the {@link MBeanMetaData} interface.
150     * The default implementation is {@link MX4JMBeanMetaData}, but it can be overridden
151     * by setting the system property defined by {@link MX4JSystemKeys#MX4J_MBEAN_METADATA}.
152     */

153    public static class Factory
154    {
155       public static MBeanMetaData create()
156       {
157          String JavaDoc className = (String JavaDoc)AccessController.doPrivileged(new PrivilegedAction JavaDoc()
158          {
159             public Object JavaDoc run()
160             {
161                return System.getProperty(MX4JSystemKeys.MX4J_MBEAN_METADATA);
162             }
163          });
164          if (className == null) className = "mx4j.server.MX4JMBeanMetaData";
165
166          try
167          {
168             try
169             {
170                return (MBeanMetaData)MBeanMetaData.class.getClassLoader().loadClass(className).newInstance();
171             }
172             catch (ClassNotFoundException JavaDoc x)
173             {
174                // Not found with the current classloader, try the context classloader
175
return (MBeanMetaData)Thread.currentThread().getContextClassLoader().loadClass(className).newInstance();
176             }
177          }
178          catch (Exception JavaDoc x)
179          {
180             throw new Error JavaDoc(x.toString());
181          }
182       }
183    }
184 }
185
Popular Tags