View Javadoc

1   package org.apache.jcs.auxiliary.disk.block;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  import org.apache.jcs.auxiliary.AuxiliaryCache;
25  import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
26  import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
27  import org.apache.jcs.engine.behavior.ICompositeCacheManager;
28  
29  /***
30   * Creates disk cache instances.
31   */
32  public class BlockDiskCacheFactory
33      implements AuxiliaryCacheFactory
34  {
35      /*** The logger */
36      private final static Log log = LogFactory.getLog( BlockDiskCacheFactory.class );
37  
38      /*** The auxiliary name */
39      private String name;
40  
41      /***
42       * Get an instance of the BlockDiskCacheManager for the attributes and then get an
43       * IndexedDiskCache from the manager.
44       * <p>
45       * The manager is a singleton.
46       * <p>
47       * One disk cache is returned per region fromt he maanger.
48       * <p>
49       * @param iaca
50       * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is
51       *            a singleton. This will allow JCS to be a nonsingleton. Also, it makes it easier to
52       *            test.
53       * @return AuxiliaryCache
54       */
55      public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
56      {
57          BlockDiskCacheAttributes idca = (BlockDiskCacheAttributes) iaca;
58          if ( log.isDebugEnabled() )
59          {
60              log.debug( "Creating DiskCache for attributes = " + idca );
61          }
62          BlockDiskCacheManager dcm = BlockDiskCacheManager.getInstance( idca );
63          return dcm.getCache( idca );
64      }
65  
66      /***
67       * Gets the name attribute of the DiskCacheFactory object
68       * <p>
69       * @return The name value
70       */
71      public String getName()
72      {
73          return this.name;
74      }
75  
76      /***
77       * Sets the name attribute of the DiskCacheFactory object
78       * <p>
79       * @param name The new name value
80       */
81      public void setName( String name )
82      {
83          this.name = name;
84      }
85  }