1 package org.tigris.scarab.services.cache; 2 3 48 49 import java.io.Serializable ; 50 import java.util.Map ; 51 52 import org.apache.fulcrum.TurbineServices; 53 import org.apache.turbine.services.yaaficomponent.YaafiComponentService; 54 import org.tigris.scarab.tools.localization.L10NKeySet; 55 import org.tigris.scarab.util.ScarabRuntimeException; 56 57 64 public class ScarabCache { 65 66 private static ScarabCacheService scarabCacheService; 67 68 public static Map getMap() { 69 return getService().getMapImpl(); 70 } 71 72 public static void clear() { 73 getService().clearImpl(); 74 } 75 76 public static Object get(Serializable instanceOrClass, String method) { 77 78 return getService().getImpl(instanceOrClass, method); 79 } 80 81 public static Object get(Serializable instanceOrClass, String method, Serializable arg1) { 82 83 return getService().getImpl(instanceOrClass, method, arg1); 84 } 85 86 public static Object get(Serializable instanceOrClass, String method, Serializable arg1, Serializable arg2) { 87 return getService().getImpl(instanceOrClass, method, arg1, arg2); 88 } 89 90 public static Object get(Serializable instanceOrClass, String method, Serializable arg1, Serializable arg2, 91 Serializable arg3) { 92 return getService().getImpl(instanceOrClass, method, arg1, arg2, arg3); 93 } 94 95 public static Object get(Serializable [] keys) { 96 return getService().getImpl(keys); 97 } 98 99 public static void put(Object value, Serializable instanceOrClass, String method) { 100 getService().putImpl(value, instanceOrClass, method); 101 } 102 103 public static void put(Object value, Serializable instanceOrClass, String method, Serializable arg1) { 104 getService().putImpl(value, instanceOrClass, method, arg1); 105 } 106 107 public static void put(Object value, Serializable instanceOrClass, String method, Serializable arg1, 108 Serializable arg2) { 109 getService().putImpl(value, instanceOrClass, method, arg1, arg2); 110 } 111 112 public static void put(Object value, Serializable instanceOrClass, String method, Serializable arg1, 113 Serializable arg2, Serializable arg3) { 114 getService().putImpl(value, instanceOrClass, method, arg1, arg2, arg3); 115 } 116 117 public static void put(Object value, Serializable [] keys) { 118 getService().putImpl(value, keys); 119 } 120 121 126 public static final ScarabCacheService getService() { 127 if (scarabCacheService == null) { 128 try { 129 YaafiComponentService yaafi = (YaafiComponentService) TurbineServices.getInstance().getService( 130 YaafiComponentService.SERVICE_NAME); 131 scarabCacheService = (ScarabCacheService) yaafi.lookup(ScarabCacheService.class.getName()); 132 } catch (Exception e) { 133 throw new ScarabRuntimeException( 134 L10NKeySet.ExceptionScarabCacheService, e); 135 } 136 } 137 return scarabCacheService; 138 } 139 140 public static void setScarabCacheService(ScarabCacheService scarabCacheService) { 141 ScarabCache.scarabCacheService = scarabCacheService; 142 } 143 } | Popular Tags |