001    /**
002     * 
003     * $Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
004     *
005     * This file is part of ** M y C o R e **
006     * Visit our homepage at http://www.mycore.de/ for details.
007     *
008     * This program is free software; you can use it, redistribute it
009     * and / or modify it under the terms of the GNU General Public License
010     * (GPL) as published by the Free Software Foundation; either version 2
011     * of the License or (at your option) any later version.
012     *
013     * This program is distributed in the hope that it will be useful, but
014     * WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program, normally in the file license.txt.
020     * If not, write to the Free Software Foundation Inc.,
021     * 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
022     *
023     **/
024    package org.mycore.common;
025    
026    /**
027     * 
028     * @author Thomas Scheffler (yagee)
029     * 
030     * Need to insert some things here
031     * @jmx.mbean
032     */
033    public class MCRCacheManager implements MCRCacheManagerMBean {
034        
035        private final MCRCache cache;
036        
037        public MCRCacheManager(final MCRCache cache){
038            this.cache=cache;
039        }
040        
041    
042        public int getCapacity() {
043            return cache.capacity;
044        }
045    
046        public double getFillRate() {
047            return cache.getFillRate();
048        }
049    
050        public double getHitRate() {
051            return cache.getHitRate();
052        }
053    
054        public long getHits() {
055            return cache.hits;
056        }
057    
058        public long getRequests() {
059            return cache.gets;
060        }
061    
062        public int getSize() {
063            return cache.size;
064        }
065        /**
066         * @jmx.managed-operation
067         */
068        public void setCapacity(int capacity) {
069            cache.setCapacity(capacity);
070        }
071    
072    
073        public void clear() {
074            int capacity=getCapacity();
075            cache.clear();
076            setCapacity(capacity);
077        }
078    
079    
080        public String getLeastRecentlyUsedElement() {
081            return cache.lru.key.toString();
082        }
083    
084    
085        public String getMostRecentlyUsedElement() {
086            return cache.mru.key.toString();
087        }
088    
089    }