001 /** 002 * 003 * Copyright 2004 Hiram Chirino 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.activemq.store.cache; 019 020 import java.io.IOException; 021 022 import org.activemq.store.PersistenceAdapter; 023 024 /** 025 * Provides a CachePersistenceAdapter that uses a seperate LRU cache 026 * for each destination. 027 * 028 * @version $Revision: 1.1.1.1 $ 029 */ 030 public class SimpleCachePersistenceAdapter extends CachePersistenceAdapter { 031 032 int cacheSize=1000; 033 034 public SimpleCachePersistenceAdapter() { 035 super(); 036 } 037 038 public SimpleCachePersistenceAdapter(PersistenceAdapter longTermPersistence) 039 throws IOException { 040 super(longTermPersistence); 041 } 042 043 /** 044 * @see org.activemq.store.cache.CachePersistenceAdapter#createMessageCache(java.lang.String) 045 */ 046 protected MessageCache createMessageCache(String destinationName) { 047 return new SimpleMessageCache(cacheSize); 048 } 049 050 // Properties 051 //------------------------------------------------------------------------- 052 053 /** 054 * @return the MAX size that ech destination's LRU can grow to. 055 */ 056 public int getCacheSize() { 057 return cacheSize; 058 } 059 /** 060 * @param the MAX size that ech destination's LRU can grow to. 061 */ 062 public void setCacheSize(int cacheSize) { 063 this.cacheSize = cacheSize; 064 } 065 066 }