//# 0 errors, 57 messages
//#
/*
    //#ExpiringLRUCacheFactoryImpl.java:1:1: class: org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl
 * 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 Expiring LRU cache factory.
 */
public class ExpiringLRUCacheFactoryImpl implements CacheFactory {
    
    private static Log log = LogFactory.getLog(ExpiringLRUCacheFactoryImpl.class);
    //#ExpiringLRUCacheFactoryImpl.java:31: method: org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl.org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init
    //#ExpiringLRUCacheFactoryImpl.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.ExpiringLRUCacheFactoryImpl
    //#    method: org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init): __Descendant_Table[org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl]
    //#output(org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init): __Dispatch_Table.constructCache(Ljava/util/Map;)Lorg/apache/roller/weblogger/util/cache/Cache;
    //#output(org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init): log
    //#output(org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init): org/apache/roller/weblogger/util/cache/CacheFactory.__Descendant_Table[org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl]
    //#post(org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init): __Descendant_Table[org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init): org/apache/roller/weblogger/util/cache/CacheFactory.__Descendant_Table[org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init): __Dispatch_Table.constructCache(Ljava/util/Map;)Lorg/apache/roller/weblogger/util/cache/Cache; == &constructCache
    //#post(org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init): init'ed(log)
    //#ExpiringLRUCacheFactoryImpl.java:31: end of method: org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl.org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl__static_init
    
    
    // protected so only the CacheManager can instantiate us
    protected ExpiringLRUCacheFactoryImpl() {}
    //#ExpiringLRUCacheFactoryImpl.java:35: method: void org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl.org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl()
    //#ExpiringLRUCacheFactoryImpl.java:35: end of method: void org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl.org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl()
    
    
    /**
     * Construct a new instance of a Roller Expiring LRUCache.
     */
    public Cache constructCache(Map properties) {
        
        int size = 100;
    //#ExpiringLRUCacheFactoryImpl.java:43: method: Cache org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl.constructCache(Map)
    //#input(Cache constructCache(Map)): ", timeout="._tainted
    //#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 ExpiringLRUCacheImpl(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.timeout
    //#output(Cache constructCache(Map)): return_value
    //#new obj(Cache constructCache(Map)): new Date(LRUCacheImpl#1)
    //#new obj(Cache constructCache(Map)): new ExpiringLRUCacheImpl(constructCache#1)
    //#pre[1] (Cache constructCache(Map)): log != null
    //#pre[2] (Cache constructCache(Map)): properties != null
    //#presumption(Cache constructCache(Map)): java.lang.Integer:parseInt(...)@48 in -1_610_612_737..3_221_225_471
    //#presumption(Cache constructCache(Map)): java.lang.Long:parseLong(...)@54 <= 18_446_744_073_709_551
    //#post(Cache constructCache(Map)): return_value == &new ExpiringLRUCacheImpl(constructCache#1)
    //#post(Cache constructCache(Map)): new Date(LRUCacheImpl#1) num objects == 1
    //#post(Cache constructCache(Map)): new ExpiringLRUCacheImpl(constructCache#1) num objects == 1
    //#post(Cache constructCache(Map)): return_value.__Tag == org/apache/roller/weblogger/util/cache/ExpiringLRUCacheImpl
    //#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)
    //#post(Cache constructCache(Map)): return_value.timeout in {0, 1_000..18_446_744_073_709_551_000}
    //#unanalyzed(Cache constructCache(Map)): Effects-of-calling:org.apache.roller.weblogger.util.cache.LRUCacheImpl
    //#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(...)@59: Addr_Set{null}, Inverse{null}
        long timeout = 15 * 60;
        String id = "unknown";
        
        try {
            size = Integer.parseInt((String) properties.get("size"));
        } catch(Exception e) {
            // ignored
        }
        
        try {
            timeout = Long.parseLong((String) properties.get("timeout"));
        } catch(Exception e) {
            // ignored
        }
        
        String cacheId = (String) properties.get("id");
        if(cacheId != null) {
            id = cacheId;
        }
        
        Cache cache = new ExpiringLRUCacheImpl(id, size, timeout);
        
        log.debug("new cache constructed. size="+size+", timeout="+timeout);
    //#ExpiringLRUCacheFactoryImpl.java:66: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl
    //#    method: Cache constructCache(Map)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
        
        return cache;
    //#ExpiringLRUCacheFactoryImpl.java:68: end of method: Cache org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl.constructCache(Map)
    }
    
}
    //#ExpiringLRUCacheFactoryImpl.java:: end of class: org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl
