1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.cache.cluster;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  
20  /**
21   * <a href="PortalCacheClusterLinkUtil.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Shuyang Zhou
24   */
25  public class PortalCacheClusterLinkUtil {
26  
27      public static PortalCacheClusterLink getPortalCacheClusterLink() {
28          if (_portalCacheClusterLink == null) {
29              if (_log.isWarnEnabled()) {
30                  _log.warn(
31                      "PortalCacheClusterLinkUtil has not been initialized.");
32              }
33  
34              return null;
35          }
36  
37          return _portalCacheClusterLink;
38      }
39  
40      public static long getSubmittedEventNumber() {
41          if (_portalCacheClusterLink == null) {
42              if (_log.isWarnEnabled()) {
43                  _log.warn(
44                      "PortalCacheClusterLinkUtil has not been initialized.");
45              }
46  
47              return -1;
48          }
49  
50          return _portalCacheClusterLink.getSubmittedEventNumber();
51      }
52  
53      public static void sendEvent(
54          PortalCacheClusterEvent portalCacheClusterEvent) {
55  
56          if (_portalCacheClusterLink == null) {
57              if (_log.isWarnEnabled()) {
58                  _log.warn(
59                      "PortalCacheClusterLinkUtil has not been initialized.");
60              }
61  
62              return;
63          }
64  
65          _portalCacheClusterLink.sendEvent(portalCacheClusterEvent);
66      }
67  
68      public void setPortalCacheClusterLink(
69          PortalCacheClusterLink portalCacheClusterLink) {
70  
71          _portalCacheClusterLink = portalCacheClusterLink;
72      }
73  
74      private static Log _log = LogFactoryUtil.getLog(
75          PortalCacheClusterLinkUtil.class);
76  
77      private static PortalCacheClusterLink _portalCacheClusterLink;
78  
79  }