Skip to content
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

JCache and CDI #3

Open
biemond opened this issue Apr 1, 2012 · 2 comments
Open

JCache and CDI #3

biemond opened this issue Apr 1, 2012 · 2 comments

Comments

@biemond
Copy link

biemond commented Apr 1, 2012

Hi,

great work, I got it working with Memcached MySQL Cluster but now I want to do something with CDI like @CacheResult.
Do you know if this works and what has to be done.

thanks Edwin

@toelen
Copy link
Owner

toelen commented Apr 2, 2012

Hi,

I haven't tried the javax.cache annotations myself, but I guess this is more the responsibility of the environment you are running on. Maybe have a look at the javax.cache examples from tomcat, jboss etc. But I am not using one of those.

When using spring you could take a look at http://blog.springsource.org/2011/02/23/spring-3-1-m1-caching/ but than you might be better of using https://github.com/toelen/spymemcached-springcache as well.

When you have it working please let me know what works for you, than I can put this on the wiki.

Regards,
Leen

@biemond
Copy link
Author

biemond commented Apr 9, 2012

Hi,

I think it is the responsibility of the jcache provider.
you need to configure some like this in the web.xml or in a spring xml to initialize the jcache.

System.setProperty("spymemcachedservers", servers);

SpyCachingProvider provider = new SpyCachingProvider();
MemcachedClient client = new MemcachedClient(addr);

cacheManager = provider.createCacheManager(provider.getDefaultClassLoader(), "default");
cache = cacheManager.<String, String> createCacheBuilder("cacheName").build();

I will do some more investigation and let you know.

By the way are you also making an 0.6 jcache implementation or waiting for the final.

thanks

I know now some more.

First create an implementation of javax.cache.annotation.BeanProvider like this

https://github.com/jsr107/jsr107tck/blob/master/cdi-weld-annotations-test-harness/src/main/java/org/jsr107/tck/annotations/cdi/test/CdiBeanProvider.java

and then tell CDI where to find it declaring a resource named javax.cache.annotation.BeanProvider in the classpath at /META-INF/services/.

https://github.com/jsr107/jsr107tck/blob/master/cdi-weld-annotations-test-harness/src/main/resources/META-INF/services/javax.cache.annotation.BeanProvider

Will try it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants