001    /**
002     * Copyright (c) 2000-2012 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.lar;
016    
017    import com.liferay.portal.kernel.lar.StagedModelDataHandler;
018    import com.liferay.portal.kernel.lar.StagedModelDataHandlerRegistry;
019    import com.liferay.portal.kernel.util.ListUtil;
020    
021    import java.util.HashMap;
022    import java.util.List;
023    import java.util.Map;
024    
025    /**
026     * The implementation of the staged model data handler registry framework.
027     *
028     * @author Mate Thurzo
029     * @see    com.liferay.portal.kernel.lar.StagedModelDataHandlerRegistryUtil
030     * @since  6.2
031     */
032    public class StagedModelDataHandlerRegistryImpl
033            implements StagedModelDataHandlerRegistry {
034    
035            public StagedModelDataHandler<?> getStagedModelDataHandler(
036                    String className) {
037    
038                    return _stagedModelDataHandlers.get(className);
039            }
040    
041            public List<StagedModelDataHandler<?>> getStagedModelDataHandlers() {
042                    return ListUtil.fromMapValues(_stagedModelDataHandlers);
043            }
044    
045            public void register(StagedModelDataHandler<?> stagedModelDataHandler) {
046                    _stagedModelDataHandlers.put(
047                            stagedModelDataHandler.getClassName(), stagedModelDataHandler);
048            }
049    
050            public void unregister(StagedModelDataHandler<?> stagedModelDataHandler) {
051                    _stagedModelDataHandlers.remove(stagedModelDataHandler.getClassName());
052            }
053    
054            private Map<String, StagedModelDataHandler<?>> _stagedModelDataHandlers =
055                    new HashMap<String, StagedModelDataHandler<?>>();
056    
057    }