package com.paul.myejb.spring;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
@Component
public class MySpringBean {    
    @Autowired    
private CacheManager cacheManager;    
    @Cacheable(value = "my-local-cache", key = "#name")    
public String sayHello(String name)
    {
        System.out.println("


MySpringBean NO CACHE


");
        String result = "Hi " + name + ", I am Spring!";
        org.springframework.cache.Cache springCache = 
this.cacheManager.getCache("my-local-cache");
        System.out.println(springCache.get(name) == 
null ? "null" : springCache.get(name).get());
        springCache.put(name, result);        
return result;
    }
}