content: package com.alicp.jetcache.autoconfigure;
  
  import com.alicp.jetcache.CacheBuilder;
  import com.alicp.jetcache.anno.CacheConsts;
  import com.alicp.jetcache.external.MockRemoteCacheBuilder;
  import org.springframework.context.annotation.Conditional;
  import org.springframework.stereotype.Component;
  
  /**
   * Created on 2016/12/2.
   *
   * @author huangli
   */
  @Component
  @Conditional(MockRemoteCacheAutoConfiguration.MockRemoteCacheCondition.class)
  public class MockRemoteCacheAutoConfiguration extends ExternalCacheAutoInit {
      public MockRemoteCacheAutoConfiguration() {
          super("mock");
      }
  
      @Override
      protected CacheBuilder initCache(ConfigTree ct, String cacheAreaWithPrefix) {
          MockRemoteCacheBuilder builder = MockRemoteCacheBuilder.createMockRemoteCacheBuilder();
          parseGeneralConfig(builder, ct);
          return builder;
      }
  
      @Override
      protected void parseGeneralConfig(CacheBuilder builder, ConfigTree ct) {
          super.parseGeneralConfig(builder, ct);
          MockRemoteCacheBuilder b = (MockRemoteCacheBuilder) builder;
          b.limit(Integer.parseInt(ct.getProperty("limit", String.valueOf(CacheConsts.DEFAULT_LOCAL_LIMIT))));
      }
  
      public static class MockRemoteCacheCondition extends JetCacheCondition {
          public MockRemoteCacheCondition() {
              super("mock");
          }
      }
  }
  