1 22 package org.jboss.ejb.plugins.cmp.jdbc2.schema; 23 24 25 import javax.transaction.Transaction ; 26 27 31 public interface Cache 32 { 33 class RemoveException extends RuntimeException 34 { 35 public RemoveException() 36 { 37 } 38 39 public RemoveException(String message) 40 { 41 super(message); 42 } 43 44 public RemoveException(Throwable cause) 45 { 46 super(cause); 47 } 48 49 public RemoveException(String message, Throwable cause) 50 { 51 super(message, cause); 52 } 53 } 54 55 void lock(); 56 57 void lock(Object key); 58 59 void unlock(); 60 61 void unlock(Object key); 62 63 Object [] getFields(Object pk); 64 65 Object [] getRelations(Object pk); 66 67 void put(Transaction tx, Object pk, Object [] fields, Object [] relations); 68 69 void remove(Transaction tx, Object pk) throws RemoveException; 70 71 boolean contains(Transaction tx, Object pk); 72 73 void lockForUpdate(Transaction tx, Object pk) throws Exception ; 74 75 void releaseLock(Transaction tx, Object pk) throws Exception ; 76 77 void flush(); 78 79 Cache NONE = new Cache() 80 { 81 public void lock() 82 { 83 } 84 85 public void lock(Object key) 86 { 87 } 88 89 public void unlock() 90 { 91 } 92 93 public void unlock(Object key) 94 { 95 } 96 97 public Object [] getFields(Object pk) 98 { 99 return null; 100 } 101 102 public Object [] getRelations(Object pk) 103 { 104 return null; 105 } 106 107 public void put(Transaction tx, Object pk, Object [] fields, Object [] relations) 108 { 109 } 110 111 public void remove(Transaction tx, Object pk) 112 { 113 } 114 115 public boolean contains(Transaction tx, Object pk) 116 { 117 return false; 118 } 119 120 public void lockForUpdate(Transaction tx, Object pk) throws Exception 121 { 122 } 123 124 public void releaseLock(Transaction tx, Object pk) throws Exception 125 { 126 } 127 128 public void flush() 129 { 130 } 131 }; 132 133 interface CacheLoader 134 { 135 Object loadFromCache(Object value); 136 137 Object getCachedValue(); 138 } 139 140 interface Listener 141 { 142 void contention(int partitionIndex, long time); 143 144 void eviction(int partitionIndex, Object pk, int size); 145 146 void hit(int partitionIndex); 147 148 void miss(int partitionIndex); 149 150 public Listener NOOP = new Listener() 151 { 152 public void contention(int partitionIndex, long time) 153 { 154 } 155 156 public void eviction(int partitionIndex, Object pk, int size) 157 { 158 } 159 160 public void hit(int partitionIndex) 161 { 162 } 163 164 public void miss(int partitionIndex) 165 { 166 } 167 }; 168 } 169 } 170 | Popular Tags |