1

我正在使用 Spring Security ACL,它需要定义缓存。到目前为止,我正在使用这个:

@Bean(name = { "defaultAclCache", "aclCache" })
protected AclCache defaultAclCache() {
    return new SpringCacheBasedAclCache(defaultAclJCacheFactory(), defaultPermissionGrantingStrategy(), defaultAclAuthorizationStrategy());
}

一切都很好。但是,我切换到使用jcache,现在返回一个与以下不兼容defaultAclJCacheFactory()的实例:javax.cache.CacheSpringCacheBasedAclCache

@Bean(name = { "defaultAclJCacheFactory", "aclJCacheFactory" })
protected Cache defaultAclJCacheFactory() {
    return cacheManager.getCache("acl_cache");
}

我试图搜索一个JCache实现,org.springframework.security.acls.model.AclCache但只有一个用于 spring 缓存和一个用于 EhCache。有没有计划推出一款jcache呢?

4

1 回答 1

4

您应该能够使用JCacheCacheManager实现来获取例如的org.springframework.cache.Cache实例:

@Bean(name = { "defaultAclCache", "aclCache" })
protected AclCache defaultAclCache(org.springframework.cache.CacheManager springCacheManager) {
    org.springframework.cache.Cache cache = 
        springCacheManager.getCache("acl_cache");
    return new SpringCacheBasedAclCache(cache, 
        defaultPermissionGrantingStrategy(), 
        defaultAclAuthorizationStrategy());
}

// Depending on your configuration, you may not even need this
@Bean
public JCacheCacheManager springCacheManager(javax.cache.CacheManager cacheManager) {
    return new JCacheCacheManager(cacheManager);
}
于 2014-06-11T13:39:00.230 回答