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.struts;
016    
017    import com.liferay.portal.kernel.struts.StrutsAction;
018    import com.liferay.portal.kernel.struts.StrutsPortletAction;
019    
020    import java.util.Map;
021    import java.util.concurrent.ConcurrentHashMap;
022    
023    import org.apache.struts.action.Action;
024    
025    /**
026     * @author Mika Koivisto
027     */
028    public class StrutsActionRegistry {
029    
030            public static void register(
031                    String path, StrutsPortletAction strutsPortletAction) {
032    
033                    Action action = new PortletActionAdapter(strutsPortletAction);
034    
035                    _actions.put(path, action);
036            }
037    
038            public static void register(String path, StrutsAction strutsAction) {
039                    Action action = new ActionAdapter(strutsAction);
040    
041                    _actions.put(path, action);
042            }
043    
044            public static void unregister(String path) {
045                    _actions.remove(path);
046            }
047    
048            public static Action getAction(String path) {
049                    return _actions.get(path);
050            }
051    
052            private static Map<String, Action> _actions =
053                    new ConcurrentHashMap<String, Action>();
054    
055    }