2

我正在尝试按照 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 之外,我还创建了以下接缝组件进行测试:

@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;
  }
 }
}

谢谢

4

1 回答 1

2

Add into your 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>
于 2010-05-27T05:55:18.487 回答