01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.com
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package org.huihoo.jfox.jmx;
09:
10: import javax.management.ObjectName;
11: import javax.management.DynamicMBean;
12: import javax.management.StandardMBean;
13:
14: /**
15: *
16: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
17: */
18:
19: public class MBeanMetaDataFactory {
20:
21: public static MBeanMetaData getInstance(ObjectName objectName,
22: Object obj, Class interfaceClass) {
23:
24: if (obj instanceof StandardMBean) { // StandardMBean
25: // the interfaceClass must be DynamicMBean, no use
26: return ((StandardMBean) obj).getMetaData();
27: } else if (obj instanceof DynamicMBean) { // DynamicMBean
28: return new DynamicMBeanMetaDataSupport(objectName,
29: (DynamicMBean) obj);
30: } else { // Standard MBean
31: return new MBeanMetaDataSupport(objectName, obj,
32: MBeanInterfaceMetaDataSupport
33: .getInstance(interfaceClass));
34: }
35: }
36:
37: }
|