001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.management.jmx;
016    
017    import com.liferay.portal.kernel.management.ManageActionException;
018    
019    import javax.management.MBeanServer;
020    import javax.management.ObjectName;
021    
022    /**
023     * @author Shuyang Zhou
024     */
025    public class DoOperationAction extends BaseJMXManageAction {
026    
027            public DoOperationAction(
028                    ObjectName objectName, String operationName, Object[] parameters,
029                    String[] signature) {
030    
031                    _objectName = objectName;
032                    _operationName = operationName;
033                    _parameters = parameters;
034                    _signature = signature;
035            }
036    
037            public void action() throws ManageActionException {
038                    try {
039                            MBeanServer mBeanServer = getMBeanServer();
040    
041                            _result = mBeanServer.invoke(
042                                    _objectName, _operationName, _parameters, _signature);
043    
044                    }
045                    catch (Exception e) {
046                            throw new ManageActionException(e);
047                    }
048            }
049    
050            public Object getResult() {
051                    return _result;
052            }
053    
054            private ObjectName _objectName;
055            private String _operationName;
056            private Object[] _parameters;
057            private Object _result;
058            private String[] _signature;
059    
060    }