001    /**
002     * Copyright (c) 2000-2010 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.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    }