dafabet手机版登录3-jcache

2018-08-25 -

  1 public synchronized Iterable getCachingProviders(ClassLoader classLoader) {

  2

  3 final ClassLoader serviceClassLoader=classLoader==null ? getDefaultClassLoader() : classLoader;

  4 LinkedHashMap providers= cachingProviders.get(serviceClassLoader);

  5

  6 if (providers==null) {

  7 //假设体系参数中设置了javax.cache.spi.CachingProvider相干值,则加以载该值对应的类

  8 if (System.getProperties().containsKey(JAVAX_CACHE_CACHING_PROVIDER)) {

  9 String className= System.getProperty(JAVAX_CACHE_CACHING_PROVIDER);

  10 providers=new LinkedHashMap();

  11 providers.put(className, loadCachingProvider(className, serviceClassLoader));

  12

  13 } else {

  14 providers=AccessController.doPrivileged(new PrivilegedAction>() {

  15 @Override

  16 public LinkedHashMap run() {

  17 LinkedHashMap result=new LinkedHashMap();

  18 //ServiceLoader.load会lazy加以载因此适宜环境的类

  19 ServiceLoader serviceLoader=ServiceLoader.load(CachingProvider.class, serviceClassLoader);

  20 //此雕刻边serviceLoader.iterator().next()会真正终止加以载,

  21 //假设依顶赖中包罗多个jcache完成,终极的result就会拥有多个元斋

  22 for (CachingProvider provider : serviceLoader) {

  23 result.put(provider.getClass().getName(), provider);

  24 }

  25 return result;

  26 }

  27 });

  28

  29 }

  30

  31 cachingProviders.put(serviceClassLoader, providers);

  32 }

  33

  34 return providers.values();

  35 }

  文字到来源:https://www.cnblogs.com/holoyong/p/7263140.html