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