001
014
015 package com.liferay.portal.kernel.management.jmx;
016
017 import com.liferay.portal.kernel.jmx.model.MBean;
018 import com.liferay.portal.kernel.management.ManageActionException;
019
020 import javax.management.AttributeList;
021 import javax.management.MBeanAttributeInfo;
022 import javax.management.MBeanInfo;
023 import javax.management.MBeanServer;
024 import javax.management.ObjectName;
025
026
029 public class GetAttributesAction extends BaseJMXManageAction {
030
031 public GetAttributesAction(MBean mBean) {
032 _mBean = mBean;
033 }
034
035 public void action() throws ManageActionException {
036 try {
037 ObjectName objectName = _mBean.getObjectName();
038
039 MBeanServer mBeanServer = getMBeanServer();
040
041 MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName);
042
043 MBeanAttributeInfo[] mBeanAttributeInfos =
044 mBeanInfo.getAttributes();
045
046 String[] attributeNames = new String[mBeanAttributeInfos.length];
047
048 for (int i = 0; i < attributeNames.length; i++) {
049 attributeNames[i] = mBeanAttributeInfos[i].getName();
050 }
051
052 _attributeList = mBeanServer.getAttributes(
053 objectName, attributeNames);
054 }
055 catch (Exception e) {
056 throw new ManageActionException(e);
057 }
058 }
059
060 public AttributeList getAttributeList() {
061 return _attributeList;
062 }
063
064 private AttributeList _attributeList;
065 private MBean _mBean;
066
067 }