[infinispan-issues] [JBoss JIRA] (ISPN-10745) infinispan-jcache-remote does not support CDI caching annotations

Dan Berindei (Jira) issues at jboss.org
Wed Oct 16 05:29:00 EDT 2019


    [ https://issues.jboss.org/browse/ISPN-10745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13800226#comment-13800226 ] 

Dan Berindei commented on ISPN-10745:
-------------------------------------

The embedded implementation is not complete either: JSR-107 specifies that the caching annotations should either use the default cache manager OR the {{CacheResolverFactory}} provided by the user (e.g. {{@CacheResult(cacheResolverFactory = InjectedCacheResolverFactory.class)}}.

The Infinispan embedded implementation ignores the {{cacheResolverFactory}} value and has instead 2 sets of interceptors:

* Unmanaged interceptors ({{org.infinispan.jcache.annotation.Cache*Interceptor}}) always use JCache's default cache manager
* Managed interceptors ({{org.infinispan.jcache.annotation.InjectedCache*Interceptor}}) use {{EmbeddedCacheManager}} instances (possibly produced by the application server).
   They search for an existing cache with the required name in any of the existing {{EmbeddedCacheManager}} s, and if the cache does not exist yet it is created in CDI's {{@Default}} {{EmbeddedCacheManager}}.

I believe we should deprecate the managed interceptors and make the unmanaged interceptors support non-JCache {{EmbeddedCacheManager}} only with an explicit {{CacheResolverFactory}}. I'm not sure if there's any value in providing our own implementation, looking only at cache names, instead we should make it easy for users to wrap an injected {{EmbeddedCacheManager}} in a {{javax.cache.CacheManager}} bean and inject that.

Unfortunately, since CDI 1.1/1.2, interceptors specified in a library's {{beans.xml}} are no longer applied automatically to all the application beans, and users need to put the interceptor class names in their own {{beans.xml}}. That means we moving the interceptors to another package is a breaking change, and moving the unmanaged interceptors to {{infinispan-jcache-commons}} to support remote caches requires a package name change (because managed interceptors depend on {{infinispan-core}}, and the jars are OSGi bundles, making split packages a pain).


> infinispan-jcache-remote does not support CDI caching annotations
> -----------------------------------------------------------------
>
>                 Key: ISPN-10745
>                 URL: https://issues.jboss.org/browse/ISPN-10745
>             Project: Infinispan
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 9.4.16.Final, 10.0.0.CR3
>            Reporter: Dan Berindei
>            Priority: Major
>
> {{infinispan-jcache-remote}} does not have CDI interceptors for the JCache annotations like {{@CacheResult}}, so the annotations are ignored.
> The JCache TCK has tests for the annotations (e.g. {{InterceptionCacheNameOnEachMethodTest}}), but those tests used to pass by accident: a Weld dependency ({{slf4j-api}}) was missing in the {{tck-remote}} maven-failsafe-plugin execution, and {{AbstractInterceptionTest}} was automatically excluding them.
> Weld 2.3.4.Final removed the {{slf4j-api}} dependency and the {{tck-remote}} interception tests started failing after the upgrade, but we did not notice because of ISPN-10379.



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the infinispan-issues mailing list