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<AttributeList> {
030
031 public GetAttributesAction(MBean mBean) {
032 _mBean = mBean;
033 }
034
035 @Override
036 public AttributeList action() throws ManageActionException {
037 try {
038 ObjectName objectName = _mBean.getObjectName();
039
040 MBeanServer mBeanServer = getMBeanServer();
041
042 MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName);
043
044 MBeanAttributeInfo[] mBeanAttributeInfos =
045 mBeanInfo.getAttributes();
046
047 String[] attributeNames = new String[mBeanAttributeInfos.length];
048
049 for (int i = 0; i < attributeNames.length; i++) {
050 attributeNames[i] = mBeanAttributeInfos[i].getName();
051 }
052
053 return mBeanServer.getAttributes(objectName, attributeNames);
054 }
055 catch (Exception e) {
056 throw new ManageActionException(e);
057 }
058 }
059
060 private MBean _mBean;
061
062 }