//# 0 errors, 52 messages
//#
/*
    //#LRUCacheFactoryImpl.java:1:1: class: org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.util.cache;

import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * Roller LRU Cache factory.
 */
public class LRUCacheFactoryImpl implements CacheFactory {
    
    private static Log log = LogFactory.getLog(LRUCacheFactoryImpl.class);
    //#LRUCacheFactoryImpl.java:31: method: org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl.org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init
    //#LRUCacheFactoryImpl.java:31: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl
    //#    method: org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init): __Descendant_Table[org/apache/roller/weblogger/util/cache/LRUCacheFactoryImpl]
    //#output(org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init): __Dispatch_Table.constructCache(Ljava/util/Map;)Lorg/apache/roller/weblogger/util/cache/Cache;
    //#output(org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init): log
    //#output(org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init): org/apache/roller/weblogger/util/cache/CacheFactory.__Descendant_Table[org/apache/roller/weblogger/util/cache/LRUCacheFactoryImpl]
    //#post(org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init): __Descendant_Table[org/apache/roller/weblogger/util/cache/LRUCacheFactoryImpl] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init): org/apache/roller/weblogger/util/cache/CacheFactory.__Descendant_Table[org/apache/roller/weblogger/util/cache/LRUCacheFactoryImpl] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init): __Dispatch_Table.constructCache(Ljava/util/Map;)Lorg/apache/roller/weblogger/util/cache/Cache; == &constructCache
    //#post(org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init): init'ed(log)
    //#LRUCacheFactoryImpl.java:31: end of method: org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl.org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl__static_init
    
    
    // protected so that only the CacheManager can instantiate us
    protected LRUCacheFactoryImpl() {}
    //#LRUCacheFactoryImpl.java:35: method: void org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl.org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl()
    //#LRUCacheFactoryImpl.java:35: end of method: void org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl.org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl()
    
    
    /**
     * Construct a new instance of a Roller LRUCache.
     */
    public Cache constructCache(Map properties) {
        
        int size = 100;
    //#LRUCacheFactoryImpl.java:43: method: Cache org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl.constructCache(Map)
    //#input(Cache constructCache(Map)): "new cache constructed. size="._tainted
    //#input(Cache constructCache(Map)): log
    //#input(Cache constructCache(Map)): properties
    //#output(Cache constructCache(Map)): new Date(LRUCacheImpl#1) num objects
    //#output(Cache constructCache(Map)): new LRUCacheImpl(constructCache#1) num objects
    //#output(Cache constructCache(Map)): return_value.__Tag
    //#output(Cache constructCache(Map)): return_value.cache
    //#output(Cache constructCache(Map)): return_value.hits
    //#output(Cache constructCache(Map)): return_value.id
    //#output(Cache constructCache(Map)): return_value.misses
    //#output(Cache constructCache(Map)): return_value.puts
    //#output(Cache constructCache(Map)): return_value.removes
    //#output(Cache constructCache(Map)): return_value.startTime
    //#output(Cache constructCache(Map)): return_value
    //#new obj(Cache constructCache(Map)): new Date(LRUCacheImpl#1)
    //#new obj(Cache constructCache(Map)): new LRUCacheImpl(constructCache#1)
    //#pre[1] (Cache constructCache(Map)): log != null
    //#pre[2] (Cache constructCache(Map)): properties != null
    //#presumption(Cache constructCache(Map)): java.lang.Integer:parseInt(...)@47 in -1_610_612_737..3_221_225_471
    //#post(Cache constructCache(Map)): return_value == &new LRUCacheImpl(constructCache#1)
    //#post(Cache constructCache(Map)): new Date(LRUCacheImpl#1) num objects == 1
    //#post(Cache constructCache(Map)): new LRUCacheImpl(constructCache#1) num objects == 1
    //#post(Cache constructCache(Map)): return_value.__Tag == org/apache/roller/weblogger/util/cache/LRUCacheImpl
    //#post(Cache constructCache(Map)): init'ed(return_value.cache)
    //#post(Cache constructCache(Map)): return_value.hits == +0
    //#post(Cache constructCache(Map)): return_value.misses == +0
    //#post(Cache constructCache(Map)): return_value.puts == +0
    //#post(Cache constructCache(Map)): return_value.removes == +0
    //#post(Cache constructCache(Map)): return_value.id != null
    //#post(Cache constructCache(Map)): return_value.startTime == &new Date(LRUCacheImpl#1)
    //#unanalyzed(Cache constructCache(Map)): Effects-of-calling:java.util.Date
    //#unanalyzed(Cache constructCache(Map)): Effects-of-calling:java.util.LinkedHashMap
    //#unanalyzed(Cache constructCache(Map)): Effects-of-calling:java.util.Collections:synchronizedMap
    //#test_vector(Cache constructCache(Map)): java.util.Map:get(...)@52: Addr_Set{null}, Inverse{null}
        String id = "unknown";
        
        try {
            size = Integer.parseInt((String) properties.get("size"));
        } catch(Exception e) {
            // ignored
        }
        
        String cacheId = (String) properties.get("id");
        if(cacheId != null) {
            id = cacheId;
        }
        
        Cache cache = new LRUCacheImpl(id, size);
        
        log.debug("new cache constructed. size="+size);
    //#LRUCacheFactoryImpl.java:59: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl
    //#    method: Cache constructCache(Map)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        return cache;
    //#LRUCacheFactoryImpl.java:61: end of method: Cache org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl.constructCache(Map)
    }
    
}
    //#LRUCacheFactoryImpl.java:: end of class: org.apache.roller.weblogger.util.cache.LRUCacheFactoryImpl
