001    /**
002     * Copyright (c) 2000-2010 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.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    }