View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package net.sf.ehcache.cluster;
17  
18  import java.util.Collection;
19  import java.util.Collections;
20  import java.util.List;
21  
22  /***
23   * This is a dummy implementation of the CacheCluster (Null Object Pattern).  It ignores
24   * all listeners and reports no nodes.
25   *
26   * @author Geert Bevin
27   * @since 2.0
28   */
29  public class NoopCacheCluster implements CacheCluster {
30  
31      /***
32       * A singleton instance you can use rather than constructing your own.
33       */
34      public static final CacheCluster INSTANCE = new NoopCacheCluster();
35  
36      /***
37       * {@inheritDoc}
38       */
39      public Collection<ClusterNode> getNodes() {
40          return Collections.emptyList();
41      }
42  
43      /***
44       * Always returns the ClusterScheme.NONE
45       *
46       * @return {@link ClusterScheme#NONE}
47       */
48      public ClusterScheme getScheme() {
49          return ClusterScheme.NONE;
50      }
51  
52      /***
53       * {@inheritDoc}
54       */
55      public boolean addTopologyListener(ClusterTopologyListener listener) {
56          return false;
57      }
58  
59      /***
60       * {@inheritDoc}
61       */
62      public boolean removeTopologyListener(ClusterTopologyListener listener) {
63          return false;
64      }
65  
66      /***
67       * {@inheritDoc}
68       */
69      public boolean isClusterOnline() {
70          return true;
71      }
72  
73      /***
74       * {@inheritDoc}
75       */
76      public ClusterNode getCurrentNode() {
77          return null;
78      }
79  
80      /***
81       * {@inheritDoc}
82       */
83      public ClusterNode waitUntilNodeJoinsCluster() {
84          return null;
85      }
86  
87      /***
88       * {@inheritDoc}
89       */
90      public List<ClusterTopologyListener> getTopologyListeners() {
91          return Collections.EMPTY_LIST;
92      }
93  }