View Javadoc
1   package org.apache.commons.jcs3.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.jcs3.auxiliary.AbstractAuxiliaryCacheFactory;
23  import org.apache.commons.jcs3.auxiliary.AuxiliaryCacheAttributes;
24  import org.apache.commons.jcs3.engine.behavior.ICompositeCacheManager;
25  import org.apache.commons.jcs3.engine.behavior.IElementSerializer;
26  import org.apache.commons.jcs3.engine.logging.behavior.ICacheEventLogger;
27  import org.apache.commons.jcs3.log.Log;
28  import org.apache.commons.jcs3.log.LogManager;
29  
30  /**
31   * Creates disk cache instances.
32   */
33  public class BlockDiskCacheFactory
34      extends AbstractAuxiliaryCacheFactory
35  {
36      /** The logger */
37      private static final Log log = LogManager.getLog( BlockDiskCacheFactory.class );
38  
39      /**
40       * Create an instance of the BlockDiskCache.
41       * <p>
42       * @param iaca the cache attributes for this cache
43       * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is
44       *            a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier
45       *            to test.
46       * @param cacheEventLogger
47       * @param elementSerializer
48       * @return BlockDiskCache
49       */
50      @Override
51      public <K, V> BlockDiskCache<K, V> createCache( final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr,
52                                         final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
53      {
54          final BlockDiskCacheAttributes idca = (BlockDiskCacheAttributes) iaca;
55          log.debug("Creating DiskCache for attributes = {0}", idca);
56  
57          final BlockDiskCache<K, V> cache = new BlockDiskCache<>( idca, elementSerializer );
58          cache.setCacheEventLogger( cacheEventLogger );
59  
60          return cache;
61      }
62  }