善用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>