开发者

Seam cache provider with ehcache null

I'm trying to configure seam/ehcache following the tutorial from jboss page:

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

I put the ehcache.1.2.3.jar in project.ear/lib and injected CacheProvider as especified, but the CacheProvider always return null. The docu开发者_运维百科mentation doesn't show any aditional configuration for ehcache, just for jboss cache.

I am probably doing something wrong, it's impossible be so easy :).

besides put the jar in /lib, i created the following seam component to test:

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

Thanks


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜