1 24 25 package org.objectweb.cjdbc.controller.cache.result; 26 27 import java.util.Iterator ; 28 29 import org.objectweb.cjdbc.common.sql.AbstractWriteRequest; 30 import org.objectweb.cjdbc.common.sql.ParsingGranularities; 31 import org.objectweb.cjdbc.common.sql.SelectRequest; 32 import org.objectweb.cjdbc.common.sql.UpdateRequest; 33 import org.objectweb.cjdbc.controller.cache.result.entries.AbstractResultCacheEntry; 34 import org.objectweb.cjdbc.controller.cache.result.schema.CacheDatabaseTable; 35 36 47 public class ResultCacheTable extends ResultCache 48 { 49 55 public ResultCacheTable(int maxEntries, int pendingTimeout) 56 { 57 super(maxEntries, pendingTimeout); 58 parsingGranularity = ParsingGranularities.TABLE; 59 } 60 61 64 protected void processAddToCache(AbstractResultCacheEntry qe) 65 { 66 SelectRequest request = qe.getRequest(); 67 for (Iterator i = request.getFrom().iterator(); i.hasNext();) 68 cdbs.getTable((String ) i.next()).addCacheEntry(qe); 69 } 70 71 74 public boolean isUpdateNecessary(UpdateRequest request) 75 { 76 return true; 77 } 78 79 82 protected void processWriteNotify(AbstractWriteRequest request) 83 { 84 CacheDatabaseTable cdt = cdbs.getTable(request.getTableName()); 85 86 if (cdt != null) 87 cdt.invalidateAll(); 88 else 89 { 90 logger.warn("Table " + request.getTableName() 91 + " not found in cache schema. Flushing whole cache."); 92 flushCache(); 93 } 94 } 95 96 99 public String getName() 100 { 101 return "table"; 102 } 103 } | Popular Tags |