001package org.apache.commons.jcs.auxiliary;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
023import org.apache.commons.jcs.engine.behavior.IElementSerializer;
024import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
025
026/**
027 * All auxiliary caches must have a factory that the cache configurator can use to create instances.
028 */
029public interface AuxiliaryCacheFactory
030{
031    /**
032     * Creates an auxiliary using the supplied attributes. Adds it to the composite cache manager.
033     * 
034     * @param attr
035     * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is
036     *            a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier to
037     *            test.
038     * @param cacheEventLogger
039     * @param elementSerializer
040     * @return AuxiliaryCache
041     * @throws Exception if cache instance could not be created
042     */
043    <K, V> AuxiliaryCache<K, V> createCache(
044            AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr,
045            ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
046            throws Exception;
047
048    /**
049     * Initialize this factory
050     */
051    void initialize();
052
053    /**
054     * Dispose of this factory, clean up shared resources
055     */
056    void dispose();
057
058    /**
059     * Sets the name attribute of the AuxiliaryCacheFactory object
060     * 
061     * @param s The new name value
062     */
063    void setName( String s );
064
065    /**
066     * Gets the name attribute of the AuxiliaryCacheFactory object
067     * 
068     * @return The name value
069     */
070    String getName();
071}