首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

善用Spring的地图

2012-09-06 
善用Spring的mappublic class DefaultCacheManager implements CacheManager {??? private static final L

善用Spring的map

public class DefaultCacheManager implements CacheManager {

??? private static final Logger log = LoggerFactory.getLogger(CacheManager.class);
??? private Map???????????????? cacheStoreProviders;

??? public Map getCacheStoreProviders() {
??????? return Collections.unmodifiableMap(cacheStoreProviders);
??? }

??? public void setCacheStoreProviders(Map cacheStoreProviders) {
??????? this.cacheStoreProviders = cacheStoreProviders;
??? }

??? public Cache createCache(String registerKey, String cacheStore, Properties cachePolicy) throws CacheException {
??????? CacheStoreProvider provider = (CacheStoreProvider) cacheStoreProviders.get(cacheStore);

??????? if (provider == null) {
??????????? throw new CacheException("CacheStore not found: " + cacheStore);
??????? }

??????? CacheStore store = provider.getCacheStore(cachePolicy);

??????? return new BaseCache(store, registerKey);
??? }
}

<bean id="cacheManager" />
??? ??? ??? ??? </entry>
??? ??? ??? ??? <entry key="CREDITCACHE">
??? ??? ??? ??? ??? <ref local="guaranteeInfoCacheProvider" />
??? ??? ??? ??? </entry>
??? ??? ??? ??? <entry key="REALNAMECACHE">
??? ??? ??? ??? ??? <ref local="realnameInfoCacheProvider" />
??? ??? ??? ??? </entry>
??? ??? ??? ??? <entry key="CREDITPROMOTE">
??? ??? ??? ??? ??? <ref local="creditPromoteCacheProvider" />
??? ??? ??? ??? </entry>
??? ??? ??? </map>
??? ??? </property>

</bean>

热点排行