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;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.MethodHandler;
020    import com.liferay.portal.model.ClusterGroup;
021    
022    import java.lang.reflect.Method;
023    
024    /**
025     * @author Shuyang Zhou
026     */
027    public class PortalManagerUtil {
028    
029            public static MethodHandler createManageActionMethodHandler(
030                    ManageAction manageAction) {
031    
032                    return new MethodHandler(_manageMethod, manageAction);
033            }
034    
035            public static void manage(
036                            ClusterGroup clusterGroup, ManageAction manageAction)
037                    throws ManageActionException {
038    
039                    ManageAction action = new ClusterManageActionWrapper(
040                            clusterGroup, manageAction);
041    
042                    _portalManager.manage(action);
043            }
044    
045            public static void manage(ManageAction manageAction)
046                    throws ManageActionException {
047    
048                    _portalManager.manage(manageAction);
049            }
050    
051            public void setPortalManager(PortalManager portalManager) {
052                    _portalManager = portalManager;
053            }
054    
055            private static Log _log = LogFactoryUtil.getLog(PortalManagerUtil.class);
056    
057            private static Method _manageMethod;
058            private static PortalManager _portalManager;
059    
060            static {
061                    try {
062                            _manageMethod = PortalManagerUtil.class.getDeclaredMethod(
063                                    "manage", ManageAction.class);
064                    }
065                    catch (Exception e) {
066                            _log.error(e, e);
067                    }
068            }
069    
070    }