001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.cache.cluster;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    
020    /**
021     * @author Shuyang Zhou
022     */
023    public class PortalCacheClusterLinkUtil {
024    
025            public static PortalCacheClusterLink getPortalCacheClusterLink() {
026                    if (_portalCacheClusterLink == null) {
027                            if (_log.isWarnEnabled()) {
028                                    _log.warn(
029                                            "PortalCacheClusterLinkUtil has not been initialized.");
030                            }
031    
032                            return null;
033                    }
034    
035                    return _portalCacheClusterLink;
036            }
037    
038            public static long getSubmittedEventNumber() {
039                    if (_portalCacheClusterLink == null) {
040                            if (_log.isWarnEnabled()) {
041                                    _log.warn(
042                                            "PortalCacheClusterLinkUtil has not been initialized.");
043                            }
044    
045                            return -1;
046                    }
047    
048                    return _portalCacheClusterLink.getSubmittedEventNumber();
049            }
050    
051            public static void sendEvent(
052                    PortalCacheClusterEvent portalCacheClusterEvent) {
053    
054                    if (_portalCacheClusterLink == null) {
055                            if (_log.isWarnEnabled()) {
056                                    _log.warn(
057                                            "PortalCacheClusterLinkUtil has not been initialized.");
058                            }
059    
060                            return;
061                    }
062    
063                    _portalCacheClusterLink.sendEvent(portalCacheClusterEvent);
064            }
065    
066            public void setPortalCacheClusterLink(
067                    PortalCacheClusterLink portalCacheClusterLink) {
068    
069                    _portalCacheClusterLink = portalCacheClusterLink;
070            }
071    
072            private static Log _log = LogFactoryUtil.getLog(
073                    PortalCacheClusterLinkUtil.class);
074    
075            private static PortalCacheClusterLink _portalCacheClusterLink;
076    
077    }