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  
17  package net.sf.ehcache.config;
18  
19  /***
20   * Class to hold the Pinning configuration.
21   *
22   * @author Ludovic Orban
23   */
24  public class PinningConfiguration implements Cloneable {
25  
26      /***
27       * Possible store values
28       */
29      public static enum Store {
30          /***
31           * Pin the elements on-heap
32           */
33          LOCALHEAP,
34  
35          /***
36           * Pin the elements in the local VM memory
37           */
38          LOCALMEMORY,
39  
40          /***
41           * Pin the elements in the cache
42           */
43          INCACHE,
44      }
45  
46      private volatile Store store;
47  
48      /***
49       * Set the store scope
50       *
51       * @param store the storage scope
52       */
53      public void setStore(String store) {
54          if (store == null) {
55              throw new IllegalArgumentException("Store must be non-null");
56          }
57          this.store(Store.valueOf(Store.class, store.toUpperCase()));
58      }
59  
60      /***
61       * Set the lowest store from which elements must not be evicted from
62       *
63       * @param store the store, encoded as a string
64       * @return this
65       */
66      public PinningConfiguration store(String store) {
67          setStore(store);
68          return this;
69      }
70  
71      /***
72       * Set the lowest store from which elements must not be evicted from
73       *
74       * @param store the store
75       * @return this
76       */
77      public PinningConfiguration store(Store store) {
78          if (store == null) {
79              throw new IllegalArgumentException("Store must be non-null");
80          }
81          this.store = store;
82          return this;
83      }
84  
85      /***
86       * Return the lowest store from which elements must not be evicted from
87       * @return the lowest store from which elements must not be evicted from
88       */
89      public Store getStore() {
90          return store;
91      }
92  
93  }