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.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<Object> {
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            @Override
038            public Object action() throws ManageActionException {
039                    try {
040                            MBeanServer mBeanServer = getMBeanServer();
041    
042                            return mBeanServer.invoke(
043                                    _objectName, _operationName, _parameters, _signature);
044    
045                    }
046                    catch (Exception e) {
047                            throw new ManageActionException(e);
048                    }
049            }
050    
051            private ObjectName _objectName;
052            private String _operationName;
053            private Object[] _parameters;
054            private String[] _signature;
055    
056    }