1 16 17 package org.apache.jetspeed.services.portletcache; 18 19 import java.io.IOException ; 20 21 import org.apache.turbine.services.TurbineServices; 22 import org.apache.turbine.services.cache.GlobalCacheService; 23 import org.apache.turbine.services.cache.CachedObject; 24 import org.apache.turbine.services.cache.ObjectExpiredException; 25 26 27 35 public class GlobalCache { 36 37 44 public static void addObject( String id, CachedObject o ) { 45 46 GlobalCacheService gcs = (GlobalCacheService)TurbineServices 47 .getInstance() 48 .getService( GlobalCacheService.SERVICE_NAME ); 49 50 gcs.addObject( id, o ); 51 } 52 53 61 public static CachedObject getObject(String id) 62 throws ObjectExpiredException { 63 64 GlobalCacheService gcs = (GlobalCacheService)TurbineServices 65 .getInstance() 66 .getService( GlobalCacheService.SERVICE_NAME ); 67 68 return gcs.getObject( id ); 69 } 70 71 77 public static int getCacheSize() 78 throws IOException { 79 GlobalCacheService gcs = (GlobalCacheService)TurbineServices 80 .getInstance() 81 .getService( GlobalCacheService.SERVICE_NAME ); 82 83 return gcs.getCacheSize(); 84 } 85 86 91 public static int getNumberOfObjects() { 92 int tempInt = 0; 93 GlobalCacheService gcs = (GlobalCacheService)TurbineServices 94 .getInstance() 95 .getService( GlobalCacheService.SERVICE_NAME ); 96 97 tempInt = gcs.getNumberOfObjects(); 98 return tempInt; 99 } 100 101 104 public void flushCache() { 105 GlobalCacheService gcs = (GlobalCacheService)TurbineServices 106 .getInstance() 107 .getService( GlobalCacheService.SERVICE_NAME ); 108 109 gcs.flushCache(); 110 } 111 } 112 | Popular Tags |