package org.springframework.samples.petclinic.system;

import java.util.concurrent.TimeUnit;
import javax.cache.CacheManager;

import org.ehcache.config.CacheConfiguration;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;
import org.ehcache.config.units.EntryUnit;
import org.ehcache.expiry.Duration;
import org.ehcache.expiry.Expirations;
import org.ehcache.jsr107.Eh107Configuration;

import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * Cache could be disable in unit test.
 */
@Configuration
@EnableCaching
@Profile("production")
class CacheConfig {

    @Bean
    public JCacheManagerCustomizer cacheManagerCustomizer() {
        return new JCacheManagerCustomizer() {
            @Override
            public void customize(CacheManager cacheManager) {
                CacheConfiguration<Object, Object> config = CacheConfigurationBuilder
                    .newCacheConfigurationBuilder(Object.class, Object.class,
                        ResourcePoolsBuilder.newResourcePoolsBuilder()
                            .heap(100, EntryUnit.ENTRIES))
                    .withExpiry(Expirations.timeToLiveExpiration(Duration.of(60, TimeUnit.SECONDS)))
                    .build();
                cacheManager.createCache("vets", Eh107Configuration.fromEhcacheCacheConfiguration(config));
            }
        };
    }

}

@@ -968,129 +968,26 @@
 urn 
-new JCacheManagerCustomizer() %7B%0A            @Override%0A            public void customize(CacheManager cacheManager) %7B%0A    
+cacheManager -%3E %7B%0A
     
@@ -1080,20 +1080,16 @@
         
-  
-  
 .newCach
@@ -1158,20 +1158,16 @@
         
-    
 Resource
@@ -1229,20 +1229,16 @@
         
-   
- 
 .heap(10
@@ -1260,20 +1260,16 @@
 TRIES))%0A
-    
         
@@ -1357,20 +1357,16 @@
 ONDS)))%0A
-    
         
@@ -1395,20 +1395,16 @@
         
-    
 cacheMan
@@ -1491,22 +1491,8 @@
 ));%0A
-            %7D%0A
     

Replace anonymous class with lambda