001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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.MBeanInfo;
021    import javax.management.MBeanServer;
022    import javax.management.ObjectName;
023    
024    /**
025     * @author Shuyang Zhou
026     */
027    public class LoadMBeanInfoAction extends BaseJMXManageAction<MBean> {
028    
029            public LoadMBeanInfoAction(MBean mBean) {
030                    _mBean = mBean;
031            }
032    
033            @Override
034            public MBean action() throws ManageActionException {
035                    try {
036                            ObjectName objectName = _mBean.getObjectName();
037    
038                            MBeanServer mBeanServer = getMBeanServer();
039    
040                            MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName);
041    
042                            return new MBean(objectName, mBeanInfo);
043                    }
044                    catch (Exception e) {
045                            throw new ManageActionException(e);
046                    }
047            }
048    
049            private MBean _mBean;
050    
051    }