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 public AttributeList 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 return mBeanServer.getAttributes(objectName, attributeNames);
053 }
054 catch (Exception e) {
055 throw new ManageActionException(e);
056 }
057 }
058
059 private MBean _mBean;
060
061 }