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.editor.fckeditor.receiver;
016    
017    import com.liferay.portal.kernel.util.InstancePool;
018    
019    import java.util.HashMap;
020    import java.util.Map;
021    
022    /**
023     * @author Ivica Cardic
024     * @author Michael C. Han
025     */
026    public class CommandReceiverFactory {
027    
028            public static CommandReceiver getCommandReceiver(String type) {
029                    CommandReceiver commandReceiver = _commandReceivers.get(type);
030    
031                    if (commandReceiver == null) {
032                            commandReceiver = (CommandReceiver)InstancePool.get(
033                                    "com.liferay.portal.editor.fckeditor.receiver.impl." +
034                                            type + "CommandReceiver");
035    
036                            _commandReceivers.put(type, commandReceiver);
037                    }
038    
039                    return commandReceiver;
040            }
041    
042            public void setCommandReceiver(
043                    String type, CommandReceiver commandReceiver) {
044    
045                    _commandReceivers.put(type, commandReceiver);
046            }
047    
048            public void setCommandReceivers(
049                    Map<String, CommandReceiver> commandReceivers) {
050    
051                    _commandReceivers.putAll(commandReceivers);
052            }
053    
054            private static Map<String, CommandReceiver> _commandReceivers =
055                    new HashMap<String, CommandReceiver>();
056    
057    }