// Path: bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/CacheResolver.java
// public abstract interface CacheResolver {
// 
// 	ProxyManager<String> resolve(String cacheName);
// 	
// }
// 
// Path: bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/SyncCacheResolver.java
// public interface SyncCacheResolver extends CacheResolver {
// 
// }
// 
// Path: bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/exception/JCacheNotFoundException.java
// public class JCacheNotFoundException extends Bucket4jGeneralException {
// 
// 	private static final long serialVersionUID = 1L;
// 	
// 	private String cacheName;
// 	
// 	/**
// 	 * @param cacheName the missing cache key
// 	 */
// 	public JCacheNotFoundException(String cacheName) {
// 		this.cacheName = cacheName;
// 	}
// 
// 	public String getCacheName() {
// 		return cacheName;
// 	}
// 
// 	public void setCacheName(String cacheName) {
// 		this.cacheName = cacheName;
// 	}
// 
// }


import javax.cache.Cache;
import javax.cache.CacheManager;
import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheResolver;
import com.giffing.bucket4j.spring.boot.starter.config.cache.SyncCacheResolver;
import com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException;
import io.github.bucket4j.Bucket4j;
import io.github.bucket4j.distributed.proxy.ProxyManager;
import io.github.bucket4j.grid.jcache.JCacheProxyManager;

package com.giffing.bucket4j.spring.boot.starter.config.cache.jcache;




/**
 * This class is the JCache (JSR-107) implementation of the {@link CacheResolver}.
 * It uses Bucket4Js {@link JCacheProxyManager} to implement the {@link ProxyManager}.
 *
 */
public class JCacheCacheResolver implements SyncCacheResolver {
	
	private CacheManager cacheManager;

	public JCacheCacheResolver(CacheManager cacheManager) {
		this.cacheManager = cacheManager;
	}
	
	public ProxyManager<String> resolve(String cacheName) {
		Cache springCache = cacheManager.getCache(cacheName);
		if (springCache == null) {

// Path: bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/CacheResolver.java
// public abstract interface CacheResolver {
// 
// 	ProxyManager<String> resolve(String cacheName);
// 	
// }
// 
// Path: bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/SyncCacheResolver.java
// public interface SyncCacheResolver extends CacheResolver {
// 
// }
// 
// Path: bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/exception/JCacheNotFoundException.java
// public class JCacheNotFoundException extends Bucket4jGeneralException {
// 
// 	private static final long serialVersionUID = 1L;
// 	
// 	private String cacheName;
// 	
// 	/**
// 	 * @param cacheName the missing cache key
// 	 */
// 	public JCacheNotFoundException(String cacheName) {
// 		this.cacheName = cacheName;
// 	}
// 
// 	public String getCacheName() {
// 		return cacheName;
// 	}
// 
// 	public void setCacheName(String cacheName) {
// 		this.cacheName = cacheName;
// 	}
// 
// }


// Path: bucket4j-spring-boot-starter/src/main/java/com/giffing/bucket4j/spring/boot/starter/config/cache/jcache/JCacheCacheResolver.java
import javax.cache.Cache;
import javax.cache.CacheManager;
import com.giffing.bucket4j.spring.boot.starter.config.cache.CacheResolver;
import com.giffing.bucket4j.spring.boot.starter.config.cache.SyncCacheResolver;
import com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException;
import io.github.bucket4j.Bucket4j;
import io.github.bucket4j.distributed.proxy.ProxyManager;
import io.github.bucket4j.grid.jcache.JCacheProxyManager;

package com.giffing.bucket4j.spring.boot.starter.config.cache.jcache;




/**
 * This class is the JCache (JSR-107) implementation of the {@link CacheResolver}.
 * It uses Bucket4Js {@link JCacheProxyManager} to implement the {@link ProxyManager}.
 *
 */
public class JCacheCacheResolver implements SyncCacheResolver {
	
	private CacheManager cacheManager;

	public JCacheCacheResolver(CacheManager cacheManager) {
		this.cacheManager = cacheManager;
	}
	
	public ProxyManager<String> resolve(String cacheName) {
		Cache springCache = cacheManager.getCache(cacheName);
		if (springCache == null) {

			throw new JCacheNotFoundException(cacheName);
