1
14
15 package com.liferay.portal.kernel.management.jmx;
16
17 import com.liferay.portal.kernel.jmx.model.MBean;
18 import com.liferay.portal.kernel.management.ManageActionException;
19
20 import javax.management.AttributeList;
21 import javax.management.MBeanAttributeInfo;
22 import javax.management.MBeanInfo;
23 import javax.management.MBeanServer;
24 import javax.management.ObjectName;
25
26
31 public class GetAttributesAction extends BaseJMXManageAction<AttributeList> {
32
33 public GetAttributesAction(MBean mBean) {
34 _mBean = mBean;
35 }
36
37 public AttributeList action() throws ManageActionException {
38 try {
39 ObjectName objectName = _mBean.getObjectName();
40
41 MBeanServer mBeanServer = getMBeanServer();
42
43 MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName);
44
45 MBeanAttributeInfo[] mBeanAttributeInfos =
46 mBeanInfo.getAttributes();
47
48 String[] attributeNames = new String[mBeanAttributeInfos.length];
49
50 for (int i = 0; i < attributeNames.length; i++) {
51 attributeNames[i] = mBeanAttributeInfos[i].getName();
52 }
53
54 return mBeanServer.getAttributes(objectName, attributeNames);
55 }
56 catch (Exception e) {
57 throw new ManageActionException(e);
58 }
59 }
60
61 private MBean _mBean;
62
63 }