-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify how a Cache, CacheManager and CachingProvider may be accessed / injected in a Java EE environment #208
Comments
I propose that we following the approach used by JMS 2.0 in Java EE 7. This would ensure consistency with the rest of the platform. An introduction to this is here: http://www.oracle.com/technetwork/articles/java/jms20-1947669.html Importantly however I don't think there's a requirement on behalf of the implementors to provide this functionality. It would be up to Java EE containers to ensure that these requirements are fulfilled using the standard API implemented by implementations. |
New Section on "Java EE Recommendations"
|
As part of detailing the integration of JCache with Java EE containers, we need to consider the following: Injection: @Inject
private CacheManager manager; //inject the default CacheManager @Resource(name = "cache/myCache")
private Cache<K, V> cache; //inject using the JNDI defined Cache Importantly this requires us to define the standard JNDI naming convention for Cache Managers and Caches. Instance Scoping: The answer is yes. Sharing should occur. What is not clear however is when the Cache is closed. Unlike JMS/JDBC etc, Caches should not be closed until an application is un-deployed as doing so (early) may reduce the benefit of caching in the first place. Transaction Scoping: The solution for this requirement is non-trivial. We need to consider: Default Caching Providers and Cache Managers: This could be injected from a well known JNDI resource. @Resource(name="java:comp/DefaultCachingProvider")
private CachingProvider provider;
@Resource(name="java:comp/DefaultCacheManager")
private CacheManager manager; Configuration Through Annotations: @CacheManager(
name="java:comp/cache/myCacheManager",
uri="some-custom-uri",
properties= {
"myProperty=value",
"myOtherProperty=otherValue"
}
)
@CacheDefinition(
name="java:comp/cache/mycache",
manager="java:comp/cache/myCacheManager",
storeByValue=true,
keyClass=String.class,
valueClass=MyCustomClass.class
) Importantly, CacheManagers and Caches defined in this way must be in the java:comp, java:module, java:app, or java:global namespaces, and they typically exist for as long as the application that defines them is deployed. Configuration Through Xml: |
Moved to JCache Next. |
So how is this now done "container-generic"? Please see my ticket #397 for details (Payara currently being used). |
We need to clarify this so that Java EE containers can correctly provide Caching resources to applications, especially using injection and/or via JNDI.
The text was updated successfully, but these errors were encountered: