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 java.util.Collections;
018    import java.util.HashSet;
019    import java.util.Properties;
020    import java.util.Set;
021    
022    /**
023     * @author Tina Tian
024     */
025    public class PortalCacheConfiguration {
026    
027            public static final String DEFAULT_PORTAL_CACHE_NAME =
028                    "DEFAULT_PORTAL_CACHE_NAME";
029    
030            public static final String PORTAL_CACHE_LISTENER_SCOPE =
031                    "PORTAL_CACHE_LISTENER_SCOPE";
032    
033            public PortalCacheConfiguration(
034                    String portalCacheName,
035                    Set<Properties> portalCacheListenerPropertiesSet,
036                    Properties portalCacheBootstrapLoaderProperties) {
037    
038                    if (portalCacheName == null) {
039                            throw new NullPointerException("Portal cache name is null");
040                    }
041    
042                    _portalCacheName = portalCacheName;
043    
044                    if (portalCacheListenerPropertiesSet == null) {
045                            _portalCacheListenerPropertiesSet = Collections.emptySet();
046                    }
047                    else {
048                            _portalCacheListenerPropertiesSet = new HashSet<>(
049                                    portalCacheListenerPropertiesSet);
050                    }
051    
052                    _portalCacheBootstrapLoaderProperties =
053                            portalCacheBootstrapLoaderProperties;
054            }
055    
056            public Properties getPortalCacheBootstrapLoaderProperties() {
057                    return _portalCacheBootstrapLoaderProperties;
058            }
059    
060            public Set<Properties> getPortalCacheListenerPropertiesSet() {
061                    return Collections.unmodifiableSet(_portalCacheListenerPropertiesSet);
062            }
063    
064            public String getPortalCacheName() {
065                    return _portalCacheName;
066            }
067    
068            public PortalCacheConfiguration newPortalCacheConfiguration(
069                    String portalCacheName) {
070    
071                    return new PortalCacheConfiguration(
072                            portalCacheName, _portalCacheListenerPropertiesSet,
073                            _portalCacheBootstrapLoaderProperties);
074            }
075    
076            private final Properties _portalCacheBootstrapLoaderProperties;
077            private final Set<Properties> _portalCacheListenerPropertiesSet;
078            private final String _portalCacheName;
079    
080    }