001    /**
002     * Copyright (c) 2000-present 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.cache.configuration;
016    
017    import com.liferay.portal.kernel.cache.CacheListenerScope;
018    
019    import java.util.Collections;
020    import java.util.HashMap;
021    import java.util.Map;
022    
023    /**
024     * @author Tina Tian
025     */
026    public class PortalCacheConfiguration {
027    
028            public static final String DEFAULT_PORTAL_CACHE_NAME =
029                    "DEFAULT_PORTAL_CACHE_NAME";
030    
031            public PortalCacheConfiguration(
032                    String portalCacheName,
033                    Map<CallbackConfiguration, CacheListenerScope>
034                            cacheListenerConfigurations,
035                    CallbackConfiguration bootstrapLoaderConfiguration) {
036    
037                    if (portalCacheName == null) {
038                            throw new NullPointerException("Portal cache name is null");
039                    }
040    
041                    _portalCacheName = portalCacheName;
042    
043                    if (cacheListenerConfigurations == null) {
044                            _cacheListenerConfigurations = Collections.emptyMap();
045                    }
046                    else {
047                            _cacheListenerConfigurations =
048                                    new HashMap<CallbackConfiguration, CacheListenerScope>(
049                                            cacheListenerConfigurations);
050                    }
051    
052                    _bootstrapLoaderConfiguration = bootstrapLoaderConfiguration;
053            }
054    
055            public CallbackConfiguration getBootstrapLoaderConfiguration() {
056                    return _bootstrapLoaderConfiguration;
057            }
058    
059            public Map<CallbackConfiguration, CacheListenerScope>
060                    getCacheListenerConfigurations() {
061    
062                    return Collections.unmodifiableMap(_cacheListenerConfigurations);
063            }
064    
065            public String getPortalCacheName() {
066                    return _portalCacheName;
067            }
068    
069            private final CallbackConfiguration _bootstrapLoaderConfiguration;
070            private final Map<CallbackConfiguration, CacheListenerScope>
071                    _cacheListenerConfigurations;
072            private final String _portalCacheName;
073    
074    }