具有ehcache null的Seam缓存提供程序

时间:2009-10-28 16:12:22

标签: java hibernate seam ehcache

我正在尝试按照jboss页面的教程配置seam / ehcache:

http://docs.jboss.org/seam/2.1.2/reference/en-US/html/cache.html

我将ehcache.1.2.3.jar放在project.ear / lib中并注入了CacheProvider,但CacheProvider总是返回null。该文档没有显示ehcache的任何附加配置,仅适用于jboss缓存。

我可能做错了,不可能这么简单:)。

除了将jar放入/ lib之外,我创建了以下的seam组件来测试:

@Scope(ScopeType.SESSION)
@Name("cacheBean")
public class CacheSeamBean implements java.io.Serializable {

 @In(required=false, create=true) 
 private EntityManager em;

 @Logger 
 private Log log;

 @In
 private Events events;

 @In CacheProvider cacheProvider;

 Boolean blLoaded = Boolean.FALSE;

 @Create
 public void buscar() {

  if (!blLoaded){
   List<Parametro> lstParametro = em.createQuery("select p from Parametro p").getResultList();
   for (Parametro parametro : lstParametro){
    cacheProvider.put(parametro.getCodigo(), parametro.getValor());
   }
   blLoaded= Boolean.TRUE;
  }
 }
}

由于

1 个答案:

答案 0 :(得分:2)

添加到components.xml:

<components xmlns="http://jboss.com/products/seam/components"
...
            xmlns:cache="http://jboss.com/products/seam/cache"
            xsi:schemaLocation=
                    "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
               http://jboss.com/products/seam/cache http://www.jboss.com/products/seam/cache-2.1.xsd">

...
   <cache:eh-cache-provider/>
...
</components>