You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by sgjava <sg...@gmail.com> on 2015/08/20 16:01:27 UTC

JCache CDI

I've done some research and found:

http://www.tomitribe.com/blog/2015/06/using-jcache-with-cdi This works, but
looking at the POM it uses the Maven Shade plugin to filter out packages
(not a huge deal), but this seams like a hack (no disrespect).

I also looked at http://www.knitelius.com/2015/06/29/using-jcache-in-jee-67
which I was unable to get the annotations working or at least see the values
in the cache using cache.get after a @CacheResult. I can get JCache working
fine without the annotations, but CDI is the route I want to go. So my
question is do I wait for things to stabilize (remember this is for
production) or is there a JCache CDI solution that works now that I can feel
confident that when included in Java EE 8 I will not have to change any
code. I'm in production with TomEE 2.0.0 and 7.0.0 and they are very stable.




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943.html
Sent from the TomEE Users mailing list archive at Nabble.com.

RE: JCache CDI

Posted by sgjava <sg...@gmail.com>.
That is for Java EE 6, but thanks.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675947.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JCache CDI

Posted by sgjava <sg...@gmail.com>.
OK, looks like I'm moving forward. Now I get:

java.lang.ClassCastException:
org.jsr107.ri.annotations.DefaultGeneratedCacheKey cannot be cast to
java.lang.String
    at
com.codeferm.services.jaxrs.CacheBeanTest.testCache(CacheBeanTest.java:95)

On Thu, Aug 27, 2015 at 11:04 AM, Romain Manni-Bucau [via TomEE & OpenEJB] <
ml-node+s979440n4675994h25@n4.nabble.com> wrote:

> EJBContainer is about jars and doesnt know anything of wars until you use
> tomee (embedded or not but needs a packaging phase). ApplicationComposer
> is
> nicer for such small tests in general since you can list all you need in
> @Classes
>
> Having beans.xml only in META-INF works even if it would be better to keep
> it in WEB-INF for consistency with other descriptors
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 17:06 GMT+02:00 Steve Goldsmith <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675994&i=0>>:
>
> > It here any issue with having beans.xml in META-INF and WEB-INF from a
> > deployment to TomEE stand alone? Or can I specify WEB-INF scanning from
> > EJBContainer?
> >
> > On Thu, Aug 27, 2015 at 10:59 AM, Romain Manni-Bucau <
> > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4675994&i=1>>
> > wrote:
> >
> > > EJBContainer doesnt read WEB-INF by default so put your beans.xml in
> > > META-INF
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-27 16:45 GMT+02:00 sgjava <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675994&i=2>>:
> > >
> > > > https://github.com/sgjava/my-jaxrs-test
> > > >
> > > > CacheBeanTest
> > > >
> > > > Thanks.
> > > >
> > > > On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE &
> > > OpenEJB]
> > > > <
> > > > [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675994&i=3>> wrote:
> > > >
> > > > > hmm, push this sample on github, I'll try to check in the coming
> > hours
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
> > > > >
> > > > > > I get no cache results using:
> > > > > >
> > > > > >         keyValueBean.add("key1", "value1");
> > > > > >         final Cache<String, String> testCache =
> > > > > > cacheBean.getCacheManager().
> > > > > >                 getCache("testCache");
> > > > > >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> > > > > testCache.
> > > > > >                 iterator();
> > > > > >         while (allCacheEntries.hasNext()) {
> > > > > >             Cache.Entry<String, String> currentEntry =
> > > > > > allCacheEntries.next();
> > > > > >             log.info("Key: " + currentEntry.getKey() + " Value:
> "
> > > > > >                     + currentEntry.getValue());
> > > > > >         }
> > > > > >
> > > > > > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE
> &
> > > > > OpenEJB]
> > > > > > <
> > > > > > [hidden email] <http://
> > > > /user/SendEmail.jtp?type=node&node=4675990&i=1>>
> > > > > wrote:
> > > > > >
> > > > > > > no default implementation in the API but clearly de default in
> > the
> > > > > > > provider
> > > > > > > you can maybe reuse. Iterating over the cache - for test
> purpose
> > -
> > > is
> > > > > an
> > > > > > > alternative you can use.
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > > > > > >
> > > > > > > > Ah, OK, that wasn't evident from what I've read so far. Is
> > there
> > > a
> > > > > > > default
> > > > > > > > implementation or do you have to create one?
> > > > > > > >
> > > > > > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden
> > > email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > no, @CacheKey doesnt mean your parameter is the key, it
> means
> > > it
> > > > > is
> > > > > > > used
> > > > > > > > in
> > > > > > > > > the key but the key is still a GeneratedCacheKey
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Romain Manni-Bucau
> > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > >
> > > > > > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > > > > > >
> > > > > > > > > > I'm just not able to see the cached values by using:
> > > > > > > > > >
> > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > >                 getCache("testCache");
> > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > testCache.getName()));
> > > > > > > > > >
> > > > > > > > > > *        // This should display value1, but it doesn't
> > > > > > > log.info
> > > > > > > > > > <http://log.info>(String.format("Value: %s",
> > > > > > > testCache.get("key1")));*
> > > > > > > > > >
> > > > > > > > > > ehcache.xml:
> > > > > > > > > >
> > > > > > > > > > <ehcache xmlns:xsi="
> > > http://www.w3.org/2001/XMLSchema-instance"
> > > > > > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > > > > > >          dynamicConfig="true">
> > > > > > > > > >
> > > > > > > > > >     <defaultCache
> > > > > > > > > >         maxEntriesLocalHeap="1000000"
> > > > > > > > > >         eternal="false"
> > > > > > > > > >         timeToIdleSeconds="86400"
> > > > > > > > > >         timeToLiveSeconds="86400"
> > > > > > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > > > > > >     </defaultCache>
> > > > > > > > > >
> > > > > > > > > >     <cache name="testCache"
> > > > > > > > > >            maxEntriesLocalHeap="1000000"
> > > > > > > > > >            eternal="false"
> > > > > > > > > >            timeToIdleSeconds="600"
> > > > > > > > > >            timeToLiveSeconds="600"
> > > > > > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > > > > > >     </cache>
> > > > > > > > > >
> > > > > > > > > > </ehcache>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > > > > > [hidden email] <http://
> > > > > > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > > > > > >
> > > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > looks good, did you encounter any issue or did you ask
> > only
> > > > > for a
> > > > > > > > > review?
> > > > > > > > > > >
> > > > > > > > > > > Note: beans.xml should be empty if already provided by
> ri
> > > > jar.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
>  Blog
> > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > Tomitriber
> > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > >
> > > > > > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > > > > > >
> > > > > > > > > > > > Your examples all have invokers, etc. but none of
> the
> > > other
> > > > > > > example
> > > > > > > > > > I've
> > > > > > > > > > > > seen require this. Since you don't have time to
> look,
> > > maybe
> > > > > you
> > > > > > > can
> > > > > > > > > see
> > > > > > > > > > > if
> > > > > > > > > > > > my structure looks good:
> > > > > > > > > > > >
> > > > > > > > > > > > pom.xml:
> > > > > > > > > > > >
> > > > > > > > > > > >         <dependency>
> > > > > > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > > > > > >
> > > > > <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > > > > > >             <version>1.0.0</version>
> > > > > > > > > > > >         </dependency>
> > > > > > > > > > > >         <dependency>
> > > > > > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > > > > > >             <version>1.0.1</version>
> > > > > > > > > > > >             <scope>compile</scope>
> > > > > > > > > > > >         </dependency>
> > > > > > > > > > > >
> > > > > > > > > > > > beans.xml:
> > > > > > > > > > > >
> > > > > > > > > > > > <beans>
> > > > > > > > > > > >     <interceptors>
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > >
> > > <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > >
> > > > > >
> > > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > > > > > >
> > > > > > > > > >
> > > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > > > > > >     </interceptors>
> > > > > > > > > > > > </beans>
> > > > > > > > > > > >
> > > > > > > > > > > > Cache bean:
> > > > > > > > > > > >
> > > > > > > > > > > > @Singleton
> > > > > > > > > > > > @Startup
> > > > > > > > > > > > @Lock(READ)
> > > > > > > > > > > > public class CacheBean {
> > > > > > > > > > > >
> > > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Caching provider.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Cache manager.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     private CacheManager cacheManager;
> > > > > > > > > > > >
> > > > > > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > > > > > >         return cacheManager;
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Using EHCache provider configured via
> > ehcache.xml
> > > in
> > > > > > > > > classpath.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > > >     @PostConstruct
> > > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > > >     public void init() {
> > > > > > > > > > > >         log.info("PostConstruct");
> > > > > > > > > > > >         cachingProvider =
> Caching.getCachingProvider();
> > > > > > > > > > > >         cacheManager =
> > cachingProvider.getCacheManager();
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Destroy cache.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > > >     @PreDestroy
> > > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > > >     public void destroy() {
> > > > > > > > > > > >         log.info("PreDestroy");
> > > > > > > > > > > >         cacheManager.close();
> > > > > > > > > > > >         cachingProvider.close();
> > > > > > > > > > > >     }
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > Bean to test annotations:
> > > > > > > > > > > >
> > > > > > > > > > > > @Stateless
> > > > > > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > > > > > public class KeyValueBean {
> > > > > > > > > > > >
> > > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > > > > > > >
> > > > > > > > > > > >     @CacheResult
> > > > > > > > > > > >     public String add(@CacheKey String key, String
> > > value) {
> > > > > > > > > > > >         log.info(String.format("Adding key: %s,
> value:
> > > > %s",
> > > > > > > key,
> > > > > > > > > > > value));
> > > > > > > > > > > >         return value;
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     @CacheRemoveAll
> > > > > > > > > > > >     public void invalidateCache() {
> > > > > > > > > > > >         log.info("Cache invalidated");
> > > > > > > > > > > >     }
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > Unit test:
> > > > > > > > > > > >
> > > > > > > > > > > > public class CacheBeanTest {
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Logger.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     private static final Logger log =
> > > > > > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > > > > > >             getName());
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Injected cache bean.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @EJB
> > > > > > > > > > > >     private CacheBean cacheBean;
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Our key/value bean.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @EJB
> > > > > > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * EJB container.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     private static EJBContainer container;
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Start EJB container.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @BeforeClass
> > > > > > > > > > > >     public static void setUpClass() {
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Close caching provider/manager and EJB
> > container.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @AfterClass
> > > > > > > > > > > >     public static void tearDownClass() {
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Set up.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @Before
> > > > > > > > > > > >     public void setUp() throws NamingException {
> > > > > > > > > > > >         log.info("setUp()");
> > > > > > > > > > > >         container =
> EJBContainer.createEJBContainer();
> > > > > > > > > > > >         container.getContext().bind("inject", this);
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Tear down.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @After
> > > > > > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > > > > > >         container.getContext().unbind("inject");
> > > > > > > > > > > >         container.close();
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @Test
> > > > > > > > > > > >     public final void testCache() {
> > > > > > > > > > > >         log.info("testCache");
> > > > > > > > > > > >         assertNotNull(cacheBean);
> > > > > > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > > >                 getCacheNames()));
> > > > > > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > > >                 getCache("testCache");
> > > > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > > > testCache.getName()));
> > > > > > > > > > > >         // This should display value1, but it
> doesn't
> > > > > > > > > > > >         log.info(String.format("Value: %s",
> > > > > > > > testCache.get("key1")));
> > > > > > > > > > > >         testCache.close();
> > > > > > > > > > > >     }
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau
> > [via
> > > > > TomEE
> > > > > > &
> > > > > > > > > > > OpenEJB] <
> > > > > > > > > > > > [hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>>
> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > dont have time to look now but here a sample i
> wrote
> > > > which
> > > > > is
> > > > > > > > green
> > > > > > > > > > > > there:
> > > > > > > > > > > > >
> > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> > Blog
> > > > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau>
> |
> > > > > > > Tomitriber
> > > > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > > > > > <http://
> > > > /user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'm not sure the <interceptors> in beans.xml are
> > > being
> > > > > > > loaded
> > > > > > > > or
> > > > > > > > > > > that I
> > > > > > > > > > > > > > have
> > > > > > > > > > > > > > the container set up right for the unit test
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'm using the EHCache provider and it fires up
> fine
> > > and
> > > > > can
> > > > > > > > > > interact
> > > > > > > > > > > > > with
> > > > > > > > > > > > > > it, but CDI doesn't appear to be working. Any
> help
> > > > > getting
> > > > > > > the
> > > > > > > > > > > working
> > > > > > > > > > > > > in
> > > > > > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --
> > > > > > > > > > > > > > View this message in context:
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > > > > > Sent from the TomEE Users mailing list archive
> at
> > > > > > > Nabble.com.
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > ------------------------------
> > > > > > > > > > > > > If you reply to this email, your message will be
> > added
> > > to
> > > > > the
> > > > > > > > > > > discussion
> > > > > > > > > > > > > below:
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > > > > > <
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > > .
> > > > > > > > > > > > > NAML
> > > > > > > > > > > > > <
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > View this message in context:
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > > Nabble.com.
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Steven P. Goldsmith
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ------------------------------
> > > > > > > If you reply to this email, your message will be added to the
> > > > > discussion
> > > > > > > below:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > <
> > > > > >
> > > > > >
> > > > > > > .
> > > > > > > NAML
> > > > > > > <
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven P. Goldsmith
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > View this message in context:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > >
> > > > >
> > > > >
> > > > > ------------------------------
> > > > > If you reply to this email, your message will be added to the
> > > discussion
> > > > > below:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> > > > > To unsubscribe from JCache CDI, click here
> > > > > <
> > > >
> > >
> >
> > > >
> > > > > .
> > > > > NAML
> > > > > <
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Steven P. Goldsmith
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
> > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675994.html
> To unsubscribe from JCache CDI, click here
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5>
> .
> NAML
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Steven P. Goldsmith




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675997.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2015-08-27 17:13 GMT+02:00 sgjava <sg...@gmail.com>:

> OK, it works now:
>
> INFO: Key: org.jsr107.ri.annotations.DefaultGeneratedCacheKey@322dd3,
> Value: value3
> Aug 27, 2015 11:15:09 AM com.codeferm.services.jaxrs.CacheBeanTest
> testCache
> INFO: Key: org.jsr107.ri.annotations.DefaultGeneratedCacheKey@322dd1,
> Value: value1
> Aug 27, 2015 11:15:09 AM com.codeferm.services.jaxrs.CacheBeanTest
> testCache
> INFO: Key: org.jsr107.ri.annotations.DefaultGeneratedCacheKey@322dd2,
> Value: value2
>
> So, since I'll be using a WAR is there a way to use
> org.apache.tomee.embedded.Container or javax.ejb.embeddable.EJBContainer to
> deploy the WAR with caching? EJBContainer.createEJBContainer();
>         container.getContext().bind("inject", this); doesn't make sense in
> this context.
>
>
outch this is rude ;)

I ll try to share what I do, there are typically 2-3 typologies:

- For JAXRS applications I use a lot ApplicationComposer, makes development
cycles super fast
- For all kind of web applications I rely either on tomee-embedded with
classpath deployment - supports src/main/webapp :) - or when it is a
"enterprise" project and it needs to be "generic" I use arquillian even if
it needs a bit more setup
- Last option I saw few times is to use only war for java parts and the war
is just a packaging module, here EJBContainter still works and with its
single start/shutdown option is not slow


> On Thu, Aug 27, 2015 at 11:07 AM, Romain Manni-Bucau [via TomEE & OpenEJB]
> <
> ml-node+s979440n4675996h87@n4.nabble.com> wrote:
>
> > META-INF should be in the classpath so WEB-INF/classes for the war
> > target/classes for tests. easiest way to get it with maven is
> > src/main/resources
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-27 17:04 GMT+02:00 sgjava <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675996&i=0>>:
> >
> > > Also, should META-INF be in src/main/resources or src/main/webapp?
> > >
> > > On Thu, Aug 27, 2015 at 10:54 AM, Romain Manni-Bucau [via TomEE &
> > OpenEJB]
> > > <
> > > [hidden email] <http://
> /user/SendEmail.jtp?type=node&node=4675996&i=1>>
> > wrote:
> > >
> > > > EJBContainer doesnt read WEB-INF by default so put your beans.xml in
> > > > META-INF
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-27 16:45 GMT+02:00 sgjava <[hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675992&i=0>>:
> > > >
> > > > > https://github.com/sgjava/my-jaxrs-test
> > > > >
> > > > > CacheBeanTest
> > > > >
> > > > > Thanks.
> > > > >
> > > > > On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE &
> > > > OpenEJB]
> > > > > <
> > > > > [hidden email] <http://
> > > /user/SendEmail.jtp?type=node&node=4675992&i=1>>
> > > > wrote:
> > > > >
> > > > > > hmm, push this sample on github, I'll try to check in the coming
> > > hours
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
> > > > > >
> > > > > > > I get no cache results using:
> > > > > > >
> > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > >         final Cache<String, String> testCache =
> > > > > > > cacheBean.getCacheManager().
> > > > > > >                 getCache("testCache");
> > > > > > >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> > > > > > testCache.
> > > > > > >                 iterator();
> > > > > > >         while (allCacheEntries.hasNext()) {
> > > > > > >             Cache.Entry<String, String> currentEntry =
> > > > > > > allCacheEntries.next();
> > > > > > >             log.info("Key: " + currentEntry.getKey() + "
> Value:
> > "
> > > > > > >                     + currentEntry.getValue());
> > > > > > >         }
> > > > > > >
> > > > > > > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE
> > &
> > > > > > OpenEJB]
> > > > > > > <
> > > > > > > [hidden email] <http://
> > > > > /user/SendEmail.jtp?type=node&node=4675990&i=1>>
> > > > > > wrote:
> > > > > > >
> > > > > > > > no default implementation in the API but clearly de default
> in
> > > the
> > > > > > > > provider
> > > > > > > > you can maybe reuse. Iterating over the cache - for test
> > purpose
> > > -
> > > > is
> > > > > > an
> > > > > > > > alternative you can use.
> > > > > > > >
> > > > > > > >
> > > > > > > > Romain Manni-Bucau
> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > > <http://www.tomitribe.com>
> > > > > > > >
> > > > > > > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > > > > > > >
> > > > > > > > > Ah, OK, that wasn't evident from what I've read so far. Is
> > > there
> > > > a
> > > > > > > > default
> > > > > > > > > implementation or do you have to create one?
> > > > > > > > >
> > > > > > > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau
> <[hidden
> > > > email]
> > > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > > > > > > >
> > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > no, @CacheKey doesnt mean your parameter is the key, it
> > means
> > > > it
> > > > > > is
> > > > > > > > used
> > > > > > > > > in
> > > > > > > > > > the key but the key is still a GeneratedCacheKey
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > Tomitriber
> > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > >
> > > > > > > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden
> email]
> > > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > > > > > > >
> > > > > > > > > > > I'm just not able to see the cached values by using:
> > > > > > > > > > >
> > > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > >                 getCache("testCache");
> > > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > > testCache.getName()));
> > > > > > > > > > >
> > > > > > > > > > > *        // This should display value1, but it doesn't
> > > > > > > > log.info
> > > > > > > > > > > <http://log.info>(String.format("Value: %s",
> > > > > > > > testCache.get("key1")));*
> > > > > > > > > > >
> > > > > > > > > > > ehcache.xml:
> > > > > > > > > > >
> > > > > > > > > > > <ehcache xmlns:xsi="
> > > > http://www.w3.org/2001/XMLSchema-instance"
> > > > > > > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > > > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > > > > > > >          dynamicConfig="true">
> > > > > > > > > > >
> > > > > > > > > > >     <defaultCache
> > > > > > > > > > >         maxEntriesLocalHeap="1000000"
> > > > > > > > > > >         eternal="false"
> > > > > > > > > > >         timeToIdleSeconds="86400"
> > > > > > > > > > >         timeToLiveSeconds="86400"
> > > > > > > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > > > > > > >     </defaultCache>
> > > > > > > > > > >
> > > > > > > > > > >     <cache name="testCache"
> > > > > > > > > > >            maxEntriesLocalHeap="1000000"
> > > > > > > > > > >            eternal="false"
> > > > > > > > > > >            timeToIdleSeconds="600"
> > > > > > > > > > >            timeToLiveSeconds="600"
> > > > > > > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > > > > > > >     </cache>
> > > > > > > > > > >
> > > > > > > > > > > </ehcache>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > > > > > > [hidden email] <http://
> > > > > > > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > > > > > > >
> > > > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > looks good, did you encounter any issue or did you
> ask
> > > > only
> > > > > > for a
> > > > > > > > > > review?
> > > > > > > > > > > >
> > > > > > > > > > > > Note: beans.xml should be empty if already provided
> by
> > ri
> > > > > jar.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> >  Blog
> > > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > > Tomitriber
> > > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > > >
> > > > > > > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > > > > > > >
> > > > > > > > > > > > > Your examples all have invokers, etc. but none of
> > the
> > > > other
> > > > > > > > example
> > > > > > > > > > > I've
> > > > > > > > > > > > > seen require this. Since you don't have time to
> > look,
> > > > maybe
> > > > > > you
> > > > > > > > can
> > > > > > > > > > see
> > > > > > > > > > > > if
> > > > > > > > > > > > > my structure looks good:
> > > > > > > > > > > > >
> > > > > > > > > > > > > pom.xml:
> > > > > > > > > > > > >
> > > > > > > > > > > > >         <dependency>
> > > > > > > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > > > > > > >
> > > > > > <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > > > > > > >             <version>1.0.0</version>
> > > > > > > > > > > > >         </dependency>
> > > > > > > > > > > > >         <dependency>
> > > > > > > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > > > > > > >             <version>1.0.1</version>
> > > > > > > > > > > > >             <scope>compile</scope>
> > > > > > > > > > > > >         </dependency>
> > > > > > > > > > > > >
> > > > > > > > > > > > > beans.xml:
> > > > > > > > > > > > >
> > > > > > > > > > > > > <beans>
> > > > > > > > > > > > >     <interceptors>
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > >
> > > >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > >
> > > > > > >
> > > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > > > > > > >
> > > > > > > > > > >
> > > > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > > > > > > >     </interceptors>
> > > > > > > > > > > > > </beans>
> > > > > > > > > > > > >
> > > > > > > > > > > > > Cache bean:
> > > > > > > > > > > > >
> > > > > > > > > > > > > @Singleton
> > > > > > > > > > > > > @Startup
> > > > > > > > > > > > > @Lock(READ)
> > > > > > > > > > > > > public class CacheBean {
> > > > > > > > > > > > >
> > > > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Caching provider.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Cache manager.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     private CacheManager cacheManager;
> > > > > > > > > > > > >
> > > > > > > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > > > > > > >         return cacheManager;
> > > > > > > > > > > > >     }
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Using EHCache provider configured via
> > > ehcache.xml
> > > > in
> > > > > > > > > > classpath.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > > > >     @PostConstruct
> > > > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > > > >     public void init() {
> > > > > > > > > > > > >         log.info("PostConstruct");
> > > > > > > > > > > > >         cachingProvider =
> > Caching.getCachingProvider();
> > > > > > > > > > > > >         cacheManager =
> > > > cachingProvider.getCacheManager();
> > > > > > > > > > > > >     }
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Destroy cache.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > > > >     @PreDestroy
> > > > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > > > >     public void destroy() {
> > > > > > > > > > > > >         log.info("PreDestroy");
> > > > > > > > > > > > >         cacheManager.close();
> > > > > > > > > > > > >         cachingProvider.close();
> > > > > > > > > > > > >     }
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > Bean to test annotations:
> > > > > > > > > > > > >
> > > > > > > > > > > > > @Stateless
> > > > > > > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > > > > > > public class KeyValueBean {
> > > > > > > > > > > > >
> > > > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > > > >
>  getLogger(KeyValueBean.class.getName());
> > > > > > > > > > > > >
> > > > > > > > > > > > >     @CacheResult
> > > > > > > > > > > > >     public String add(@CacheKey String key, String
> > > > value) {
> > > > > > > > > > > > >         log.info(String.format("Adding key: %s,
> > value:
> > > > > %s",
> > > > > > > > key,
> > > > > > > > > > > > value));
> > > > > > > > > > > > >         return value;
> > > > > > > > > > > > >     }
> > > > > > > > > > > > >
> > > > > > > > > > > > >     @CacheRemoveAll
> > > > > > > > > > > > >     public void invalidateCache() {
> > > > > > > > > > > > >         log.info("Cache invalidated");
> > > > > > > > > > > > >     }
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > Unit test:
> > > > > > > > > > > > >
> > > > > > > > > > > > > public class CacheBeanTest {
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Logger.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     private static final Logger log =
> > > > > > > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > > > > > > >             getName());
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Injected cache bean.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     @EJB
> > > > > > > > > > > > >     private CacheBean cacheBean;
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Our key/value bean.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     @EJB
> > > > > > > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * EJB container.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     private static EJBContainer container;
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Start EJB container.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     @BeforeClass
> > > > > > > > > > > > >     public static void setUpClass() {
> > > > > > > > > > > > >     }
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Close caching provider/manager and EJB
> > > container.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     @AfterClass
> > > > > > > > > > > > >     public static void tearDownClass() {
> > > > > > > > > > > > >     }
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Set up.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     @Before
> > > > > > > > > > > > >     public void setUp() throws NamingException {
> > > > > > > > > > > > >         log.info("setUp()");
> > > > > > > > > > > > >         container =
> > EJBContainer.createEJBContainer();
> > > > > > > > > > > > >         container.getContext().bind("inject",
> this);
> > > > > > > > > > > > >     }
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Tear down.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     @After
> > > > > > > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > > > > > > >         container.getContext().unbind("inject");
> > > > > > > > > > > > >         container.close();
> > > > > > > > > > > > >     }
> > > > > > > > > > > > >
> > > > > > > > > > > > >     /**
> > > > > > > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > > > > > > >      */
> > > > > > > > > > > > >     @Test
> > > > > > > > > > > > >     public final void testCache() {
> > > > > > > > > > > > >         log.info("testCache");
> > > > > > > > > > > > >         assertNotNull(cacheBean);
> > > > > > > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > > > >                 getCacheNames()));
> > > > > > > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > > > >                 getCache("testCache");
> > > > > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > > > > testCache.getName()));
> > > > > > > > > > > > >         // This should display value1, but it
> > doesn't
> > > > > > > > > > > > >         log.info(String.format("Value: %s",
> > > > > > > > > testCache.get("key1")));
> > > > > > > > > > > > >         testCache.close();
> > > > > > > > > > > > >     }
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau
> > > [via
> > > > > > TomEE
> > > > > > > &
> > > > > > > > > > > > OpenEJB] <
> > > > > > > > > > > > > [hidden email]
> > > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>>
> > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > dont have time to look now but here a sample i
> > wrote
> > > > > which
> > > > > > is
> > > > > > > > > green
> > > > > > > > > > > > > there:
> > > > > > > > > > > > > >
> > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> > > >  Blog
> > > > > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > > > > LinkedIn <
> https://www.linkedin.com/in/rmannibucau>
> > |
> > > > > > > > Tomitriber
> > > > > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > > > > > > <http://
> > > > > /user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'm not sure the <interceptors> in beans.xml
> are
> > > > being
> > > > > > > > loaded
> > > > > > > > > or
> > > > > > > > > > > > that I
> > > > > > > > > > > > > > > have
> > > > > > > > > > > > > > > the container set up right for the unit test
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'm using the EHCache provider and it fires up
> > fine
> > > > and
> > > > > > can
> > > > > > > > > > > interact
> > > > > > > > > > > > > > with
> > > > > > > > > > > > > > > it, but CDI doesn't appear to be working. Any
> > help
> > > > > > getting
> > > > > > > > the
> > > > > > > > > > > > working
> > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > View this message in context:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > > > > > > Sent from the TomEE Users mailing list archive
> > at
> > > > > > > > Nabble.com.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > ------------------------------
> > > > > > > > > > > > > > If you reply to this email, your message will be
> > > added
> > > > to
> > > > > > the
> > > > > > > > > > > > discussion
> > > > > > > > > > > > > > below:
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > > > > > > <
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > > .
> > > > > > > > > > > > > > NAML
> > > > > > > > > > > > > > <
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > > View this message in context:
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > > > Nabble.com.
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Steven P. Goldsmith
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > ------------------------------
> > > > > > > > If you reply to this email, your message will be added to the
> > > > > > discussion
> > > > > > > > below:
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > <
> > > > > > >
> > > > > > >
> > > > > > > > .
> > > > > > > > NAML
> > > > > > > > <
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven P. Goldsmith
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > View this message in context:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > > >
> > > > > >
> > > > > >
> > > > > > ------------------------------
> > > > > > If you reply to this email, your message will be added to the
> > > > discussion
> > > > > > below:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> > > > > > To unsubscribe from JCache CDI, click here
> > > > > > <
> > > > >
> > > > >
> > > > > > .
> > > > > > NAML
> > > > > > <
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven P. Goldsmith
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > View this message in context:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
> > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > >
> > > >
> > > >
> > > > ------------------------------
> > > > If you reply to this email, your message will be added to the
> > discussion
> > > > below:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675992.html
> > > > To unsubscribe from JCache CDI, click here
> > > > <
> > > >
> > > > .
> > > > NAML
> > > > <
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675995.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675996.html
> > To unsubscribe from JCache CDI, click here
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> >
> > .
> > NAML
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
> --
> Steven P. Goldsmith
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675998.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JCache CDI

Posted by sgjava <sg...@gmail.com>.
OK, it works now:

INFO: Key: org.jsr107.ri.annotations.DefaultGeneratedCacheKey@322dd3,
Value: value3
Aug 27, 2015 11:15:09 AM com.codeferm.services.jaxrs.CacheBeanTest testCache
INFO: Key: org.jsr107.ri.annotations.DefaultGeneratedCacheKey@322dd1,
Value: value1
Aug 27, 2015 11:15:09 AM com.codeferm.services.jaxrs.CacheBeanTest testCache
INFO: Key: org.jsr107.ri.annotations.DefaultGeneratedCacheKey@322dd2,
Value: value2

So, since I'll be using a WAR is there a way to use
org.apache.tomee.embedded.Container or javax.ejb.embeddable.EJBContainer to
deploy the WAR with caching? EJBContainer.createEJBContainer();
        container.getContext().bind("inject", this); doesn't make sense in
this context.

On Thu, Aug 27, 2015 at 11:07 AM, Romain Manni-Bucau [via TomEE & OpenEJB] <
ml-node+s979440n4675996h87@n4.nabble.com> wrote:

> META-INF should be in the classpath so WEB-INF/classes for the war
> target/classes for tests. easiest way to get it with maven is
> src/main/resources
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 17:04 GMT+02:00 sgjava <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675996&i=0>>:
>
> > Also, should META-INF be in src/main/resources or src/main/webapp?
> >
> > On Thu, Aug 27, 2015 at 10:54 AM, Romain Manni-Bucau [via TomEE &
> OpenEJB]
> > <
> > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4675996&i=1>>
> wrote:
> >
> > > EJBContainer doesnt read WEB-INF by default so put your beans.xml in
> > > META-INF
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-27 16:45 GMT+02:00 sgjava <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675992&i=0>>:
> > >
> > > > https://github.com/sgjava/my-jaxrs-test
> > > >
> > > > CacheBeanTest
> > > >
> > > > Thanks.
> > > >
> > > > On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE &
> > > OpenEJB]
> > > > <
> > > > [hidden email] <http://
> > /user/SendEmail.jtp?type=node&node=4675992&i=1>>
> > > wrote:
> > > >
> > > > > hmm, push this sample on github, I'll try to check in the coming
> > hours
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
> > > > >
> > > > > > I get no cache results using:
> > > > > >
> > > > > >         keyValueBean.add("key1", "value1");
> > > > > >         final Cache<String, String> testCache =
> > > > > > cacheBean.getCacheManager().
> > > > > >                 getCache("testCache");
> > > > > >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> > > > > testCache.
> > > > > >                 iterator();
> > > > > >         while (allCacheEntries.hasNext()) {
> > > > > >             Cache.Entry<String, String> currentEntry =
> > > > > > allCacheEntries.next();
> > > > > >             log.info("Key: " + currentEntry.getKey() + " Value:
> "
> > > > > >                     + currentEntry.getValue());
> > > > > >         }
> > > > > >
> > > > > > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE
> &
> > > > > OpenEJB]
> > > > > > <
> > > > > > [hidden email] <http://
> > > > /user/SendEmail.jtp?type=node&node=4675990&i=1>>
> > > > > wrote:
> > > > > >
> > > > > > > no default implementation in the API but clearly de default in
> > the
> > > > > > > provider
> > > > > > > you can maybe reuse. Iterating over the cache - for test
> purpose
> > -
> > > is
> > > > > an
> > > > > > > alternative you can use.
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > > > > > >
> > > > > > > > Ah, OK, that wasn't evident from what I've read so far. Is
> > there
> > > a
> > > > > > > default
> > > > > > > > implementation or do you have to create one?
> > > > > > > >
> > > > > > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden
> > > email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > no, @CacheKey doesnt mean your parameter is the key, it
> means
> > > it
> > > > > is
> > > > > > > used
> > > > > > > > in
> > > > > > > > > the key but the key is still a GeneratedCacheKey
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Romain Manni-Bucau
> > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > >
> > > > > > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > > > > > >
> > > > > > > > > > I'm just not able to see the cached values by using:
> > > > > > > > > >
> > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > >                 getCache("testCache");
> > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > testCache.getName()));
> > > > > > > > > >
> > > > > > > > > > *        // This should display value1, but it doesn't
> > > > > > > log.info
> > > > > > > > > > <http://log.info>(String.format("Value: %s",
> > > > > > > testCache.get("key1")));*
> > > > > > > > > >
> > > > > > > > > > ehcache.xml:
> > > > > > > > > >
> > > > > > > > > > <ehcache xmlns:xsi="
> > > http://www.w3.org/2001/XMLSchema-instance"
> > > > > > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > > > > > >          dynamicConfig="true">
> > > > > > > > > >
> > > > > > > > > >     <defaultCache
> > > > > > > > > >         maxEntriesLocalHeap="1000000"
> > > > > > > > > >         eternal="false"
> > > > > > > > > >         timeToIdleSeconds="86400"
> > > > > > > > > >         timeToLiveSeconds="86400"
> > > > > > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > > > > > >     </defaultCache>
> > > > > > > > > >
> > > > > > > > > >     <cache name="testCache"
> > > > > > > > > >            maxEntriesLocalHeap="1000000"
> > > > > > > > > >            eternal="false"
> > > > > > > > > >            timeToIdleSeconds="600"
> > > > > > > > > >            timeToLiveSeconds="600"
> > > > > > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > > > > > >     </cache>
> > > > > > > > > >
> > > > > > > > > > </ehcache>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > > > > > [hidden email] <http://
> > > > > > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > > > > > >
> > > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > looks good, did you encounter any issue or did you ask
> > > only
> > > > > for a
> > > > > > > > > review?
> > > > > > > > > > >
> > > > > > > > > > > Note: beans.xml should be empty if already provided by
> ri
> > > > jar.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
>  Blog
> > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > Tomitriber
> > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > >
> > > > > > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > > > > > >
> > > > > > > > > > > > Your examples all have invokers, etc. but none of
> the
> > > other
> > > > > > > example
> > > > > > > > > > I've
> > > > > > > > > > > > seen require this. Since you don't have time to
> look,
> > > maybe
> > > > > you
> > > > > > > can
> > > > > > > > > see
> > > > > > > > > > > if
> > > > > > > > > > > > my structure looks good:
> > > > > > > > > > > >
> > > > > > > > > > > > pom.xml:
> > > > > > > > > > > >
> > > > > > > > > > > >         <dependency>
> > > > > > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > > > > > >
> > > > > <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > > > > > >             <version>1.0.0</version>
> > > > > > > > > > > >         </dependency>
> > > > > > > > > > > >         <dependency>
> > > > > > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > > > > > >             <version>1.0.1</version>
> > > > > > > > > > > >             <scope>compile</scope>
> > > > > > > > > > > >         </dependency>
> > > > > > > > > > > >
> > > > > > > > > > > > beans.xml:
> > > > > > > > > > > >
> > > > > > > > > > > > <beans>
> > > > > > > > > > > >     <interceptors>
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > >
> > >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > >
> > > > > >
> > > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > > > > > >
> > > > > > > > > >
> > > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > > > > > >     </interceptors>
> > > > > > > > > > > > </beans>
> > > > > > > > > > > >
> > > > > > > > > > > > Cache bean:
> > > > > > > > > > > >
> > > > > > > > > > > > @Singleton
> > > > > > > > > > > > @Startup
> > > > > > > > > > > > @Lock(READ)
> > > > > > > > > > > > public class CacheBean {
> > > > > > > > > > > >
> > > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Caching provider.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Cache manager.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     private CacheManager cacheManager;
> > > > > > > > > > > >
> > > > > > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > > > > > >         return cacheManager;
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Using EHCache provider configured via
> > ehcache.xml
> > > in
> > > > > > > > > classpath.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > > >     @PostConstruct
> > > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > > >     public void init() {
> > > > > > > > > > > >         log.info("PostConstruct");
> > > > > > > > > > > >         cachingProvider =
> Caching.getCachingProvider();
> > > > > > > > > > > >         cacheManager =
> > > cachingProvider.getCacheManager();
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Destroy cache.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > > >     @PreDestroy
> > > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > > >     public void destroy() {
> > > > > > > > > > > >         log.info("PreDestroy");
> > > > > > > > > > > >         cacheManager.close();
> > > > > > > > > > > >         cachingProvider.close();
> > > > > > > > > > > >     }
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > Bean to test annotations:
> > > > > > > > > > > >
> > > > > > > > > > > > @Stateless
> > > > > > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > > > > > public class KeyValueBean {
> > > > > > > > > > > >
> > > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > > > > > > >
> > > > > > > > > > > >     @CacheResult
> > > > > > > > > > > >     public String add(@CacheKey String key, String
> > > value) {
> > > > > > > > > > > >         log.info(String.format("Adding key: %s,
> value:
> > > > %s",
> > > > > > > key,
> > > > > > > > > > > value));
> > > > > > > > > > > >         return value;
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     @CacheRemoveAll
> > > > > > > > > > > >     public void invalidateCache() {
> > > > > > > > > > > >         log.info("Cache invalidated");
> > > > > > > > > > > >     }
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > Unit test:
> > > > > > > > > > > >
> > > > > > > > > > > > public class CacheBeanTest {
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Logger.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     private static final Logger log =
> > > > > > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > > > > > >             getName());
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Injected cache bean.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @EJB
> > > > > > > > > > > >     private CacheBean cacheBean;
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Our key/value bean.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @EJB
> > > > > > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * EJB container.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     private static EJBContainer container;
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Start EJB container.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @BeforeClass
> > > > > > > > > > > >     public static void setUpClass() {
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Close caching provider/manager and EJB
> > container.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @AfterClass
> > > > > > > > > > > >     public static void tearDownClass() {
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Set up.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @Before
> > > > > > > > > > > >     public void setUp() throws NamingException {
> > > > > > > > > > > >         log.info("setUp()");
> > > > > > > > > > > >         container =
> EJBContainer.createEJBContainer();
> > > > > > > > > > > >         container.getContext().bind("inject", this);
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Tear down.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @After
> > > > > > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > > > > > >         container.getContext().unbind("inject");
> > > > > > > > > > > >         container.close();
> > > > > > > > > > > >     }
> > > > > > > > > > > >
> > > > > > > > > > > >     /**
> > > > > > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > > > > > >      */
> > > > > > > > > > > >     @Test
> > > > > > > > > > > >     public final void testCache() {
> > > > > > > > > > > >         log.info("testCache");
> > > > > > > > > > > >         assertNotNull(cacheBean);
> > > > > > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > > >                 getCacheNames()));
> > > > > > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > > >                 getCache("testCache");
> > > > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > > > testCache.getName()));
> > > > > > > > > > > >         // This should display value1, but it
> doesn't
> > > > > > > > > > > >         log.info(String.format("Value: %s",
> > > > > > > > testCache.get("key1")));
> > > > > > > > > > > >         testCache.close();
> > > > > > > > > > > >     }
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau
> > [via
> > > > > TomEE
> > > > > > &
> > > > > > > > > > > OpenEJB] <
> > > > > > > > > > > > [hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>>
> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > dont have time to look now but here a sample i
> wrote
> > > > which
> > > > > is
> > > > > > > > green
> > > > > > > > > > > > there:
> > > > > > > > > > > > >
> > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> > >  Blog
> > > > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau>
> |
> > > > > > > Tomitriber
> > > > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > > > >
> > > > > > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > > > > > <http://
> > > > /user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'm not sure the <interceptors> in beans.xml are
> > > being
> > > > > > > loaded
> > > > > > > > or
> > > > > > > > > > > that I
> > > > > > > > > > > > > > have
> > > > > > > > > > > > > > the container set up right for the unit test
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'm using the EHCache provider and it fires up
> fine
> > > and
> > > > > can
> > > > > > > > > > interact
> > > > > > > > > > > > > with
> > > > > > > > > > > > > > it, but CDI doesn't appear to be working. Any
> help
> > > > > getting
> > > > > > > the
> > > > > > > > > > > working
> > > > > > > > > > > > > in
> > > > > > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --
> > > > > > > > > > > > > > View this message in context:
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > > > > > Sent from the TomEE Users mailing list archive
> at
> > > > > > > Nabble.com.
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > ------------------------------
> > > > > > > > > > > > > If you reply to this email, your message will be
> > added
> > > to
> > > > > the
> > > > > > > > > > > discussion
> > > > > > > > > > > > > below:
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > > > > > <
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > > .
> > > > > > > > > > > > > NAML
> > > > > > > > > > > > > <
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > View this message in context:
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > > Nabble.com.
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Steven P. Goldsmith
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ------------------------------
> > > > > > > If you reply to this email, your message will be added to the
> > > > > discussion
> > > > > > > below:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > <
> > > > > >
> > > > > >
> > > > > > > .
> > > > > > > NAML
> > > > > > > <
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven P. Goldsmith
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > View this message in context:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > >
> > > > >
> > > > >
> > > > > ------------------------------
> > > > > If you reply to this email, your message will be added to the
> > > discussion
> > > > > below:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> > > > > To unsubscribe from JCache CDI, click here
> > > > > <
> > > >
> > > >
> > > > > .
> > > > > NAML
> > > > > <
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Steven P. Goldsmith
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
> > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > >
> > >
> > >
> > > ------------------------------
> > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675992.html
> > > To unsubscribe from JCache CDI, click here
> > > <
> > >
> > > .
> > > NAML
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675995.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675996.html
> To unsubscribe from JCache CDI, click here
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5>
> .
> NAML
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Steven P. Goldsmith




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675998.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
you can't if your parameter doesnt implement this type:
https://rmannibucau.wordpress.com/2015/08/21/cacheresult-jcache-cdi-to-the-rescue-of-microservices/
has a sample for Long


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-27 16:06 GMT+02:00 sgjava <sg...@gmail.com>:

> Cool, I'll look at creating one that keeps the parameter as is. Thanks for
> your help.
>
> On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE & OpenEJB]
> <
> ml-node+s979440n4675986h77@n4.nabble.com> wrote:
>
> > no default implementation in the API but clearly de default in the
> > provider
> > you can maybe reuse. Iterating over the cache - for test purpose - is an
> > alternative you can use.
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> >
> > > Ah, OK, that wasn't evident from what I've read so far. Is there a
> > default
> > > implementation or do you have to create one?
> > >
> > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > >
> > > wrote:
> > >
> > > > no, @CacheKey doesnt mean your parameter is the key, it means it is
> > used
> > > in
> > > > the key but the key is still a GeneratedCacheKey
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > >
> > > > > I'm just not able to see the cached values by using:
> > > > >
> > > > >         final Cache<String, String> testCache =
> > > > > cacheBean.getCacheManager().
> > > > >                 getCache("testCache");
> > > > >         log.info(String.format("Cache name: %s",
> > > testCache.getName()));
> > > > >
> > > > > *        // This should display value1, but it doesn't
> > log.info
> > > > > <http://log.info>(String.format("Value: %s",
> > testCache.get("key1")));*
> > > > >
> > > > > ehcache.xml:
> > > > >
> > > > > <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > >          updateCheck="true" monitoring="autodetect"
> > > > >          dynamicConfig="true">
> > > > >
> > > > >     <defaultCache
> > > > >         maxEntriesLocalHeap="1000000"
> > > > >         eternal="false"
> > > > >         timeToIdleSeconds="86400"
> > > > >         timeToLiveSeconds="86400"
> > > > >         memoryStoreEvictionPolicy="LRU">
> > > > >     </defaultCache>
> > > > >
> > > > >     <cache name="testCache"
> > > > >            maxEntriesLocalHeap="1000000"
> > > > >            eternal="false"
> > > > >            timeToIdleSeconds="600"
> > > > >            timeToLiveSeconds="600"
> > > > >            memoryStoreEvictionPolicy="LFU">
> > > > >     </cache>
> > > > >
> > > > > </ehcache>
> > > > >
> > > > >
> > > > >
> > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > [hidden email] <http://
> /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > >
> > > > > wrote:
> > > > >
> > > > > > looks good, did you encounter any issue or did you ask only for a
> > > > review?
> > > > > >
> > > > > > Note: beans.xml should be empty if already provided by ri jar.
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > >
> > > > > > > Your examples all have invokers, etc. but none of the other
> > example
> > > > > I've
> > > > > > > seen require this. Since you don't have time to look, maybe you
> > can
> > > > see
> > > > > > if
> > > > > > > my structure looks good:
> > > > > > >
> > > > > > > pom.xml:
> > > > > > >
> > > > > > >         <dependency>
> > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > >             <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > >             <version>1.0.0</version>
> > > > > > >         </dependency>
> > > > > > >         <dependency>
> > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > >             <artifactId>jcache</artifactId>
> > > > > > >             <version>1.0.1</version>
> > > > > > >             <scope>compile</scope>
> > > > > > >         </dependency>
> > > > > > >
> > > > > > > beans.xml:
> > > > > > >
> > > > > > > <beans>
> > > > > > >     <interceptors>
> > > > > > >
> > > > > >
> >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > >
> > > > > > >
> > > > >
> > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > >
> > > > > > >
> > > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > >
> > > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > >     </interceptors>
> > > > > > > </beans>
> > > > > > >
> > > > > > > Cache bean:
> > > > > > >
> > > > > > > @Singleton
> > > > > > > @Startup
> > > > > > > @Lock(READ)
> > > > > > > public class CacheBean {
> > > > > > >
> > > > > > >     private static final Logger log = Logger.
> > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Caching provider.
> > > > > > >      */
> > > > > > >     private CachingProvider cachingProvider;
> > > > > > >     /**
> > > > > > >      * Cache manager.
> > > > > > >      */
> > > > > > >     private CacheManager cacheManager;
> > > > > > >
> > > > > > >     public CacheManager getCacheManager() {
> > > > > > >         return cacheManager;
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Using EHCache provider configured via ehcache.xml in
> > > > classpath.
> > > > > > >      */
> > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > >     @PostConstruct
> > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > >     public void init() {
> > > > > > >         log.info("PostConstruct");
> > > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > > >         cacheManager = cachingProvider.getCacheManager();
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Destroy cache.
> > > > > > >      */
> > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > >     @PreDestroy
> > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > >     public void destroy() {
> > > > > > >         log.info("PreDestroy");
> > > > > > >         cacheManager.close();
> > > > > > >         cachingProvider.close();
> > > > > > >     }
> > > > > > > }
> > > > > > >
> > > > > > > Bean to test annotations:
> > > > > > >
> > > > > > > @Stateless
> > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > public class KeyValueBean {
> > > > > > >
> > > > > > >     private static final Logger log = Logger.
> > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > >
> > > > > > >     @CacheResult
> > > > > > >     public String add(@CacheKey String key, String value) {
> > > > > > >         log.info(String.format("Adding key: %s, value: %s",
> > key,
> > > > > > value));
> > > > > > >         return value;
> > > > > > >     }
> > > > > > >
> > > > > > >     @CacheRemoveAll
> > > > > > >     public void invalidateCache() {
> > > > > > >         log.info("Cache invalidated");
> > > > > > >     }
> > > > > > > }
> > > > > > >
> > > > > > > Unit test:
> > > > > > >
> > > > > > > public class CacheBeanTest {
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Logger.
> > > > > > >      */
> > > > > > >     private static final Logger log =
> > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > >             getName());
> > > > > > >     /**
> > > > > > >      * Injected cache bean.
> > > > > > >      */
> > > > > > >     @EJB
> > > > > > >     private CacheBean cacheBean;
> > > > > > >     /**
> > > > > > >      * Our key/value bean.
> > > > > > >      */
> > > > > > >     @EJB
> > > > > > >     private KeyValueBean keyValueBean;
> > > > > > >
> > > > > > >     /**
> > > > > > >      * EJB container.
> > > > > > >      */
> > > > > > >     private static EJBContainer container;
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Start EJB container.
> > > > > > >      */
> > > > > > >     @BeforeClass
> > > > > > >     public static void setUpClass() {
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Close caching provider/manager and EJB container.
> > > > > > >      */
> > > > > > >     @AfterClass
> > > > > > >     public static void tearDownClass() {
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Set up.
> > > > > > >      */
> > > > > > >     @Before
> > > > > > >     public void setUp() throws NamingException {
> > > > > > >         log.info("setUp()");
> > > > > > >         container = EJBContainer.createEJBContainer();
> > > > > > >         container.getContext().bind("inject", this);
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Tear down.
> > > > > > >      */
> > > > > > >     @After
> > > > > > >     public void tearDown() throws NamingException {
> > > > > > >         container.getContext().unbind("inject");
> > > > > > >         container.close();
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > >      */
> > > > > > >     @Test
> > > > > > >     public final void testCache() {
> > > > > > >         log.info("testCache");
> > > > > > >         assertNotNull(cacheBean);
> > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > cacheBean.getCacheManager().
> > > > > > >                 getCacheNames()));
> > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > >         final Cache<String, String> testCache =
> > > > > > > cacheBean.getCacheManager().
> > > > > > >                 getCache("testCache");
> > > > > > >         log.info(String.format("Cache name: %s",
> > > > > testCache.getName()));
> > > > > > >         // This should display value1, but it doesn't
> > > > > > >         log.info(String.format("Value: %s",
> > > testCache.get("key1")));
> > > > > > >         testCache.close();
> > > > > > >     }
> > > > > > > }
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE
> &
> > > > > > OpenEJB] <
> > > > > > > [hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > > >
> > > > > > > > dont have time to look now but here a sample i wrote which is
> > > green
> > > > > > > there:
> > > > > > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > >
> > > > > > > >
> > > > > > > > Romain Manni-Bucau
> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > > <http://www.tomitribe.com>
> > > > > > > >
> > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > >
> > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > >
> > > > > > > > > I'm not sure the <interceptors> in beans.xml are being
> > loaded
> > > or
> > > > > > that I
> > > > > > > > > have
> > > > > > > > > the container set up right for the unit test
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > >
> > > > > > > > > I'm using the EHCache provider and it fires up fine and can
> > > > > interact
> > > > > > > > with
> > > > > > > > > it, but CDI doesn't appear to be working. Any help getting
> > the
> > > > > > working
> > > > > > > > in
> > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > View this message in context:
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > Sent from the TomEE Users mailing list archive at
> > Nabble.com.
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > ------------------------------
> > > > > > > > If you reply to this email, your message will be added to the
> > > > > > discussion
> > > > > > > > below:
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > <
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > > > > > >
> > > > > > > > .
> > > > > > > > NAML
> > > > > > > > <
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven P. Goldsmith
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > View this message in context:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven P. Goldsmith
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > To unsubscribe from JCache CDI, click here
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> >
> > .
> > NAML
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
> --
> Steven P. Goldsmith
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675987.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JCache CDI

Posted by sgjava <sg...@gmail.com>.
Cool, I'll look at creating one that keeps the parameter as is. Thanks for
your help.

On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE & OpenEJB] <
ml-node+s979440n4675986h77@n4.nabble.com> wrote:

> no default implementation in the API but clearly de default in the
> provider
> you can maybe reuse. Iterating over the cache - for test purpose - is an
> alternative you can use.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
>
> > Ah, OK, that wasn't evident from what I've read so far. Is there a
> default
> > implementation or do you have to create one?
> >
> > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > >
> > wrote:
> >
> > > no, @CacheKey doesnt mean your parameter is the key, it means it is
> used
> > in
> > > the key but the key is still a GeneratedCacheKey
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > >
> > > > I'm just not able to see the cached values by using:
> > > >
> > > >         final Cache<String, String> testCache =
> > > > cacheBean.getCacheManager().
> > > >                 getCache("testCache");
> > > >         log.info(String.format("Cache name: %s",
> > testCache.getName()));
> > > >
> > > > *        // This should display value1, but it doesn't
> log.info
> > > > <http://log.info>(String.format("Value: %s",
> testCache.get("key1")));*
> > > >
> > > > ehcache.xml:
> > > >
> > > > <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > >          updateCheck="true" monitoring="autodetect"
> > > >          dynamicConfig="true">
> > > >
> > > >     <defaultCache
> > > >         maxEntriesLocalHeap="1000000"
> > > >         eternal="false"
> > > >         timeToIdleSeconds="86400"
> > > >         timeToLiveSeconds="86400"
> > > >         memoryStoreEvictionPolicy="LRU">
> > > >     </defaultCache>
> > > >
> > > >     <cache name="testCache"
> > > >            maxEntriesLocalHeap="1000000"
> > > >            eternal="false"
> > > >            timeToIdleSeconds="600"
> > > >            timeToLiveSeconds="600"
> > > >            memoryStoreEvictionPolicy="LFU">
> > > >     </cache>
> > > >
> > > > </ehcache>
> > > >
> > > >
> > > >
> > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > >
> > > > wrote:
> > > >
> > > > > looks good, did you encounter any issue or did you ask only for a
> > > review?
> > > > >
> > > > > Note: beans.xml should be empty if already provided by ri jar.
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > >
> > > > > > Your examples all have invokers, etc. but none of the other
> example
> > > > I've
> > > > > > seen require this. Since you don't have time to look, maybe you
> can
> > > see
> > > > > if
> > > > > > my structure looks good:
> > > > > >
> > > > > > pom.xml:
> > > > > >
> > > > > >         <dependency>
> > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > >             <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > >             <version>1.0.0</version>
> > > > > >         </dependency>
> > > > > >         <dependency>
> > > > > >             <groupId>org.ehcache</groupId>
> > > > > >             <artifactId>jcache</artifactId>
> > > > > >             <version>1.0.1</version>
> > > > > >             <scope>compile</scope>
> > > > > >         </dependency>
> > > > > >
> > > > > > beans.xml:
> > > > > >
> > > > > > <beans>
> > > > > >     <interceptors>
> > > > > >
> > > > >
>  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > >
> > > > > >
> > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > >
> > > > > >
> > > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > >
> > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > >     </interceptors>
> > > > > > </beans>
> > > > > >
> > > > > > Cache bean:
> > > > > >
> > > > > > @Singleton
> > > > > > @Startup
> > > > > > @Lock(READ)
> > > > > > public class CacheBean {
> > > > > >
> > > > > >     private static final Logger log = Logger.
> > > > > >             getLogger(CacheBean.class.getName());
> > > > > >
> > > > > >     /**
> > > > > >      * Caching provider.
> > > > > >      */
> > > > > >     private CachingProvider cachingProvider;
> > > > > >     /**
> > > > > >      * Cache manager.
> > > > > >      */
> > > > > >     private CacheManager cacheManager;
> > > > > >
> > > > > >     public CacheManager getCacheManager() {
> > > > > >         return cacheManager;
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Using EHCache provider configured via ehcache.xml in
> > > classpath.
> > > > > >      */
> > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > >     @PostConstruct
> > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > >     public void init() {
> > > > > >         log.info("PostConstruct");
> > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > >         cacheManager = cachingProvider.getCacheManager();
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Destroy cache.
> > > > > >      */
> > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > >     @PreDestroy
> > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > >     public void destroy() {
> > > > > >         log.info("PreDestroy");
> > > > > >         cacheManager.close();
> > > > > >         cachingProvider.close();
> > > > > >     }
> > > > > > }
> > > > > >
> > > > > > Bean to test annotations:
> > > > > >
> > > > > > @Stateless
> > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > public class KeyValueBean {
> > > > > >
> > > > > >     private static final Logger log = Logger.
> > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > >
> > > > > >     @CacheResult
> > > > > >     public String add(@CacheKey String key, String value) {
> > > > > >         log.info(String.format("Adding key: %s, value: %s",
> key,
> > > > > value));
> > > > > >         return value;
> > > > > >     }
> > > > > >
> > > > > >     @CacheRemoveAll
> > > > > >     public void invalidateCache() {
> > > > > >         log.info("Cache invalidated");
> > > > > >     }
> > > > > > }
> > > > > >
> > > > > > Unit test:
> > > > > >
> > > > > > public class CacheBeanTest {
> > > > > >
> > > > > >     /**
> > > > > >      * Logger.
> > > > > >      */
> > > > > >     private static final Logger log =
> > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > >             getName());
> > > > > >     /**
> > > > > >      * Injected cache bean.
> > > > > >      */
> > > > > >     @EJB
> > > > > >     private CacheBean cacheBean;
> > > > > >     /**
> > > > > >      * Our key/value bean.
> > > > > >      */
> > > > > >     @EJB
> > > > > >     private KeyValueBean keyValueBean;
> > > > > >
> > > > > >     /**
> > > > > >      * EJB container.
> > > > > >      */
> > > > > >     private static EJBContainer container;
> > > > > >
> > > > > >     /**
> > > > > >      * Start EJB container.
> > > > > >      */
> > > > > >     @BeforeClass
> > > > > >     public static void setUpClass() {
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Close caching provider/manager and EJB container.
> > > > > >      */
> > > > > >     @AfterClass
> > > > > >     public static void tearDownClass() {
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Set up.
> > > > > >      */
> > > > > >     @Before
> > > > > >     public void setUp() throws NamingException {
> > > > > >         log.info("setUp()");
> > > > > >         container = EJBContainer.createEJBContainer();
> > > > > >         container.getContext().bind("inject", this);
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Tear down.
> > > > > >      */
> > > > > >     @After
> > > > > >     public void tearDown() throws NamingException {
> > > > > >         container.getContext().unbind("inject");
> > > > > >         container.close();
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > >      */
> > > > > >     @Test
> > > > > >     public final void testCache() {
> > > > > >         log.info("testCache");
> > > > > >         assertNotNull(cacheBean);
> > > > > >         log.info(String.format("Cache names: %s",
> > > > > > cacheBean.getCacheManager().
> > > > > >                 getCacheNames()));
> > > > > >         keyValueBean.add("key1", "value1");
> > > > > >         final Cache<String, String> testCache =
> > > > > > cacheBean.getCacheManager().
> > > > > >                 getCache("testCache");
> > > > > >         log.info(String.format("Cache name: %s",
> > > > testCache.getName()));
> > > > > >         // This should display value1, but it doesn't
> > > > > >         log.info(String.format("Value: %s",
> > testCache.get("key1")));
> > > > > >         testCache.close();
> > > > > >     }
> > > > > > }
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE &
> > > > > OpenEJB] <
> > > > > > [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > >
> > > > > > > dont have time to look now but here a sample i wrote which is
> > green
> > > > > > there:
> > > > > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > >
> > > > > > > > I added my JCache attempt in my test project
> > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > >
> > > > > > > > I'm not sure the <interceptors> in beans.xml are being
> loaded
> > or
> > > > > that I
> > > > > > > > have
> > > > > > > > the container set up right for the unit test
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > >
> > > > > > > > I'm using the EHCache provider and it fires up fine and can
> > > > interact
> > > > > > > with
> > > > > > > > it, but CDI doesn't appear to be working. Any help getting
> the
> > > > > working
> > > > > > > in
> > > > > > > > TomEE 7 is appreciated.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > View this message in context:
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > Sent from the TomEE Users mailing list archive at
> Nabble.com.
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ------------------------------
> > > > > > > If you reply to this email, your message will be added to the
> > > > > discussion
> > > > > > > below:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > <
> > > > > >
> > > > >
> > > >
> > >
> >
> > > > > >
> > > > > > > .
> > > > > > > NAML
> > > > > > > <
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven P. Goldsmith
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > View this message in context:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Steven P. Goldsmith
> > > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> To unsubscribe from JCache CDI, click here
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5>
> .
> NAML
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Steven P. Goldsmith




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675987.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
META-INF should be in the classpath so WEB-INF/classes for the war
target/classes for tests. easiest way to get it with maven is
src/main/resources


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-27 17:04 GMT+02:00 sgjava <sg...@gmail.com>:

> Also, should META-INF be in src/main/resources or src/main/webapp?
>
> On Thu, Aug 27, 2015 at 10:54 AM, Romain Manni-Bucau [via TomEE & OpenEJB]
> <
> ml-node+s979440n4675992h63@n4.nabble.com> wrote:
>
> > EJBContainer doesnt read WEB-INF by default so put your beans.xml in
> > META-INF
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-27 16:45 GMT+02:00 sgjava <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675992&i=0>>:
> >
> > > https://github.com/sgjava/my-jaxrs-test
> > >
> > > CacheBeanTest
> > >
> > > Thanks.
> > >
> > > On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE &
> > OpenEJB]
> > > <
> > > [hidden email] <http://
> /user/SendEmail.jtp?type=node&node=4675992&i=1>>
> > wrote:
> > >
> > > > hmm, push this sample on github, I'll try to check in the coming
> hours
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
> > > >
> > > > > I get no cache results using:
> > > > >
> > > > >         keyValueBean.add("key1", "value1");
> > > > >         final Cache<String, String> testCache =
> > > > > cacheBean.getCacheManager().
> > > > >                 getCache("testCache");
> > > > >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> > > > testCache.
> > > > >                 iterator();
> > > > >         while (allCacheEntries.hasNext()) {
> > > > >             Cache.Entry<String, String> currentEntry =
> > > > > allCacheEntries.next();
> > > > >             log.info("Key: " + currentEntry.getKey() + " Value: "
> > > > >                     + currentEntry.getValue());
> > > > >         }
> > > > >
> > > > > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE &
> > > > OpenEJB]
> > > > > <
> > > > > [hidden email] <http://
> > > /user/SendEmail.jtp?type=node&node=4675990&i=1>>
> > > > wrote:
> > > > >
> > > > > > no default implementation in the API but clearly de default in
> the
> > > > > > provider
> > > > > > you can maybe reuse. Iterating over the cache - for test purpose
> -
> > is
> > > > an
> > > > > > alternative you can use.
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > > > > >
> > > > > > > Ah, OK, that wasn't evident from what I've read so far. Is
> there
> > a
> > > > > > default
> > > > > > > implementation or do you have to create one?
> > > > > > >
> > > > > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden
> > email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > no, @CacheKey doesnt mean your parameter is the key, it means
> > it
> > > > is
> > > > > > used
> > > > > > > in
> > > > > > > > the key but the key is still a GeneratedCacheKey
> > > > > > > >
> > > > > > > >
> > > > > > > > Romain Manni-Bucau
> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > > <http://www.tomitribe.com>
> > > > > > > >
> > > > > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > > > > >
> > > > > > > > > I'm just not able to see the cached values by using:
> > > > > > > > >
> > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > >                 getCache("testCache");
> > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > testCache.getName()));
> > > > > > > > >
> > > > > > > > > *        // This should display value1, but it doesn't
> > > > > > log.info
> > > > > > > > > <http://log.info>(String.format("Value: %s",
> > > > > > testCache.get("key1")));*
> > > > > > > > >
> > > > > > > > > ehcache.xml:
> > > > > > > > >
> > > > > > > > > <ehcache xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance"
> > > > > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > > > > >          dynamicConfig="true">
> > > > > > > > >
> > > > > > > > >     <defaultCache
> > > > > > > > >         maxEntriesLocalHeap="1000000"
> > > > > > > > >         eternal="false"
> > > > > > > > >         timeToIdleSeconds="86400"
> > > > > > > > >         timeToLiveSeconds="86400"
> > > > > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > > > > >     </defaultCache>
> > > > > > > > >
> > > > > > > > >     <cache name="testCache"
> > > > > > > > >            maxEntriesLocalHeap="1000000"
> > > > > > > > >            eternal="false"
> > > > > > > > >            timeToIdleSeconds="600"
> > > > > > > > >            timeToLiveSeconds="600"
> > > > > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > > > > >     </cache>
> > > > > > > > >
> > > > > > > > > </ehcache>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > > > > [hidden email] <http://
> > > > > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > > > > >
> > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > looks good, did you encounter any issue or did you ask
> > only
> > > > for a
> > > > > > > > review?
> > > > > > > > > >
> > > > > > > > > > Note: beans.xml should be empty if already provided by ri
> > > jar.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > Tomitriber
> > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > >
> > > > > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > > > > >
> > > > > > > > > > > Your examples all have invokers, etc. but none of the
> > other
> > > > > > example
> > > > > > > > > I've
> > > > > > > > > > > seen require this. Since you don't have time to look,
> > maybe
> > > > you
> > > > > > can
> > > > > > > > see
> > > > > > > > > > if
> > > > > > > > > > > my structure looks good:
> > > > > > > > > > >
> > > > > > > > > > > pom.xml:
> > > > > > > > > > >
> > > > > > > > > > >         <dependency>
> > > > > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > > > > >
> > > > <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > > > > >             <version>1.0.0</version>
> > > > > > > > > > >         </dependency>
> > > > > > > > > > >         <dependency>
> > > > > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > > > > >             <version>1.0.1</version>
> > > > > > > > > > >             <scope>compile</scope>
> > > > > > > > > > >         </dependency>
> > > > > > > > > > >
> > > > > > > > > > > beans.xml:
> > > > > > > > > > >
> > > > > > > > > > > <beans>
> > > > > > > > > > >     <interceptors>
> > > > > > > > > > >
> > > > > > > > > >
> > > > > >
> >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > >
> > > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > > > > >
> > > > > > > > >
> > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > > > > >     </interceptors>
> > > > > > > > > > > </beans>
> > > > > > > > > > >
> > > > > > > > > > > Cache bean:
> > > > > > > > > > >
> > > > > > > > > > > @Singleton
> > > > > > > > > > > @Startup
> > > > > > > > > > > @Lock(READ)
> > > > > > > > > > > public class CacheBean {
> > > > > > > > > > >
> > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Caching provider.
> > > > > > > > > > >      */
> > > > > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Cache manager.
> > > > > > > > > > >      */
> > > > > > > > > > >     private CacheManager cacheManager;
> > > > > > > > > > >
> > > > > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > > > > >         return cacheManager;
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Using EHCache provider configured via
> ehcache.xml
> > in
> > > > > > > > classpath.
> > > > > > > > > > >      */
> > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > >     @PostConstruct
> > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > >     public void init() {
> > > > > > > > > > >         log.info("PostConstruct");
> > > > > > > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > > > > > > >         cacheManager =
> > cachingProvider.getCacheManager();
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Destroy cache.
> > > > > > > > > > >      */
> > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > >     @PreDestroy
> > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > >     public void destroy() {
> > > > > > > > > > >         log.info("PreDestroy");
> > > > > > > > > > >         cacheManager.close();
> > > > > > > > > > >         cachingProvider.close();
> > > > > > > > > > >     }
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > Bean to test annotations:
> > > > > > > > > > >
> > > > > > > > > > > @Stateless
> > > > > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > > > > public class KeyValueBean {
> > > > > > > > > > >
> > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > > > > > >
> > > > > > > > > > >     @CacheResult
> > > > > > > > > > >     public String add(@CacheKey String key, String
> > value) {
> > > > > > > > > > >         log.info(String.format("Adding key: %s, value:
> > > %s",
> > > > > > key,
> > > > > > > > > > value));
> > > > > > > > > > >         return value;
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     @CacheRemoveAll
> > > > > > > > > > >     public void invalidateCache() {
> > > > > > > > > > >         log.info("Cache invalidated");
> > > > > > > > > > >     }
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > Unit test:
> > > > > > > > > > >
> > > > > > > > > > > public class CacheBeanTest {
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Logger.
> > > > > > > > > > >      */
> > > > > > > > > > >     private static final Logger log =
> > > > > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > > > > >             getName());
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Injected cache bean.
> > > > > > > > > > >      */
> > > > > > > > > > >     @EJB
> > > > > > > > > > >     private CacheBean cacheBean;
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Our key/value bean.
> > > > > > > > > > >      */
> > > > > > > > > > >     @EJB
> > > > > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * EJB container.
> > > > > > > > > > >      */
> > > > > > > > > > >     private static EJBContainer container;
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Start EJB container.
> > > > > > > > > > >      */
> > > > > > > > > > >     @BeforeClass
> > > > > > > > > > >     public static void setUpClass() {
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Close caching provider/manager and EJB
> container.
> > > > > > > > > > >      */
> > > > > > > > > > >     @AfterClass
> > > > > > > > > > >     public static void tearDownClass() {
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Set up.
> > > > > > > > > > >      */
> > > > > > > > > > >     @Before
> > > > > > > > > > >     public void setUp() throws NamingException {
> > > > > > > > > > >         log.info("setUp()");
> > > > > > > > > > >         container = EJBContainer.createEJBContainer();
> > > > > > > > > > >         container.getContext().bind("inject", this);
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Tear down.
> > > > > > > > > > >      */
> > > > > > > > > > >     @After
> > > > > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > > > > >         container.getContext().unbind("inject");
> > > > > > > > > > >         container.close();
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > > > > >      */
> > > > > > > > > > >     @Test
> > > > > > > > > > >     public final void testCache() {
> > > > > > > > > > >         log.info("testCache");
> > > > > > > > > > >         assertNotNull(cacheBean);
> > > > > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > >                 getCacheNames()));
> > > > > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > >                 getCache("testCache");
> > > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > > testCache.getName()));
> > > > > > > > > > >         // This should display value1, but it doesn't
> > > > > > > > > > >         log.info(String.format("Value: %s",
> > > > > > > testCache.get("key1")));
> > > > > > > > > > >         testCache.close();
> > > > > > > > > > >     }
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau
> [via
> > > > TomEE
> > > > > &
> > > > > > > > > > OpenEJB] <
> > > > > > > > > > > [hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > > > > > > >
> > > > > > > > > > > > dont have time to look now but here a sample i wrote
> > > which
> > > > is
> > > > > > > green
> > > > > > > > > > > there:
> > > > > > > > > > > >
> > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> >  Blog
> > > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > > Tomitriber
> > > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > > >
> > > > > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > > > > <http://
> > > /user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > > > > >
> > > > > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm not sure the <interceptors> in beans.xml are
> > being
> > > > > > loaded
> > > > > > > or
> > > > > > > > > > that I
> > > > > > > > > > > > > have
> > > > > > > > > > > > > the container set up right for the unit test
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm using the EHCache provider and it fires up fine
> > and
> > > > can
> > > > > > > > > interact
> > > > > > > > > > > > with
> > > > > > > > > > > > > it, but CDI doesn't appear to be working. Any help
> > > > getting
> > > > > > the
> > > > > > > > > > working
> > > > > > > > > > > > in
> > > > > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > > View this message in context:
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > > > Nabble.com.
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > ------------------------------
> > > > > > > > > > > > If you reply to this email, your message will be
> added
> > to
> > > > the
> > > > > > > > > > discussion
> > > > > > > > > > > > below:
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > > > > <
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > > .
> > > > > > > > > > > > NAML
> > > > > > > > > > > > <
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > View this message in context:
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > Nabble.com.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Steven P. Goldsmith
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven P. Goldsmith
> > > > > > >
> > > > > >
> > > > > >
> > > > > > ------------------------------
> > > > > > If you reply to this email, your message will be added to the
> > > > discussion
> > > > > > below:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > > > > To unsubscribe from JCache CDI, click here
> > > > > > <
> > > > >
> > > > >
> > > > > > .
> > > > > > NAML
> > > > > > <
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven P. Goldsmith
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > View this message in context:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > >
> > > >
> > > >
> > > > ------------------------------
> > > > If you reply to this email, your message will be added to the
> > discussion
> > > > below:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> > > > To unsubscribe from JCache CDI, click here
> > > > <
> > >
> > >
> > > > .
> > > > NAML
> > > > <
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675992.html
> > To unsubscribe from JCache CDI, click here
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> >
> > .
> > NAML
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
> --
> Steven P. Goldsmith
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675995.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JCache CDI

Posted by sgjava <sg...@gmail.com>.
Also, should META-INF be in src/main/resources or src/main/webapp?

On Thu, Aug 27, 2015 at 10:54 AM, Romain Manni-Bucau [via TomEE & OpenEJB] <
ml-node+s979440n4675992h63@n4.nabble.com> wrote:

> EJBContainer doesnt read WEB-INF by default so put your beans.xml in
> META-INF
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 16:45 GMT+02:00 sgjava <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675992&i=0>>:
>
> > https://github.com/sgjava/my-jaxrs-test
> >
> > CacheBeanTest
> >
> > Thanks.
> >
> > On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE &
> OpenEJB]
> > <
> > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4675992&i=1>>
> wrote:
> >
> > > hmm, push this sample on github, I'll try to check in the coming hours
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
> > >
> > > > I get no cache results using:
> > > >
> > > >         keyValueBean.add("key1", "value1");
> > > >         final Cache<String, String> testCache =
> > > > cacheBean.getCacheManager().
> > > >                 getCache("testCache");
> > > >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> > > testCache.
> > > >                 iterator();
> > > >         while (allCacheEntries.hasNext()) {
> > > >             Cache.Entry<String, String> currentEntry =
> > > > allCacheEntries.next();
> > > >             log.info("Key: " + currentEntry.getKey() + " Value: "
> > > >                     + currentEntry.getValue());
> > > >         }
> > > >
> > > > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE &
> > > OpenEJB]
> > > > <
> > > > [hidden email] <http://
> > /user/SendEmail.jtp?type=node&node=4675990&i=1>>
> > > wrote:
> > > >
> > > > > no default implementation in the API but clearly de default in the
> > > > > provider
> > > > > you can maybe reuse. Iterating over the cache - for test purpose -
> is
> > > an
> > > > > alternative you can use.
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > > > >
> > > > > > Ah, OK, that wasn't evident from what I've read so far. Is there
> a
> > > > > default
> > > > > > implementation or do you have to create one?
> > > > > >
> > > > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden
> email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > no, @CacheKey doesnt mean your parameter is the key, it means
> it
> > > is
> > > > > used
> > > > > > in
> > > > > > > the key but the key is still a GeneratedCacheKey
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > > > >
> > > > > > > > I'm just not able to see the cached values by using:
> > > > > > > >
> > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > cacheBean.getCacheManager().
> > > > > > > >                 getCache("testCache");
> > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > testCache.getName()));
> > > > > > > >
> > > > > > > > *        // This should display value1, but it doesn't
> > > > > log.info
> > > > > > > > <http://log.info>(String.format("Value: %s",
> > > > > testCache.get("key1")));*
> > > > > > > >
> > > > > > > > ehcache.xml:
> > > > > > > >
> > > > > > > > <ehcache xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
> > > > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > > > >          dynamicConfig="true">
> > > > > > > >
> > > > > > > >     <defaultCache
> > > > > > > >         maxEntriesLocalHeap="1000000"
> > > > > > > >         eternal="false"
> > > > > > > >         timeToIdleSeconds="86400"
> > > > > > > >         timeToLiveSeconds="86400"
> > > > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > > > >     </defaultCache>
> > > > > > > >
> > > > > > > >     <cache name="testCache"
> > > > > > > >            maxEntriesLocalHeap="1000000"
> > > > > > > >            eternal="false"
> > > > > > > >            timeToIdleSeconds="600"
> > > > > > > >            timeToLiveSeconds="600"
> > > > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > > > >     </cache>
> > > > > > > >
> > > > > > > > </ehcache>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > > > [hidden email] <http://
> > > > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > looks good, did you encounter any issue or did you ask
> only
> > > for a
> > > > > > > review?
> > > > > > > > >
> > > > > > > > > Note: beans.xml should be empty if already provided by ri
> > jar.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Romain Manni-Bucau
> > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > >
> > > > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > > > >
> > > > > > > > > > Your examples all have invokers, etc. but none of the
> other
> > > > > example
> > > > > > > > I've
> > > > > > > > > > seen require this. Since you don't have time to look,
> maybe
> > > you
> > > > > can
> > > > > > > see
> > > > > > > > > if
> > > > > > > > > > my structure looks good:
> > > > > > > > > >
> > > > > > > > > > pom.xml:
> > > > > > > > > >
> > > > > > > > > >         <dependency>
> > > > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > > > >
> > > <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > > > >             <version>1.0.0</version>
> > > > > > > > > >         </dependency>
> > > > > > > > > >         <dependency>
> > > > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > > > >             <version>1.0.1</version>
> > > > > > > > > >             <scope>compile</scope>
> > > > > > > > > >         </dependency>
> > > > > > > > > >
> > > > > > > > > > beans.xml:
> > > > > > > > > >
> > > > > > > > > > <beans>
> > > > > > > > > >     <interceptors>
> > > > > > > > > >
> > > > > > > > >
> > > > >
>  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > >
> > > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > > > >
> > > > > > > >
> > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > > > >     </interceptors>
> > > > > > > > > > </beans>
> > > > > > > > > >
> > > > > > > > > > Cache bean:
> > > > > > > > > >
> > > > > > > > > > @Singleton
> > > > > > > > > > @Startup
> > > > > > > > > > @Lock(READ)
> > > > > > > > > > public class CacheBean {
> > > > > > > > > >
> > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Caching provider.
> > > > > > > > > >      */
> > > > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > > > >     /**
> > > > > > > > > >      * Cache manager.
> > > > > > > > > >      */
> > > > > > > > > >     private CacheManager cacheManager;
> > > > > > > > > >
> > > > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > > > >         return cacheManager;
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Using EHCache provider configured via ehcache.xml
> in
> > > > > > > classpath.
> > > > > > > > > >      */
> > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > >     @PostConstruct
> > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > >     public void init() {
> > > > > > > > > >         log.info("PostConstruct");
> > > > > > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > > > > > >         cacheManager =
> cachingProvider.getCacheManager();
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Destroy cache.
> > > > > > > > > >      */
> > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > >     @PreDestroy
> > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > >     public void destroy() {
> > > > > > > > > >         log.info("PreDestroy");
> > > > > > > > > >         cacheManager.close();
> > > > > > > > > >         cachingProvider.close();
> > > > > > > > > >     }
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > Bean to test annotations:
> > > > > > > > > >
> > > > > > > > > > @Stateless
> > > > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > > > public class KeyValueBean {
> > > > > > > > > >
> > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > > > > >
> > > > > > > > > >     @CacheResult
> > > > > > > > > >     public String add(@CacheKey String key, String
> value) {
> > > > > > > > > >         log.info(String.format("Adding key: %s, value:
> > %s",
> > > > > key,
> > > > > > > > > value));
> > > > > > > > > >         return value;
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     @CacheRemoveAll
> > > > > > > > > >     public void invalidateCache() {
> > > > > > > > > >         log.info("Cache invalidated");
> > > > > > > > > >     }
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > Unit test:
> > > > > > > > > >
> > > > > > > > > > public class CacheBeanTest {
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Logger.
> > > > > > > > > >      */
> > > > > > > > > >     private static final Logger log =
> > > > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > > > >             getName());
> > > > > > > > > >     /**
> > > > > > > > > >      * Injected cache bean.
> > > > > > > > > >      */
> > > > > > > > > >     @EJB
> > > > > > > > > >     private CacheBean cacheBean;
> > > > > > > > > >     /**
> > > > > > > > > >      * Our key/value bean.
> > > > > > > > > >      */
> > > > > > > > > >     @EJB
> > > > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * EJB container.
> > > > > > > > > >      */
> > > > > > > > > >     private static EJBContainer container;
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Start EJB container.
> > > > > > > > > >      */
> > > > > > > > > >     @BeforeClass
> > > > > > > > > >     public static void setUpClass() {
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Close caching provider/manager and EJB container.
> > > > > > > > > >      */
> > > > > > > > > >     @AfterClass
> > > > > > > > > >     public static void tearDownClass() {
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Set up.
> > > > > > > > > >      */
> > > > > > > > > >     @Before
> > > > > > > > > >     public void setUp() throws NamingException {
> > > > > > > > > >         log.info("setUp()");
> > > > > > > > > >         container = EJBContainer.createEJBContainer();
> > > > > > > > > >         container.getContext().bind("inject", this);
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Tear down.
> > > > > > > > > >      */
> > > > > > > > > >     @After
> > > > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > > > >         container.getContext().unbind("inject");
> > > > > > > > > >         container.close();
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > > > >      */
> > > > > > > > > >     @Test
> > > > > > > > > >     public final void testCache() {
> > > > > > > > > >         log.info("testCache");
> > > > > > > > > >         assertNotNull(cacheBean);
> > > > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > >                 getCacheNames()));
> > > > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > >                 getCache("testCache");
> > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > testCache.getName()));
> > > > > > > > > >         // This should display value1, but it doesn't
> > > > > > > > > >         log.info(String.format("Value: %s",
> > > > > > testCache.get("key1")));
> > > > > > > > > >         testCache.close();
> > > > > > > > > >     }
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via
> > > TomEE
> > > > &
> > > > > > > > > OpenEJB] <
> > > > > > > > > > [hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > > > > > >
> > > > > > > > > > > dont have time to look now but here a sample i wrote
> > which
> > > is
> > > > > > green
> > > > > > > > > > there:
> > > > > > > > > > >
> https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
>  Blog
> > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > Tomitriber
> > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > >
> > > > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > > > <http://
> > /user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > > > >
> > > > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > > > >
> > > > > > > > > > > > I'm not sure the <interceptors> in beans.xml are
> being
> > > > > loaded
> > > > > > or
> > > > > > > > > that I
> > > > > > > > > > > > have
> > > > > > > > > > > > the container set up right for the unit test
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > > > >
> > > > > > > > > > > > I'm using the EHCache provider and it fires up fine
> and
> > > can
> > > > > > > > interact
> > > > > > > > > > > with
> > > > > > > > > > > > it, but CDI doesn't appear to be working. Any help
> > > getting
> > > > > the
> > > > > > > > > working
> > > > > > > > > > > in
> > > > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > View this message in context:
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > > Nabble.com.
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > ------------------------------
> > > > > > > > > > > If you reply to this email, your message will be added
> to
> > > the
> > > > > > > > > discussion
> > > > > > > > > > > below:
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > > > <
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > > > > > >
> > > > > > > > > > > .
> > > > > > > > > > > NAML
> > > > > > > > > > > <
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > View this message in context:
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > Nabble.com.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Steven P. Goldsmith
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven P. Goldsmith
> > > > > >
> > > > >
> > > > >
> > > > > ------------------------------
> > > > > If you reply to this email, your message will be added to the
> > > discussion
> > > > > below:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > > > To unsubscribe from JCache CDI, click here
> > > > > <
> > > >
> > > >
> > > > > .
> > > > > NAML
> > > > > <
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Steven P. Goldsmith
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > >
> > >
> > >
> > > ------------------------------
> > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> > > To unsubscribe from JCache CDI, click here
> > > <
> >
> >
> > > .
> > > NAML
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675992.html
> To unsubscribe from JCache CDI, click here
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5>
> .
> NAML
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Steven P. Goldsmith




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675995.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
EJBContainer is about jars and doesnt know anything of wars until you use
tomee (embedded or not but needs a packaging phase). ApplicationComposer is
nicer for such small tests in general since you can list all you need in
@Classes

Having beans.xml only in META-INF works even if it would be better to keep
it in WEB-INF for consistency with other descriptors


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-27 17:06 GMT+02:00 Steve Goldsmith <sg...@gmail.com>:

> It here any issue with having beans.xml in META-INF and WEB-INF from a
> deployment to TomEE stand alone? Or can I specify WEB-INF scanning from
> EJBContainer?
>
> On Thu, Aug 27, 2015 at 10:59 AM, Romain Manni-Bucau <
> rmannibucau@gmail.com>
> wrote:
>
> > EJBContainer doesnt read WEB-INF by default so put your beans.xml in
> > META-INF
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-27 16:45 GMT+02:00 sgjava <sg...@gmail.com>:
> >
> > > https://github.com/sgjava/my-jaxrs-test
> > >
> > > CacheBeanTest
> > >
> > > Thanks.
> > >
> > > On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE &
> > OpenEJB]
> > > <
> > > ml-node+s979440n4675990h1@n4.nabble.com> wrote:
> > >
> > > > hmm, push this sample on github, I'll try to check in the coming
> hours
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
> > > >
> > > > > I get no cache results using:
> > > > >
> > > > >         keyValueBean.add("key1", "value1");
> > > > >         final Cache<String, String> testCache =
> > > > > cacheBean.getCacheManager().
> > > > >                 getCache("testCache");
> > > > >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> > > > testCache.
> > > > >                 iterator();
> > > > >         while (allCacheEntries.hasNext()) {
> > > > >             Cache.Entry<String, String> currentEntry =
> > > > > allCacheEntries.next();
> > > > >             log.info("Key: " + currentEntry.getKey() + " Value: "
> > > > >                     + currentEntry.getValue());
> > > > >         }
> > > > >
> > > > > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE &
> > > > OpenEJB]
> > > > > <
> > > > > [hidden email] <http://
> > > /user/SendEmail.jtp?type=node&node=4675990&i=1>>
> > > > wrote:
> > > > >
> > > > > > no default implementation in the API but clearly de default in
> the
> > > > > > provider
> > > > > > you can maybe reuse. Iterating over the cache - for test purpose
> -
> > is
> > > > an
> > > > > > alternative you can use.
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > > > > >
> > > > > > > Ah, OK, that wasn't evident from what I've read so far. Is
> there
> > a
> > > > > > default
> > > > > > > implementation or do you have to create one?
> > > > > > >
> > > > > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden
> > email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > no, @CacheKey doesnt mean your parameter is the key, it means
> > it
> > > > is
> > > > > > used
> > > > > > > in
> > > > > > > > the key but the key is still a GeneratedCacheKey
> > > > > > > >
> > > > > > > >
> > > > > > > > Romain Manni-Bucau
> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > > <http://www.tomitribe.com>
> > > > > > > >
> > > > > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > > > > >
> > > > > > > > > I'm just not able to see the cached values by using:
> > > > > > > > >
> > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > >                 getCache("testCache");
> > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > testCache.getName()));
> > > > > > > > >
> > > > > > > > > *        // This should display value1, but it doesn't
> > > > > > log.info
> > > > > > > > > <http://log.info>(String.format("Value: %s",
> > > > > > testCache.get("key1")));*
> > > > > > > > >
> > > > > > > > > ehcache.xml:
> > > > > > > > >
> > > > > > > > > <ehcache xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance"
> > > > > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > > > > >          dynamicConfig="true">
> > > > > > > > >
> > > > > > > > >     <defaultCache
> > > > > > > > >         maxEntriesLocalHeap="1000000"
> > > > > > > > >         eternal="false"
> > > > > > > > >         timeToIdleSeconds="86400"
> > > > > > > > >         timeToLiveSeconds="86400"
> > > > > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > > > > >     </defaultCache>
> > > > > > > > >
> > > > > > > > >     <cache name="testCache"
> > > > > > > > >            maxEntriesLocalHeap="1000000"
> > > > > > > > >            eternal="false"
> > > > > > > > >            timeToIdleSeconds="600"
> > > > > > > > >            timeToLiveSeconds="600"
> > > > > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > > > > >     </cache>
> > > > > > > > >
> > > > > > > > > </ehcache>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > > > > [hidden email] <http://
> > > > > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > > > > >
> > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > looks good, did you encounter any issue or did you ask
> only
> > > > for a
> > > > > > > > review?
> > > > > > > > > >
> > > > > > > > > > Note: beans.xml should be empty if already provided by ri
> > > jar.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > Tomitriber
> > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > >
> > > > > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > > > > >
> > > > > > > > > > > Your examples all have invokers, etc. but none of the
> > other
> > > > > > example
> > > > > > > > > I've
> > > > > > > > > > > seen require this. Since you don't have time to look,
> > maybe
> > > > you
> > > > > > can
> > > > > > > > see
> > > > > > > > > > if
> > > > > > > > > > > my structure looks good:
> > > > > > > > > > >
> > > > > > > > > > > pom.xml:
> > > > > > > > > > >
> > > > > > > > > > >         <dependency>
> > > > > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > > > > >
> > > > <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > > > > >             <version>1.0.0</version>
> > > > > > > > > > >         </dependency>
> > > > > > > > > > >         <dependency>
> > > > > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > > > > >             <version>1.0.1</version>
> > > > > > > > > > >             <scope>compile</scope>
> > > > > > > > > > >         </dependency>
> > > > > > > > > > >
> > > > > > > > > > > beans.xml:
> > > > > > > > > > >
> > > > > > > > > > > <beans>
> > > > > > > > > > >     <interceptors>
> > > > > > > > > > >
> > > > > > > > > >
> > > > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > >
> > > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > > > > >
> > > > > > > > >
> > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > > > > >     </interceptors>
> > > > > > > > > > > </beans>
> > > > > > > > > > >
> > > > > > > > > > > Cache bean:
> > > > > > > > > > >
> > > > > > > > > > > @Singleton
> > > > > > > > > > > @Startup
> > > > > > > > > > > @Lock(READ)
> > > > > > > > > > > public class CacheBean {
> > > > > > > > > > >
> > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Caching provider.
> > > > > > > > > > >      */
> > > > > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Cache manager.
> > > > > > > > > > >      */
> > > > > > > > > > >     private CacheManager cacheManager;
> > > > > > > > > > >
> > > > > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > > > > >         return cacheManager;
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Using EHCache provider configured via
> ehcache.xml
> > in
> > > > > > > > classpath.
> > > > > > > > > > >      */
> > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > >     @PostConstruct
> > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > >     public void init() {
> > > > > > > > > > >         log.info("PostConstruct");
> > > > > > > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > > > > > > >         cacheManager =
> cachingProvider.getCacheManager();
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Destroy cache.
> > > > > > > > > > >      */
> > > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > > >     @PreDestroy
> > > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > > >     public void destroy() {
> > > > > > > > > > >         log.info("PreDestroy");
> > > > > > > > > > >         cacheManager.close();
> > > > > > > > > > >         cachingProvider.close();
> > > > > > > > > > >     }
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > Bean to test annotations:
> > > > > > > > > > >
> > > > > > > > > > > @Stateless
> > > > > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > > > > public class KeyValueBean {
> > > > > > > > > > >
> > > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > > > > > >
> > > > > > > > > > >     @CacheResult
> > > > > > > > > > >     public String add(@CacheKey String key, String
> > value) {
> > > > > > > > > > >         log.info(String.format("Adding key: %s, value:
> > > %s",
> > > > > > key,
> > > > > > > > > > value));
> > > > > > > > > > >         return value;
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     @CacheRemoveAll
> > > > > > > > > > >     public void invalidateCache() {
> > > > > > > > > > >         log.info("Cache invalidated");
> > > > > > > > > > >     }
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > Unit test:
> > > > > > > > > > >
> > > > > > > > > > > public class CacheBeanTest {
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Logger.
> > > > > > > > > > >      */
> > > > > > > > > > >     private static final Logger log =
> > > > > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > > > > >             getName());
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Injected cache bean.
> > > > > > > > > > >      */
> > > > > > > > > > >     @EJB
> > > > > > > > > > >     private CacheBean cacheBean;
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Our key/value bean.
> > > > > > > > > > >      */
> > > > > > > > > > >     @EJB
> > > > > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * EJB container.
> > > > > > > > > > >      */
> > > > > > > > > > >     private static EJBContainer container;
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Start EJB container.
> > > > > > > > > > >      */
> > > > > > > > > > >     @BeforeClass
> > > > > > > > > > >     public static void setUpClass() {
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Close caching provider/manager and EJB
> container.
> > > > > > > > > > >      */
> > > > > > > > > > >     @AfterClass
> > > > > > > > > > >     public static void tearDownClass() {
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Set up.
> > > > > > > > > > >      */
> > > > > > > > > > >     @Before
> > > > > > > > > > >     public void setUp() throws NamingException {
> > > > > > > > > > >         log.info("setUp()");
> > > > > > > > > > >         container = EJBContainer.createEJBContainer();
> > > > > > > > > > >         container.getContext().bind("inject", this);
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Tear down.
> > > > > > > > > > >      */
> > > > > > > > > > >     @After
> > > > > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > > > > >         container.getContext().unbind("inject");
> > > > > > > > > > >         container.close();
> > > > > > > > > > >     }
> > > > > > > > > > >
> > > > > > > > > > >     /**
> > > > > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > > > > >      */
> > > > > > > > > > >     @Test
> > > > > > > > > > >     public final void testCache() {
> > > > > > > > > > >         log.info("testCache");
> > > > > > > > > > >         assertNotNull(cacheBean);
> > > > > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > >                 getCacheNames()));
> > > > > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > > >                 getCache("testCache");
> > > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > > testCache.getName()));
> > > > > > > > > > >         // This should display value1, but it doesn't
> > > > > > > > > > >         log.info(String.format("Value: %s",
> > > > > > > testCache.get("key1")));
> > > > > > > > > > >         testCache.close();
> > > > > > > > > > >     }
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau
> [via
> > > > TomEE
> > > > > &
> > > > > > > > > > OpenEJB] <
> > > > > > > > > > > [hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > > > > > > >
> > > > > > > > > > > > dont have time to look now but here a sample i wrote
> > > which
> > > > is
> > > > > > > green
> > > > > > > > > > > there:
> > > > > > > > > > > >
> > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |
> Blog
> > > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > > Tomitriber
> > > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > > >
> > > > > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > > > > <http://
> > > /user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > > > > >
> > > > > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm not sure the <interceptors> in beans.xml are
> > being
> > > > > > loaded
> > > > > > > or
> > > > > > > > > > that I
> > > > > > > > > > > > > have
> > > > > > > > > > > > > the container set up right for the unit test
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm using the EHCache provider and it fires up fine
> > and
> > > > can
> > > > > > > > > interact
> > > > > > > > > > > > with
> > > > > > > > > > > > > it, but CDI doesn't appear to be working. Any help
> > > > getting
> > > > > > the
> > > > > > > > > > working
> > > > > > > > > > > > in
> > > > > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --
> > > > > > > > > > > > > View this message in context:
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > > > Nabble.com.
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > ------------------------------
> > > > > > > > > > > > If you reply to this email, your message will be
> added
> > to
> > > > the
> > > > > > > > > > discussion
> > > > > > > > > > > > below:
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > > > > <
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > > .
> > > > > > > > > > > > NAML
> > > > > > > > > > > > <
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > View this message in context:
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > Nabble.com.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Steven P. Goldsmith
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven P. Goldsmith
> > > > > > >
> > > > > >
> > > > > >
> > > > > > ------------------------------
> > > > > > If you reply to this email, your message will be added to the
> > > > discussion
> > > > > > below:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > > > > To unsubscribe from JCache CDI, click here
> > > > > > <
> > > > >
> > > > >
> > > > > > .
> > > > > > NAML
> > > > > > <
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven P. Goldsmith
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > View this message in context:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > >
> > > >
> > > >
> > > > ------------------------------
> > > > If you reply to this email, your message will be added to the
> > discussion
> > > > below:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> > > > To unsubscribe from JCache CDI, click here
> > > > <
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> > > >
> > > > .
> > > > NAML
> > > > <
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > >
> >
>
>
>
> --
> Steven P. Goldsmith
>

Re: JCache CDI

Posted by Steve Goldsmith <sg...@gmail.com>.
It here any issue with having beans.xml in META-INF and WEB-INF from a
deployment to TomEE stand alone? Or can I specify WEB-INF scanning from
EJBContainer?

On Thu, Aug 27, 2015 at 10:59 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> EJBContainer doesnt read WEB-INF by default so put your beans.xml in
> META-INF
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 16:45 GMT+02:00 sgjava <sg...@gmail.com>:
>
> > https://github.com/sgjava/my-jaxrs-test
> >
> > CacheBeanTest
> >
> > Thanks.
> >
> > On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE &
> OpenEJB]
> > <
> > ml-node+s979440n4675990h1@n4.nabble.com> wrote:
> >
> > > hmm, push this sample on github, I'll try to check in the coming hours
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
> > >
> > > > I get no cache results using:
> > > >
> > > >         keyValueBean.add("key1", "value1");
> > > >         final Cache<String, String> testCache =
> > > > cacheBean.getCacheManager().
> > > >                 getCache("testCache");
> > > >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> > > testCache.
> > > >                 iterator();
> > > >         while (allCacheEntries.hasNext()) {
> > > >             Cache.Entry<String, String> currentEntry =
> > > > allCacheEntries.next();
> > > >             log.info("Key: " + currentEntry.getKey() + " Value: "
> > > >                     + currentEntry.getValue());
> > > >         }
> > > >
> > > > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE &
> > > OpenEJB]
> > > > <
> > > > [hidden email] <http://
> > /user/SendEmail.jtp?type=node&node=4675990&i=1>>
> > > wrote:
> > > >
> > > > > no default implementation in the API but clearly de default in the
> > > > > provider
> > > > > you can maybe reuse. Iterating over the cache - for test purpose -
> is
> > > an
> > > > > alternative you can use.
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > > > >
> > > > > > Ah, OK, that wasn't evident from what I've read so far. Is there
> a
> > > > > default
> > > > > > implementation or do you have to create one?
> > > > > >
> > > > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden
> email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > no, @CacheKey doesnt mean your parameter is the key, it means
> it
> > > is
> > > > > used
> > > > > > in
> > > > > > > the key but the key is still a GeneratedCacheKey
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > > > >
> > > > > > > > I'm just not able to see the cached values by using:
> > > > > > > >
> > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > cacheBean.getCacheManager().
> > > > > > > >                 getCache("testCache");
> > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > testCache.getName()));
> > > > > > > >
> > > > > > > > *        // This should display value1, but it doesn't
> > > > > log.info
> > > > > > > > <http://log.info>(String.format("Value: %s",
> > > > > testCache.get("key1")));*
> > > > > > > >
> > > > > > > > ehcache.xml:
> > > > > > > >
> > > > > > > > <ehcache xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
> > > > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > > > >          dynamicConfig="true">
> > > > > > > >
> > > > > > > >     <defaultCache
> > > > > > > >         maxEntriesLocalHeap="1000000"
> > > > > > > >         eternal="false"
> > > > > > > >         timeToIdleSeconds="86400"
> > > > > > > >         timeToLiveSeconds="86400"
> > > > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > > > >     </defaultCache>
> > > > > > > >
> > > > > > > >     <cache name="testCache"
> > > > > > > >            maxEntriesLocalHeap="1000000"
> > > > > > > >            eternal="false"
> > > > > > > >            timeToIdleSeconds="600"
> > > > > > > >            timeToLiveSeconds="600"
> > > > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > > > >     </cache>
> > > > > > > >
> > > > > > > > </ehcache>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > > > [hidden email] <http://
> > > > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > looks good, did you encounter any issue or did you ask only
> > > for a
> > > > > > > review?
> > > > > > > > >
> > > > > > > > > Note: beans.xml should be empty if already provided by ri
> > jar.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Romain Manni-Bucau
> > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > >
> > > > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > > > >
> > > > > > > > > > Your examples all have invokers, etc. but none of the
> other
> > > > > example
> > > > > > > > I've
> > > > > > > > > > seen require this. Since you don't have time to look,
> maybe
> > > you
> > > > > can
> > > > > > > see
> > > > > > > > > if
> > > > > > > > > > my structure looks good:
> > > > > > > > > >
> > > > > > > > > > pom.xml:
> > > > > > > > > >
> > > > > > > > > >         <dependency>
> > > > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > > > >
> > > <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > > > >             <version>1.0.0</version>
> > > > > > > > > >         </dependency>
> > > > > > > > > >         <dependency>
> > > > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > > > >             <version>1.0.1</version>
> > > > > > > > > >             <scope>compile</scope>
> > > > > > > > > >         </dependency>
> > > > > > > > > >
> > > > > > > > > > beans.xml:
> > > > > > > > > >
> > > > > > > > > > <beans>
> > > > > > > > > >     <interceptors>
> > > > > > > > > >
> > > > > > > > >
> > > > >
> <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > >
> > > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > > > >
> > > > > > > >
> > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > > > >     </interceptors>
> > > > > > > > > > </beans>
> > > > > > > > > >
> > > > > > > > > > Cache bean:
> > > > > > > > > >
> > > > > > > > > > @Singleton
> > > > > > > > > > @Startup
> > > > > > > > > > @Lock(READ)
> > > > > > > > > > public class CacheBean {
> > > > > > > > > >
> > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Caching provider.
> > > > > > > > > >      */
> > > > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > > > >     /**
> > > > > > > > > >      * Cache manager.
> > > > > > > > > >      */
> > > > > > > > > >     private CacheManager cacheManager;
> > > > > > > > > >
> > > > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > > > >         return cacheManager;
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Using EHCache provider configured via ehcache.xml
> in
> > > > > > > classpath.
> > > > > > > > > >      */
> > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > >     @PostConstruct
> > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > >     public void init() {
> > > > > > > > > >         log.info("PostConstruct");
> > > > > > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > > > > > >         cacheManager = cachingProvider.getCacheManager();
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Destroy cache.
> > > > > > > > > >      */
> > > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > > >     @PreDestroy
> > > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > > >     public void destroy() {
> > > > > > > > > >         log.info("PreDestroy");
> > > > > > > > > >         cacheManager.close();
> > > > > > > > > >         cachingProvider.close();
> > > > > > > > > >     }
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > Bean to test annotations:
> > > > > > > > > >
> > > > > > > > > > @Stateless
> > > > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > > > public class KeyValueBean {
> > > > > > > > > >
> > > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > > > > >
> > > > > > > > > >     @CacheResult
> > > > > > > > > >     public String add(@CacheKey String key, String
> value) {
> > > > > > > > > >         log.info(String.format("Adding key: %s, value:
> > %s",
> > > > > key,
> > > > > > > > > value));
> > > > > > > > > >         return value;
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     @CacheRemoveAll
> > > > > > > > > >     public void invalidateCache() {
> > > > > > > > > >         log.info("Cache invalidated");
> > > > > > > > > >     }
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > Unit test:
> > > > > > > > > >
> > > > > > > > > > public class CacheBeanTest {
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Logger.
> > > > > > > > > >      */
> > > > > > > > > >     private static final Logger log =
> > > > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > > > >             getName());
> > > > > > > > > >     /**
> > > > > > > > > >      * Injected cache bean.
> > > > > > > > > >      */
> > > > > > > > > >     @EJB
> > > > > > > > > >     private CacheBean cacheBean;
> > > > > > > > > >     /**
> > > > > > > > > >      * Our key/value bean.
> > > > > > > > > >      */
> > > > > > > > > >     @EJB
> > > > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * EJB container.
> > > > > > > > > >      */
> > > > > > > > > >     private static EJBContainer container;
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Start EJB container.
> > > > > > > > > >      */
> > > > > > > > > >     @BeforeClass
> > > > > > > > > >     public static void setUpClass() {
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Close caching provider/manager and EJB container.
> > > > > > > > > >      */
> > > > > > > > > >     @AfterClass
> > > > > > > > > >     public static void tearDownClass() {
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Set up.
> > > > > > > > > >      */
> > > > > > > > > >     @Before
> > > > > > > > > >     public void setUp() throws NamingException {
> > > > > > > > > >         log.info("setUp()");
> > > > > > > > > >         container = EJBContainer.createEJBContainer();
> > > > > > > > > >         container.getContext().bind("inject", this);
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Tear down.
> > > > > > > > > >      */
> > > > > > > > > >     @After
> > > > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > > > >         container.getContext().unbind("inject");
> > > > > > > > > >         container.close();
> > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > >     /**
> > > > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > > > >      */
> > > > > > > > > >     @Test
> > > > > > > > > >     public final void testCache() {
> > > > > > > > > >         log.info("testCache");
> > > > > > > > > >         assertNotNull(cacheBean);
> > > > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > >                 getCacheNames()));
> > > > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > > >                 getCache("testCache");
> > > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > > testCache.getName()));
> > > > > > > > > >         // This should display value1, but it doesn't
> > > > > > > > > >         log.info(String.format("Value: %s",
> > > > > > testCache.get("key1")));
> > > > > > > > > >         testCache.close();
> > > > > > > > > >     }
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via
> > > TomEE
> > > > &
> > > > > > > > > OpenEJB] <
> > > > > > > > > > [hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > > > > > >
> > > > > > > > > > > dont have time to look now but here a sample i wrote
> > which
> > > is
> > > > > > green
> > > > > > > > > > there:
> > > > > > > > > > >
> https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > > Tomitriber
> > > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > > >
> > > > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > > > <http://
> > /user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > > > >
> > > > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > > > >
> > > > > > > > > > > > I'm not sure the <interceptors> in beans.xml are
> being
> > > > > loaded
> > > > > > or
> > > > > > > > > that I
> > > > > > > > > > > > have
> > > > > > > > > > > > the container set up right for the unit test
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > > > >
> > > > > > > > > > > > I'm using the EHCache provider and it fires up fine
> and
> > > can
> > > > > > > > interact
> > > > > > > > > > > with
> > > > > > > > > > > > it, but CDI doesn't appear to be working. Any help
> > > getting
> > > > > the
> > > > > > > > > working
> > > > > > > > > > > in
> > > > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > View this message in context:
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > > Nabble.com.
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > ------------------------------
> > > > > > > > > > > If you reply to this email, your message will be added
> to
> > > the
> > > > > > > > > discussion
> > > > > > > > > > > below:
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > > > <
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > > > > > >
> > > > > > > > > > > .
> > > > > > > > > > > NAML
> > > > > > > > > > > <
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Steven P. Goldsmith
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > View this message in context:
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > Nabble.com.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Steven P. Goldsmith
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven P. Goldsmith
> > > > > >
> > > > >
> > > > >
> > > > > ------------------------------
> > > > > If you reply to this email, your message will be added to the
> > > discussion
> > > > > below:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > > > To unsubscribe from JCache CDI, click here
> > > > > <
> > > >
> > > >
> > > > > .
> > > > > NAML
> > > > > <
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Steven P. Goldsmith
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > >
> > >
> > >
> > > ------------------------------
> > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> > > To unsubscribe from JCache CDI, click here
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> > >
> > > .
> > > NAML
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>



-- 
Steven P. Goldsmith

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
EJBContainer doesnt read WEB-INF by default so put your beans.xml in
META-INF


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-27 16:45 GMT+02:00 sgjava <sg...@gmail.com>:

> https://github.com/sgjava/my-jaxrs-test
>
> CacheBeanTest
>
> Thanks.
>
> On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE & OpenEJB]
> <
> ml-node+s979440n4675990h1@n4.nabble.com> wrote:
>
> > hmm, push this sample on github, I'll try to check in the coming hours
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
> >
> > > I get no cache results using:
> > >
> > >         keyValueBean.add("key1", "value1");
> > >         final Cache<String, String> testCache =
> > > cacheBean.getCacheManager().
> > >                 getCache("testCache");
> > >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> > testCache.
> > >                 iterator();
> > >         while (allCacheEntries.hasNext()) {
> > >             Cache.Entry<String, String> currentEntry =
> > > allCacheEntries.next();
> > >             log.info("Key: " + currentEntry.getKey() + " Value: "
> > >                     + currentEntry.getValue());
> > >         }
> > >
> > > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE &
> > OpenEJB]
> > > <
> > > [hidden email] <http://
> /user/SendEmail.jtp?type=node&node=4675990&i=1>>
> > wrote:
> > >
> > > > no default implementation in the API but clearly de default in the
> > > > provider
> > > > you can maybe reuse. Iterating over the cache - for test purpose - is
> > an
> > > > alternative you can use.
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > > >
> > > > > Ah, OK, that wasn't evident from what I've read so far. Is there a
> > > > default
> > > > > implementation or do you have to create one?
> > > > >
> > > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > > >
> > > > > wrote:
> > > > >
> > > > > > no, @CacheKey doesnt mean your parameter is the key, it means it
> > is
> > > > used
> > > > > in
> > > > > > the key but the key is still a GeneratedCacheKey
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > > >
> > > > > > > I'm just not able to see the cached values by using:
> > > > > > >
> > > > > > >         final Cache<String, String> testCache =
> > > > > > > cacheBean.getCacheManager().
> > > > > > >                 getCache("testCache");
> > > > > > >         log.info(String.format("Cache name: %s",
> > > > > testCache.getName()));
> > > > > > >
> > > > > > > *        // This should display value1, but it doesn't
> > > > log.info
> > > > > > > <http://log.info>(String.format("Value: %s",
> > > > testCache.get("key1")));*
> > > > > > >
> > > > > > > ehcache.xml:
> > > > > > >
> > > > > > > <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > > >          dynamicConfig="true">
> > > > > > >
> > > > > > >     <defaultCache
> > > > > > >         maxEntriesLocalHeap="1000000"
> > > > > > >         eternal="false"
> > > > > > >         timeToIdleSeconds="86400"
> > > > > > >         timeToLiveSeconds="86400"
> > > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > > >     </defaultCache>
> > > > > > >
> > > > > > >     <cache name="testCache"
> > > > > > >            maxEntriesLocalHeap="1000000"
> > > > > > >            eternal="false"
> > > > > > >            timeToIdleSeconds="600"
> > > > > > >            timeToLiveSeconds="600"
> > > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > > >     </cache>
> > > > > > >
> > > > > > > </ehcache>
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > > [hidden email] <http://
> > > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > looks good, did you encounter any issue or did you ask only
> > for a
> > > > > > review?
> > > > > > > >
> > > > > > > > Note: beans.xml should be empty if already provided by ri
> jar.
> > > > > > > >
> > > > > > > >
> > > > > > > > Romain Manni-Bucau
> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > > <http://www.tomitribe.com>
> > > > > > > >
> > > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > > >
> > > > > > > > > Your examples all have invokers, etc. but none of the other
> > > > example
> > > > > > > I've
> > > > > > > > > seen require this. Since you don't have time to look, maybe
> > you
> > > > can
> > > > > > see
> > > > > > > > if
> > > > > > > > > my structure looks good:
> > > > > > > > >
> > > > > > > > > pom.xml:
> > > > > > > > >
> > > > > > > > >         <dependency>
> > > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > > >
> > <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > > >             <version>1.0.0</version>
> > > > > > > > >         </dependency>
> > > > > > > > >         <dependency>
> > > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > > >             <version>1.0.1</version>
> > > > > > > > >             <scope>compile</scope>
> > > > > > > > >         </dependency>
> > > > > > > > >
> > > > > > > > > beans.xml:
> > > > > > > > >
> > > > > > > > > <beans>
> > > > > > > > >     <interceptors>
> > > > > > > > >
> > > > > > > >
> > > >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > > >
> > > > > > > > >
> > > > > >
> > > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > > >
> > > > > > >
> >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > > >     </interceptors>
> > > > > > > > > </beans>
> > > > > > > > >
> > > > > > > > > Cache bean:
> > > > > > > > >
> > > > > > > > > @Singleton
> > > > > > > > > @Startup
> > > > > > > > > @Lock(READ)
> > > > > > > > > public class CacheBean {
> > > > > > > > >
> > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Caching provider.
> > > > > > > > >      */
> > > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > > >     /**
> > > > > > > > >      * Cache manager.
> > > > > > > > >      */
> > > > > > > > >     private CacheManager cacheManager;
> > > > > > > > >
> > > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > > >         return cacheManager;
> > > > > > > > >     }
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Using EHCache provider configured via ehcache.xml in
> > > > > > classpath.
> > > > > > > > >      */
> > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > >     @PostConstruct
> > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > >     public void init() {
> > > > > > > > >         log.info("PostConstruct");
> > > > > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > > > > >         cacheManager = cachingProvider.getCacheManager();
> > > > > > > > >     }
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Destroy cache.
> > > > > > > > >      */
> > > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > > >     @PreDestroy
> > > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > > >     public void destroy() {
> > > > > > > > >         log.info("PreDestroy");
> > > > > > > > >         cacheManager.close();
> > > > > > > > >         cachingProvider.close();
> > > > > > > > >     }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > Bean to test annotations:
> > > > > > > > >
> > > > > > > > > @Stateless
> > > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > > public class KeyValueBean {
> > > > > > > > >
> > > > > > > > >     private static final Logger log = Logger.
> > > > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > > > >
> > > > > > > > >     @CacheResult
> > > > > > > > >     public String add(@CacheKey String key, String value) {
> > > > > > > > >         log.info(String.format("Adding key: %s, value:
> %s",
> > > > key,
> > > > > > > > value));
> > > > > > > > >         return value;
> > > > > > > > >     }
> > > > > > > > >
> > > > > > > > >     @CacheRemoveAll
> > > > > > > > >     public void invalidateCache() {
> > > > > > > > >         log.info("Cache invalidated");
> > > > > > > > >     }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > Unit test:
> > > > > > > > >
> > > > > > > > > public class CacheBeanTest {
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Logger.
> > > > > > > > >      */
> > > > > > > > >     private static final Logger log =
> > > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > > >             getName());
> > > > > > > > >     /**
> > > > > > > > >      * Injected cache bean.
> > > > > > > > >      */
> > > > > > > > >     @EJB
> > > > > > > > >     private CacheBean cacheBean;
> > > > > > > > >     /**
> > > > > > > > >      * Our key/value bean.
> > > > > > > > >      */
> > > > > > > > >     @EJB
> > > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * EJB container.
> > > > > > > > >      */
> > > > > > > > >     private static EJBContainer container;
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Start EJB container.
> > > > > > > > >      */
> > > > > > > > >     @BeforeClass
> > > > > > > > >     public static void setUpClass() {
> > > > > > > > >     }
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Close caching provider/manager and EJB container.
> > > > > > > > >      */
> > > > > > > > >     @AfterClass
> > > > > > > > >     public static void tearDownClass() {
> > > > > > > > >     }
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Set up.
> > > > > > > > >      */
> > > > > > > > >     @Before
> > > > > > > > >     public void setUp() throws NamingException {
> > > > > > > > >         log.info("setUp()");
> > > > > > > > >         container = EJBContainer.createEJBContainer();
> > > > > > > > >         container.getContext().bind("inject", this);
> > > > > > > > >     }
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Tear down.
> > > > > > > > >      */
> > > > > > > > >     @After
> > > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > > >         container.getContext().unbind("inject");
> > > > > > > > >         container.close();
> > > > > > > > >     }
> > > > > > > > >
> > > > > > > > >     /**
> > > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > > >      */
> > > > > > > > >     @Test
> > > > > > > > >     public final void testCache() {
> > > > > > > > >         log.info("testCache");
> > > > > > > > >         assertNotNull(cacheBean);
> > > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > >                 getCacheNames()));
> > > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > > cacheBean.getCacheManager().
> > > > > > > > >                 getCache("testCache");
> > > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > > testCache.getName()));
> > > > > > > > >         // This should display value1, but it doesn't
> > > > > > > > >         log.info(String.format("Value: %s",
> > > > > testCache.get("key1")));
> > > > > > > > >         testCache.close();
> > > > > > > > >     }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via
> > TomEE
> > > &
> > > > > > > > OpenEJB] <
> > > > > > > > > [hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > > > > >
> > > > > > > > > > dont have time to look now but here a sample i wrote
> which
> > is
> > > > > green
> > > > > > > > > there:
> > > > > > > > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Romain Manni-Bucau
> > > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > > Tomitriber
> > > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > > >
> > > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > > <http://
> /user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > > >
> > > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > > >
> > > > > > > > > > > I'm not sure the <interceptors> in beans.xml are being
> > > > loaded
> > > > > or
> > > > > > > > that I
> > > > > > > > > > > have
> > > > > > > > > > > the container set up right for the unit test
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > > >
> > > > > > > > > > > I'm using the EHCache provider and it fires up fine and
> > can
> > > > > > > interact
> > > > > > > > > > with
> > > > > > > > > > > it, but CDI doesn't appear to be working. Any help
> > getting
> > > > the
> > > > > > > > working
> > > > > > > > > > in
> > > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > View this message in context:
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > > Nabble.com.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > ------------------------------
> > > > > > > > > > If you reply to this email, your message will be added to
> > the
> > > > > > > > discussion
> > > > > > > > > > below:
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > > <
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > > > > > >
> > > > > > > > > > .
> > > > > > > > > > NAML
> > > > > > > > > > <
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Steven P. Goldsmith
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > View this message in context:
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > > Sent from the TomEE Users mailing list archive at
> > Nabble.com.
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven P. Goldsmith
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven P. Goldsmith
> > > > >
> > > >
> > > >
> > > > ------------------------------
> > > > If you reply to this email, your message will be added to the
> > discussion
> > > > below:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > > To unsubscribe from JCache CDI, click here
> > > > <
> > >
> > >
> > > > .
> > > > NAML
> > > > <
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> > To unsubscribe from JCache CDI, click here
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> >
> > .
> > NAML
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
> --
> Steven P. Goldsmith
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JCache CDI

Posted by sgjava <sg...@gmail.com>.
https://github.com/sgjava/my-jaxrs-test

CacheBeanTest

Thanks.

On Thu, Aug 27, 2015 at 10:37 AM, Romain Manni-Bucau [via TomEE & OpenEJB] <
ml-node+s979440n4675990h1@n4.nabble.com> wrote:

> hmm, push this sample on github, I'll try to check in the coming hours
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 16:29 GMT+02:00 sgjava <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675990&i=0>>:
>
> > I get no cache results using:
> >
> >         keyValueBean.add("key1", "value1");
> >         final Cache<String, String> testCache =
> > cacheBean.getCacheManager().
> >                 getCache("testCache");
> >         Iterator<Cache.Entry<String, String>> allCacheEntries =
> testCache.
> >                 iterator();
> >         while (allCacheEntries.hasNext()) {
> >             Cache.Entry<String, String> currentEntry =
> > allCacheEntries.next();
> >             log.info("Key: " + currentEntry.getKey() + " Value: "
> >                     + currentEntry.getValue());
> >         }
> >
> > On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE &
> OpenEJB]
> > <
> > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4675990&i=1>>
> wrote:
> >
> > > no default implementation in the API but clearly de default in the
> > > provider
> > > you can maybe reuse. Iterating over the cache - for test purpose - is
> an
> > > alternative you can use.
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> > >
> > > > Ah, OK, that wasn't evident from what I've read so far. Is there a
> > > default
> > > > implementation or do you have to create one?
> > > >
> > > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > > >
> > > > wrote:
> > > >
> > > > > no, @CacheKey doesnt mean your parameter is the key, it means it
> is
> > > used
> > > > in
> > > > > the key but the key is still a GeneratedCacheKey
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > > >
> > > > > > I'm just not able to see the cached values by using:
> > > > > >
> > > > > >         final Cache<String, String> testCache =
> > > > > > cacheBean.getCacheManager().
> > > > > >                 getCache("testCache");
> > > > > >         log.info(String.format("Cache name: %s",
> > > > testCache.getName()));
> > > > > >
> > > > > > *        // This should display value1, but it doesn't
> > > log.info
> > > > > > <http://log.info>(String.format("Value: %s",
> > > testCache.get("key1")));*
> > > > > >
> > > > > > ehcache.xml:
> > > > > >
> > > > > > <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > > >          updateCheck="true" monitoring="autodetect"
> > > > > >          dynamicConfig="true">
> > > > > >
> > > > > >     <defaultCache
> > > > > >         maxEntriesLocalHeap="1000000"
> > > > > >         eternal="false"
> > > > > >         timeToIdleSeconds="86400"
> > > > > >         timeToLiveSeconds="86400"
> > > > > >         memoryStoreEvictionPolicy="LRU">
> > > > > >     </defaultCache>
> > > > > >
> > > > > >     <cache name="testCache"
> > > > > >            maxEntriesLocalHeap="1000000"
> > > > > >            eternal="false"
> > > > > >            timeToIdleSeconds="600"
> > > > > >            timeToLiveSeconds="600"
> > > > > >            memoryStoreEvictionPolicy="LFU">
> > > > > >     </cache>
> > > > > >
> > > > > > </ehcache>
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > > [hidden email] <http://
> > /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > looks good, did you encounter any issue or did you ask only
> for a
> > > > > review?
> > > > > > >
> > > > > > > Note: beans.xml should be empty if already provided by ri jar.
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > > >
> > > > > > > > Your examples all have invokers, etc. but none of the other
> > > example
> > > > > > I've
> > > > > > > > seen require this. Since you don't have time to look, maybe
> you
> > > can
> > > > > see
> > > > > > > if
> > > > > > > > my structure looks good:
> > > > > > > >
> > > > > > > > pom.xml:
> > > > > > > >
> > > > > > > >         <dependency>
> > > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > > >
> <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > > >             <version>1.0.0</version>
> > > > > > > >         </dependency>
> > > > > > > >         <dependency>
> > > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > > >             <artifactId>jcache</artifactId>
> > > > > > > >             <version>1.0.1</version>
> > > > > > > >             <scope>compile</scope>
> > > > > > > >         </dependency>
> > > > > > > >
> > > > > > > > beans.xml:
> > > > > > > >
> > > > > > > > <beans>
> > > > > > > >     <interceptors>
> > > > > > > >
> > > > > > >
> > >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > > >
> > > > > > > >
> > > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > > >
> > > > > >
>  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > > >     </interceptors>
> > > > > > > > </beans>
> > > > > > > >
> > > > > > > > Cache bean:
> > > > > > > >
> > > > > > > > @Singleton
> > > > > > > > @Startup
> > > > > > > > @Lock(READ)
> > > > > > > > public class CacheBean {
> > > > > > > >
> > > > > > > >     private static final Logger log = Logger.
> > > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Caching provider.
> > > > > > > >      */
> > > > > > > >     private CachingProvider cachingProvider;
> > > > > > > >     /**
> > > > > > > >      * Cache manager.
> > > > > > > >      */
> > > > > > > >     private CacheManager cacheManager;
> > > > > > > >
> > > > > > > >     public CacheManager getCacheManager() {
> > > > > > > >         return cacheManager;
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Using EHCache provider configured via ehcache.xml in
> > > > > classpath.
> > > > > > > >      */
> > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > >     @PostConstruct
> > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > >     public void init() {
> > > > > > > >         log.info("PostConstruct");
> > > > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > > > >         cacheManager = cachingProvider.getCacheManager();
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Destroy cache.
> > > > > > > >      */
> > > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > > >     @PreDestroy
> > > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > > >     public void destroy() {
> > > > > > > >         log.info("PreDestroy");
> > > > > > > >         cacheManager.close();
> > > > > > > >         cachingProvider.close();
> > > > > > > >     }
> > > > > > > > }
> > > > > > > >
> > > > > > > > Bean to test annotations:
> > > > > > > >
> > > > > > > > @Stateless
> > > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > > public class KeyValueBean {
> > > > > > > >
> > > > > > > >     private static final Logger log = Logger.
> > > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > > >
> > > > > > > >     @CacheResult
> > > > > > > >     public String add(@CacheKey String key, String value) {
> > > > > > > >         log.info(String.format("Adding key: %s, value: %s",
> > > key,
> > > > > > > value));
> > > > > > > >         return value;
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     @CacheRemoveAll
> > > > > > > >     public void invalidateCache() {
> > > > > > > >         log.info("Cache invalidated");
> > > > > > > >     }
> > > > > > > > }
> > > > > > > >
> > > > > > > > Unit test:
> > > > > > > >
> > > > > > > > public class CacheBeanTest {
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Logger.
> > > > > > > >      */
> > > > > > > >     private static final Logger log =
> > > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > > >             getName());
> > > > > > > >     /**
> > > > > > > >      * Injected cache bean.
> > > > > > > >      */
> > > > > > > >     @EJB
> > > > > > > >     private CacheBean cacheBean;
> > > > > > > >     /**
> > > > > > > >      * Our key/value bean.
> > > > > > > >      */
> > > > > > > >     @EJB
> > > > > > > >     private KeyValueBean keyValueBean;
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * EJB container.
> > > > > > > >      */
> > > > > > > >     private static EJBContainer container;
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Start EJB container.
> > > > > > > >      */
> > > > > > > >     @BeforeClass
> > > > > > > >     public static void setUpClass() {
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Close caching provider/manager and EJB container.
> > > > > > > >      */
> > > > > > > >     @AfterClass
> > > > > > > >     public static void tearDownClass() {
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Set up.
> > > > > > > >      */
> > > > > > > >     @Before
> > > > > > > >     public void setUp() throws NamingException {
> > > > > > > >         log.info("setUp()");
> > > > > > > >         container = EJBContainer.createEJBContainer();
> > > > > > > >         container.getContext().bind("inject", this);
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Tear down.
> > > > > > > >      */
> > > > > > > >     @After
> > > > > > > >     public void tearDown() throws NamingException {
> > > > > > > >         container.getContext().unbind("inject");
> > > > > > > >         container.close();
> > > > > > > >     }
> > > > > > > >
> > > > > > > >     /**
> > > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > > >      */
> > > > > > > >     @Test
> > > > > > > >     public final void testCache() {
> > > > > > > >         log.info("testCache");
> > > > > > > >         assertNotNull(cacheBean);
> > > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > > cacheBean.getCacheManager().
> > > > > > > >                 getCacheNames()));
> > > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > > >         final Cache<String, String> testCache =
> > > > > > > > cacheBean.getCacheManager().
> > > > > > > >                 getCache("testCache");
> > > > > > > >         log.info(String.format("Cache name: %s",
> > > > > > testCache.getName()));
> > > > > > > >         // This should display value1, but it doesn't
> > > > > > > >         log.info(String.format("Value: %s",
> > > > testCache.get("key1")));
> > > > > > > >         testCache.close();
> > > > > > > >     }
> > > > > > > > }
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via
> TomEE
> > &
> > > > > > > OpenEJB] <
> > > > > > > > [hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > > > >
> > > > > > > > > dont have time to look now but here a sample i wrote which
> is
> > > > green
> > > > > > > > there:
> > > > > > > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Romain Manni-Bucau
> > > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > > Tomitriber
> > > > > > > > > <http://www.tomitribe.com>
> > > > > > > > >
> > > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > > >
> > > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > > >
> > > > > > > > > > I'm not sure the <interceptors> in beans.xml are being
> > > loaded
> > > > or
> > > > > > > that I
> > > > > > > > > > have
> > > > > > > > > > the container set up right for the unit test
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > > >
> > > > > > > > > > I'm using the EHCache provider and it fires up fine and
> can
> > > > > > interact
> > > > > > > > > with
> > > > > > > > > > it, but CDI doesn't appear to be working. Any help
> getting
> > > the
> > > > > > > working
> > > > > > > > > in
> > > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > View this message in context:
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > > Sent from the TomEE Users mailing list archive at
> > > Nabble.com.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > ------------------------------
> > > > > > > > > If you reply to this email, your message will be added to
> the
> > > > > > > discussion
> > > > > > > > > below:
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > > <
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > > > > > >
> > > > > > > > > .
> > > > > > > > > NAML
> > > > > > > > > <
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Steven P. Goldsmith
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > View this message in context:
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > > Sent from the TomEE Users mailing list archive at
> Nabble.com.
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven P. Goldsmith
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Steven P. Goldsmith
> > > >
> > >
> > >
> > > ------------------------------
> > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > > To unsubscribe from JCache CDI, click here
> > > <
> >
> >
> > > .
> > > NAML
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675990.html
> To unsubscribe from JCache CDI, click here
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5>
> .
> NAML
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Steven P. Goldsmith




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675991.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
hmm, push this sample on github, I'll try to check in the coming hours


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-27 16:29 GMT+02:00 sgjava <sg...@gmail.com>:

> I get no cache results using:
>
>         keyValueBean.add("key1", "value1");
>         final Cache<String, String> testCache =
> cacheBean.getCacheManager().
>                 getCache("testCache");
>         Iterator<Cache.Entry<String, String>> allCacheEntries = testCache.
>                 iterator();
>         while (allCacheEntries.hasNext()) {
>             Cache.Entry<String, String> currentEntry =
> allCacheEntries.next();
>             log.info("Key: " + currentEntry.getKey() + " Value: "
>                     + currentEntry.getValue());
>         }
>
> On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE & OpenEJB]
> <
> ml-node+s979440n4675986h77@n4.nabble.com> wrote:
>
> > no default implementation in the API but clearly de default in the
> > provider
> > you can maybe reuse. Iterating over the cache - for test purpose - is an
> > alternative you can use.
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
> >
> > > Ah, OK, that wasn't evident from what I've read so far. Is there a
> > default
> > > implementation or do you have to create one?
> > >
> > > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > > >
> > > wrote:
> > >
> > > > no, @CacheKey doesnt mean your parameter is the key, it means it is
> > used
> > > in
> > > > the key but the key is still a GeneratedCacheKey
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > > >
> > > > > I'm just not able to see the cached values by using:
> > > > >
> > > > >         final Cache<String, String> testCache =
> > > > > cacheBean.getCacheManager().
> > > > >                 getCache("testCache");
> > > > >         log.info(String.format("Cache name: %s",
> > > testCache.getName()));
> > > > >
> > > > > *        // This should display value1, but it doesn't
> > log.info
> > > > > <http://log.info>(String.format("Value: %s",
> > testCache.get("key1")));*
> > > > >
> > > > > ehcache.xml:
> > > > >
> > > > > <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > > >          updateCheck="true" monitoring="autodetect"
> > > > >          dynamicConfig="true">
> > > > >
> > > > >     <defaultCache
> > > > >         maxEntriesLocalHeap="1000000"
> > > > >         eternal="false"
> > > > >         timeToIdleSeconds="86400"
> > > > >         timeToLiveSeconds="86400"
> > > > >         memoryStoreEvictionPolicy="LRU">
> > > > >     </defaultCache>
> > > > >
> > > > >     <cache name="testCache"
> > > > >            maxEntriesLocalHeap="1000000"
> > > > >            eternal="false"
> > > > >            timeToIdleSeconds="600"
> > > > >            timeToLiveSeconds="600"
> > > > >            memoryStoreEvictionPolicy="LFU">
> > > > >     </cache>
> > > > >
> > > > > </ehcache>
> > > > >
> > > > >
> > > > >
> > > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > > [hidden email] <http://
> /user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > > >
> > > > > wrote:
> > > > >
> > > > > > looks good, did you encounter any issue or did you ask only for a
> > > > review?
> > > > > >
> > > > > > Note: beans.xml should be empty if already provided by ri jar.
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > > >
> > > > > > > Your examples all have invokers, etc. but none of the other
> > example
> > > > > I've
> > > > > > > seen require this. Since you don't have time to look, maybe you
> > can
> > > > see
> > > > > > if
> > > > > > > my structure looks good:
> > > > > > >
> > > > > > > pom.xml:
> > > > > > >
> > > > > > >         <dependency>
> > > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > > >             <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > > >             <version>1.0.0</version>
> > > > > > >         </dependency>
> > > > > > >         <dependency>
> > > > > > >             <groupId>org.ehcache</groupId>
> > > > > > >             <artifactId>jcache</artifactId>
> > > > > > >             <version>1.0.1</version>
> > > > > > >             <scope>compile</scope>
> > > > > > >         </dependency>
> > > > > > >
> > > > > > > beans.xml:
> > > > > > >
> > > > > > > <beans>
> > > > > > >     <interceptors>
> > > > > > >
> > > > > >
> >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > > >
> > > > > > >
> > > > >
> > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > > >
> > > > > > >
> > > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > > >
> > > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > > >     </interceptors>
> > > > > > > </beans>
> > > > > > >
> > > > > > > Cache bean:
> > > > > > >
> > > > > > > @Singleton
> > > > > > > @Startup
> > > > > > > @Lock(READ)
> > > > > > > public class CacheBean {
> > > > > > >
> > > > > > >     private static final Logger log = Logger.
> > > > > > >             getLogger(CacheBean.class.getName());
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Caching provider.
> > > > > > >      */
> > > > > > >     private CachingProvider cachingProvider;
> > > > > > >     /**
> > > > > > >      * Cache manager.
> > > > > > >      */
> > > > > > >     private CacheManager cacheManager;
> > > > > > >
> > > > > > >     public CacheManager getCacheManager() {
> > > > > > >         return cacheManager;
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Using EHCache provider configured via ehcache.xml in
> > > > classpath.
> > > > > > >      */
> > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > >     @PostConstruct
> > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > >     public void init() {
> > > > > > >         log.info("PostConstruct");
> > > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > > >         cacheManager = cachingProvider.getCacheManager();
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Destroy cache.
> > > > > > >      */
> > > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > > >     @PreDestroy
> > > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > > >     public void destroy() {
> > > > > > >         log.info("PreDestroy");
> > > > > > >         cacheManager.close();
> > > > > > >         cachingProvider.close();
> > > > > > >     }
> > > > > > > }
> > > > > > >
> > > > > > > Bean to test annotations:
> > > > > > >
> > > > > > > @Stateless
> > > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > > public class KeyValueBean {
> > > > > > >
> > > > > > >     private static final Logger log = Logger.
> > > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > > >
> > > > > > >     @CacheResult
> > > > > > >     public String add(@CacheKey String key, String value) {
> > > > > > >         log.info(String.format("Adding key: %s, value: %s",
> > key,
> > > > > > value));
> > > > > > >         return value;
> > > > > > >     }
> > > > > > >
> > > > > > >     @CacheRemoveAll
> > > > > > >     public void invalidateCache() {
> > > > > > >         log.info("Cache invalidated");
> > > > > > >     }
> > > > > > > }
> > > > > > >
> > > > > > > Unit test:
> > > > > > >
> > > > > > > public class CacheBeanTest {
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Logger.
> > > > > > >      */
> > > > > > >     private static final Logger log =
> > > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > > >             getName());
> > > > > > >     /**
> > > > > > >      * Injected cache bean.
> > > > > > >      */
> > > > > > >     @EJB
> > > > > > >     private CacheBean cacheBean;
> > > > > > >     /**
> > > > > > >      * Our key/value bean.
> > > > > > >      */
> > > > > > >     @EJB
> > > > > > >     private KeyValueBean keyValueBean;
> > > > > > >
> > > > > > >     /**
> > > > > > >      * EJB container.
> > > > > > >      */
> > > > > > >     private static EJBContainer container;
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Start EJB container.
> > > > > > >      */
> > > > > > >     @BeforeClass
> > > > > > >     public static void setUpClass() {
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Close caching provider/manager and EJB container.
> > > > > > >      */
> > > > > > >     @AfterClass
> > > > > > >     public static void tearDownClass() {
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Set up.
> > > > > > >      */
> > > > > > >     @Before
> > > > > > >     public void setUp() throws NamingException {
> > > > > > >         log.info("setUp()");
> > > > > > >         container = EJBContainer.createEJBContainer();
> > > > > > >         container.getContext().bind("inject", this);
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Tear down.
> > > > > > >      */
> > > > > > >     @After
> > > > > > >     public void tearDown() throws NamingException {
> > > > > > >         container.getContext().unbind("inject");
> > > > > > >         container.close();
> > > > > > >     }
> > > > > > >
> > > > > > >     /**
> > > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > > >      */
> > > > > > >     @Test
> > > > > > >     public final void testCache() {
> > > > > > >         log.info("testCache");
> > > > > > >         assertNotNull(cacheBean);
> > > > > > >         log.info(String.format("Cache names: %s",
> > > > > > > cacheBean.getCacheManager().
> > > > > > >                 getCacheNames()));
> > > > > > >         keyValueBean.add("key1", "value1");
> > > > > > >         final Cache<String, String> testCache =
> > > > > > > cacheBean.getCacheManager().
> > > > > > >                 getCache("testCache");
> > > > > > >         log.info(String.format("Cache name: %s",
> > > > > testCache.getName()));
> > > > > > >         // This should display value1, but it doesn't
> > > > > > >         log.info(String.format("Value: %s",
> > > testCache.get("key1")));
> > > > > > >         testCache.close();
> > > > > > >     }
> > > > > > > }
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE
> &
> > > > > > OpenEJB] <
> > > > > > > [hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > > >
> > > > > > > > dont have time to look now but here a sample i wrote which is
> > > green
> > > > > > > there:
> > > > > > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > > >
> > > > > > > >
> > > > > > > > Romain Manni-Bucau
> > > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > > https://github.com/rmannibucau> |
> > > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> > Tomitriber
> > > > > > > > <http://www.tomitribe.com>
> > > > > > > >
> > > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > > >
> > > > > > > > > I added my JCache attempt in my test project
> > > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > > >
> > > > > > > > > I'm not sure the <interceptors> in beans.xml are being
> > loaded
> > > or
> > > > > > that I
> > > > > > > > > have
> > > > > > > > > the container set up right for the unit test
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > > >
> > > > > > > > > I'm using the EHCache provider and it fires up fine and can
> > > > > interact
> > > > > > > > with
> > > > > > > > > it, but CDI doesn't appear to be working. Any help getting
> > the
> > > > > > working
> > > > > > > > in
> > > > > > > > > TomEE 7 is appreciated.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > View this message in context:
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > > Sent from the TomEE Users mailing list archive at
> > Nabble.com.
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > ------------------------------
> > > > > > > > If you reply to this email, your message will be added to the
> > > > > > discussion
> > > > > > > > below:
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > > <
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > > > > > >
> > > > > > > > .
> > > > > > > > NAML
> > > > > > > > <
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven P. Goldsmith
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > View this message in context:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven P. Goldsmith
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> > To unsubscribe from JCache CDI, click here
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> >
> > .
> > NAML
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
> --
> Steven P. Goldsmith
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JCache CDI

Posted by sgjava <sg...@gmail.com>.
I get no cache results using:

        keyValueBean.add("key1", "value1");
        final Cache<String, String> testCache = cacheBean.getCacheManager().
                getCache("testCache");
        Iterator<Cache.Entry<String, String>> allCacheEntries = testCache.
                iterator();
        while (allCacheEntries.hasNext()) {
            Cache.Entry<String, String> currentEntry =
allCacheEntries.next();
            log.info("Key: " + currentEntry.getKey() + " Value: "
                    + currentEntry.getValue());
        }

On Thu, Aug 27, 2015 at 10:04 AM, Romain Manni-Bucau [via TomEE & OpenEJB] <
ml-node+s979440n4675986h77@n4.nabble.com> wrote:

> no default implementation in the API but clearly de default in the
> provider
> you can maybe reuse. Iterating over the cache - for test purpose - is an
> alternative you can use.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 16:07 GMT+02:00 Steve Goldsmith <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=0>>:
>
> > Ah, OK, that wasn't evident from what I've read so far. Is there a
> default
> > implementation or do you have to create one?
> >
> > On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=1>
> > >
> > wrote:
> >
> > > no, @CacheKey doesnt mean your parameter is the key, it means it is
> used
> > in
> > > the key but the key is still a GeneratedCacheKey
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=2>>:
> > >
> > > > I'm just not able to see the cached values by using:
> > > >
> > > >         final Cache<String, String> testCache =
> > > > cacheBean.getCacheManager().
> > > >                 getCache("testCache");
> > > >         log.info(String.format("Cache name: %s",
> > testCache.getName()));
> > > >
> > > > *        // This should display value1, but it doesn't
> log.info
> > > > <http://log.info>(String.format("Value: %s",
> testCache.get("key1")));*
> > > >
> > > > ehcache.xml:
> > > >
> > > > <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > > >          updateCheck="true" monitoring="autodetect"
> > > >          dynamicConfig="true">
> > > >
> > > >     <defaultCache
> > > >         maxEntriesLocalHeap="1000000"
> > > >         eternal="false"
> > > >         timeToIdleSeconds="86400"
> > > >         timeToLiveSeconds="86400"
> > > >         memoryStoreEvictionPolicy="LRU">
> > > >     </defaultCache>
> > > >
> > > >     <cache name="testCache"
> > > >            maxEntriesLocalHeap="1000000"
> > > >            eternal="false"
> > > >            timeToIdleSeconds="600"
> > > >            timeToLiveSeconds="600"
> > > >            memoryStoreEvictionPolicy="LFU">
> > > >     </cache>
> > > >
> > > > </ehcache>
> > > >
> > > >
> > > >
> > > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4675986&i=3>
> > > > >
> > > > wrote:
> > > >
> > > > > looks good, did you encounter any issue or did you ask only for a
> > > review?
> > > > >
> > > > > Note: beans.xml should be empty if already provided by ri jar.
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-08-27 15:41 GMT+02:00 sgjava <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=4>>:
> > > > >
> > > > > > Your examples all have invokers, etc. but none of the other
> example
> > > > I've
> > > > > > seen require this. Since you don't have time to look, maybe you
> can
> > > see
> > > > > if
> > > > > > my structure looks good:
> > > > > >
> > > > > > pom.xml:
> > > > > >
> > > > > >         <dependency>
> > > > > >             <groupId>org.jsr107.ri</groupId>
> > > > > >             <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > > >             <version>1.0.0</version>
> > > > > >         </dependency>
> > > > > >         <dependency>
> > > > > >             <groupId>org.ehcache</groupId>
> > > > > >             <artifactId>jcache</artifactId>
> > > > > >             <version>1.0.1</version>
> > > > > >             <scope>compile</scope>
> > > > > >         </dependency>
> > > > > >
> > > > > > beans.xml:
> > > > > >
> > > > > > <beans>
> > > > > >     <interceptors>
> > > > > >
> > > > >
>  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > > >
> > > > > >
> > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > > >
> > > > > >
> > > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > > >
> > > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > > >     </interceptors>
> > > > > > </beans>
> > > > > >
> > > > > > Cache bean:
> > > > > >
> > > > > > @Singleton
> > > > > > @Startup
> > > > > > @Lock(READ)
> > > > > > public class CacheBean {
> > > > > >
> > > > > >     private static final Logger log = Logger.
> > > > > >             getLogger(CacheBean.class.getName());
> > > > > >
> > > > > >     /**
> > > > > >      * Caching provider.
> > > > > >      */
> > > > > >     private CachingProvider cachingProvider;
> > > > > >     /**
> > > > > >      * Cache manager.
> > > > > >      */
> > > > > >     private CacheManager cacheManager;
> > > > > >
> > > > > >     public CacheManager getCacheManager() {
> > > > > >         return cacheManager;
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Using EHCache provider configured via ehcache.xml in
> > > classpath.
> > > > > >      */
> > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > >     @PostConstruct
> > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > >     public void init() {
> > > > > >         log.info("PostConstruct");
> > > > > >         cachingProvider = Caching.getCachingProvider();
> > > > > >         cacheManager = cachingProvider.getCacheManager();
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Destroy cache.
> > > > > >      */
> > > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > > >     @PreDestroy
> > > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > > >     public void destroy() {
> > > > > >         log.info("PreDestroy");
> > > > > >         cacheManager.close();
> > > > > >         cachingProvider.close();
> > > > > >     }
> > > > > > }
> > > > > >
> > > > > > Bean to test annotations:
> > > > > >
> > > > > > @Stateless
> > > > > > @CacheDefaults(cacheName = "testCache")
> > > > > > public class KeyValueBean {
> > > > > >
> > > > > >     private static final Logger log = Logger.
> > > > > >             getLogger(KeyValueBean.class.getName());
> > > > > >
> > > > > >     @CacheResult
> > > > > >     public String add(@CacheKey String key, String value) {
> > > > > >         log.info(String.format("Adding key: %s, value: %s",
> key,
> > > > > value));
> > > > > >         return value;
> > > > > >     }
> > > > > >
> > > > > >     @CacheRemoveAll
> > > > > >     public void invalidateCache() {
> > > > > >         log.info("Cache invalidated");
> > > > > >     }
> > > > > > }
> > > > > >
> > > > > > Unit test:
> > > > > >
> > > > > > public class CacheBeanTest {
> > > > > >
> > > > > >     /**
> > > > > >      * Logger.
> > > > > >      */
> > > > > >     private static final Logger log =
> > > > > Logger.getLogger(CacheBeanTest.class.
> > > > > >             getName());
> > > > > >     /**
> > > > > >      * Injected cache bean.
> > > > > >      */
> > > > > >     @EJB
> > > > > >     private CacheBean cacheBean;
> > > > > >     /**
> > > > > >      * Our key/value bean.
> > > > > >      */
> > > > > >     @EJB
> > > > > >     private KeyValueBean keyValueBean;
> > > > > >
> > > > > >     /**
> > > > > >      * EJB container.
> > > > > >      */
> > > > > >     private static EJBContainer container;
> > > > > >
> > > > > >     /**
> > > > > >      * Start EJB container.
> > > > > >      */
> > > > > >     @BeforeClass
> > > > > >     public static void setUpClass() {
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Close caching provider/manager and EJB container.
> > > > > >      */
> > > > > >     @AfterClass
> > > > > >     public static void tearDownClass() {
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Set up.
> > > > > >      */
> > > > > >     @Before
> > > > > >     public void setUp() throws NamingException {
> > > > > >         log.info("setUp()");
> > > > > >         container = EJBContainer.createEJBContainer();
> > > > > >         container.getContext().bind("inject", this);
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Tear down.
> > > > > >      */
> > > > > >     @After
> > > > > >     public void tearDown() throws NamingException {
> > > > > >         container.getContext().unbind("inject");
> > > > > >         container.close();
> > > > > >     }
> > > > > >
> > > > > >     /**
> > > > > >      * Test JSR-107 cache using EHCache provider.
> > > > > >      */
> > > > > >     @Test
> > > > > >     public final void testCache() {
> > > > > >         log.info("testCache");
> > > > > >         assertNotNull(cacheBean);
> > > > > >         log.info(String.format("Cache names: %s",
> > > > > > cacheBean.getCacheManager().
> > > > > >                 getCacheNames()));
> > > > > >         keyValueBean.add("key1", "value1");
> > > > > >         final Cache<String, String> testCache =
> > > > > > cacheBean.getCacheManager().
> > > > > >                 getCache("testCache");
> > > > > >         log.info(String.format("Cache name: %s",
> > > > testCache.getName()));
> > > > > >         // This should display value1, but it doesn't
> > > > > >         log.info(String.format("Value: %s",
> > testCache.get("key1")));
> > > > > >         testCache.close();
> > > > > >     }
> > > > > > }
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE &
> > > > > OpenEJB] <
> > > > > > [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675986&i=5>> wrote:
> > > > > >
> > > > > > > dont have time to look now but here a sample i wrote which is
> > green
> > > > > > there:
> > > > > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > > >
> > > > > > >
> > > > > > > Romain Manni-Bucau
> > > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > > https://github.com/rmannibucau> |
> > > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> |
> Tomitriber
> > > > > > > <http://www.tomitribe.com>
> > > > > > >
> > > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > > >
> > > > > > > > I added my JCache attempt in my test project
> > > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > > >
> > > > > > > > I'm not sure the <interceptors> in beans.xml are being
> loaded
> > or
> > > > > that I
> > > > > > > > have
> > > > > > > > the container set up right for the unit test
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > > >
> > > > > > > > I'm using the EHCache provider and it fires up fine and can
> > > > interact
> > > > > > > with
> > > > > > > > it, but CDI doesn't appear to be working. Any help getting
> the
> > > > > working
> > > > > > > in
> > > > > > > > TomEE 7 is appreciated.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > View this message in context:
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > > Sent from the TomEE Users mailing list archive at
> Nabble.com.
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ------------------------------
> > > > > > > If you reply to this email, your message will be added to the
> > > > > discussion
> > > > > > > below:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > > To unsubscribe from JCache CDI, click here
> > > > > > > <
> > > > > >
> > > > >
> > > >
> > >
> >
> > > > > >
> > > > > > > .
> > > > > > > NAML
> > > > > > > <
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven P. Goldsmith
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > View this message in context:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Steven P. Goldsmith
> > > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675986.html
> To unsubscribe from JCache CDI, click here
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5>
> .
> NAML
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Steven P. Goldsmith




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675989.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
no default implementation in the API but clearly de default in the provider
you can maybe reuse. Iterating over the cache - for test purpose - is an
alternative you can use.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-27 16:07 GMT+02:00 Steve Goldsmith <sg...@gmail.com>:

> Ah, OK, that wasn't evident from what I've read so far. Is there a default
> implementation or do you have to create one?
>
> On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > no, @CacheKey doesnt mean your parameter is the key, it means it is used
> in
> > the key but the key is still a GeneratedCacheKey
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <sg...@gmail.com>:
> >
> > > I'm just not able to see the cached values by using:
> > >
> > >         final Cache<String, String> testCache =
> > > cacheBean.getCacheManager().
> > >                 getCache("testCache");
> > >         log.info(String.format("Cache name: %s",
> testCache.getName()));
> > >
> > > *        // This should display value1, but it doesn't        log.info
> > > <http://log.info>(String.format("Value: %s", testCache.get("key1")));*
> > >
> > > ehcache.xml:
> > >
> > > <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> > >          updateCheck="true" monitoring="autodetect"
> > >          dynamicConfig="true">
> > >
> > >     <defaultCache
> > >         maxEntriesLocalHeap="1000000"
> > >         eternal="false"
> > >         timeToIdleSeconds="86400"
> > >         timeToLiveSeconds="86400"
> > >         memoryStoreEvictionPolicy="LRU">
> > >     </defaultCache>
> > >
> > >     <cache name="testCache"
> > >            maxEntriesLocalHeap="1000000"
> > >            eternal="false"
> > >            timeToIdleSeconds="600"
> > >            timeToLiveSeconds="600"
> > >            memoryStoreEvictionPolicy="LFU">
> > >     </cache>
> > >
> > > </ehcache>
> > >
> > >
> > >
> > > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > > >
> > > wrote:
> > >
> > > > looks good, did you encounter any issue or did you ask only for a
> > review?
> > > >
> > > > Note: beans.xml should be empty if already provided by ri jar.
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-27 15:41 GMT+02:00 sgjava <sg...@gmail.com>:
> > > >
> > > > > Your examples all have invokers, etc. but none of the other example
> > > I've
> > > > > seen require this. Since you don't have time to look, maybe you can
> > see
> > > > if
> > > > > my structure looks good:
> > > > >
> > > > > pom.xml:
> > > > >
> > > > >         <dependency>
> > > > >             <groupId>org.jsr107.ri</groupId>
> > > > >             <artifactId>cache-annotations-ri-cdi</artifactId>
> > > > >             <version>1.0.0</version>
> > > > >         </dependency>
> > > > >         <dependency>
> > > > >             <groupId>org.ehcache</groupId>
> > > > >             <artifactId>jcache</artifactId>
> > > > >             <version>1.0.1</version>
> > > > >             <scope>compile</scope>
> > > > >         </dependency>
> > > > >
> > > > > beans.xml:
> > > > >
> > > > > <beans>
> > > > >     <interceptors>
> > > > >
> > > >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > > >
> > > > >
> > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > > >
> > > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > > >
> > >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > > >     </interceptors>
> > > > > </beans>
> > > > >
> > > > > Cache bean:
> > > > >
> > > > > @Singleton
> > > > > @Startup
> > > > > @Lock(READ)
> > > > > public class CacheBean {
> > > > >
> > > > >     private static final Logger log = Logger.
> > > > >             getLogger(CacheBean.class.getName());
> > > > >
> > > > >     /**
> > > > >      * Caching provider.
> > > > >      */
> > > > >     private CachingProvider cachingProvider;
> > > > >     /**
> > > > >      * Cache manager.
> > > > >      */
> > > > >     private CacheManager cacheManager;
> > > > >
> > > > >     public CacheManager getCacheManager() {
> > > > >         return cacheManager;
> > > > >     }
> > > > >
> > > > >     /**
> > > > >      * Using EHCache provider configured via ehcache.xml in
> > classpath.
> > > > >      */
> > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > >     @PostConstruct
> > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > >     public void init() {
> > > > >         log.info("PostConstruct");
> > > > >         cachingProvider = Caching.getCachingProvider();
> > > > >         cacheManager = cachingProvider.getCacheManager();
> > > > >     }
> > > > >
> > > > >     /**
> > > > >      * Destroy cache.
> > > > >      */
> > > > >     //CHECKSTYLE:OFF DesignForExtension
> > > > >     @PreDestroy
> > > > >     //CHECKSTYLE:ON DesignForExtension
> > > > >     public void destroy() {
> > > > >         log.info("PreDestroy");
> > > > >         cacheManager.close();
> > > > >         cachingProvider.close();
> > > > >     }
> > > > > }
> > > > >
> > > > > Bean to test annotations:
> > > > >
> > > > > @Stateless
> > > > > @CacheDefaults(cacheName = "testCache")
> > > > > public class KeyValueBean {
> > > > >
> > > > >     private static final Logger log = Logger.
> > > > >             getLogger(KeyValueBean.class.getName());
> > > > >
> > > > >     @CacheResult
> > > > >     public String add(@CacheKey String key, String value) {
> > > > >         log.info(String.format("Adding key: %s, value: %s", key,
> > > > value));
> > > > >         return value;
> > > > >     }
> > > > >
> > > > >     @CacheRemoveAll
> > > > >     public void invalidateCache() {
> > > > >         log.info("Cache invalidated");
> > > > >     }
> > > > > }
> > > > >
> > > > > Unit test:
> > > > >
> > > > > public class CacheBeanTest {
> > > > >
> > > > >     /**
> > > > >      * Logger.
> > > > >      */
> > > > >     private static final Logger log =
> > > > Logger.getLogger(CacheBeanTest.class.
> > > > >             getName());
> > > > >     /**
> > > > >      * Injected cache bean.
> > > > >      */
> > > > >     @EJB
> > > > >     private CacheBean cacheBean;
> > > > >     /**
> > > > >      * Our key/value bean.
> > > > >      */
> > > > >     @EJB
> > > > >     private KeyValueBean keyValueBean;
> > > > >
> > > > >     /**
> > > > >      * EJB container.
> > > > >      */
> > > > >     private static EJBContainer container;
> > > > >
> > > > >     /**
> > > > >      * Start EJB container.
> > > > >      */
> > > > >     @BeforeClass
> > > > >     public static void setUpClass() {
> > > > >     }
> > > > >
> > > > >     /**
> > > > >      * Close caching provider/manager and EJB container.
> > > > >      */
> > > > >     @AfterClass
> > > > >     public static void tearDownClass() {
> > > > >     }
> > > > >
> > > > >     /**
> > > > >      * Set up.
> > > > >      */
> > > > >     @Before
> > > > >     public void setUp() throws NamingException {
> > > > >         log.info("setUp()");
> > > > >         container = EJBContainer.createEJBContainer();
> > > > >         container.getContext().bind("inject", this);
> > > > >     }
> > > > >
> > > > >     /**
> > > > >      * Tear down.
> > > > >      */
> > > > >     @After
> > > > >     public void tearDown() throws NamingException {
> > > > >         container.getContext().unbind("inject");
> > > > >         container.close();
> > > > >     }
> > > > >
> > > > >     /**
> > > > >      * Test JSR-107 cache using EHCache provider.
> > > > >      */
> > > > >     @Test
> > > > >     public final void testCache() {
> > > > >         log.info("testCache");
> > > > >         assertNotNull(cacheBean);
> > > > >         log.info(String.format("Cache names: %s",
> > > > > cacheBean.getCacheManager().
> > > > >                 getCacheNames()));
> > > > >         keyValueBean.add("key1", "value1");
> > > > >         final Cache<String, String> testCache =
> > > > > cacheBean.getCacheManager().
> > > > >                 getCache("testCache");
> > > > >         log.info(String.format("Cache name: %s",
> > > testCache.getName()));
> > > > >         // This should display value1, but it doesn't
> > > > >         log.info(String.format("Value: %s",
> testCache.get("key1")));
> > > > >         testCache.close();
> > > > >     }
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE &
> > > > OpenEJB] <
> > > > > ml-node+s979440n4675949h30@n4.nabble.com> wrote:
> > > > >
> > > > > > dont have time to look now but here a sample i wrote which is
> green
> > > > > there:
> > > > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > > >
> > > > > >
> > > > > > Romain Manni-Bucau
> > > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > > https://github.com/rmannibucau> |
> > > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > > <http://www.tomitribe.com>
> > > > > >
> > > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > > >
> > > > > > > I added my JCache attempt in my test project
> > > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > > >
> > > > > > > I'm not sure the <interceptors> in beans.xml are being loaded
> or
> > > > that I
> > > > > > > have
> > > > > > > the container set up right for the unit test
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > > >
> > > > > > > I'm using the EHCache provider and it fires up fine and can
> > > interact
> > > > > > with
> > > > > > > it, but CDI doesn't appear to be working. Any help getting the
> > > > working
> > > > > > in
> > > > > > > TomEE 7 is appreciated.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > View this message in context:
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > > >
> > > > > >
> > > > > >
> > > > > > ------------------------------
> > > > > > If you reply to this email, your message will be added to the
> > > > discussion
> > > > > > below:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > > To unsubscribe from JCache CDI, click here
> > > > > > <
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> > > > > >
> > > > > > .
> > > > > > NAML
> > > > > > <
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven P. Goldsmith
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > View this message in context:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> >
>
>
>
> --
> Steven P. Goldsmith
>

Re: JCache CDI

Posted by Steve Goldsmith <sg...@gmail.com>.
Ah, OK, that wasn't evident from what I've read so far. Is there a default
implementation or do you have to create one?

On Thu, Aug 27, 2015 at 9:58 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> no, @CacheKey doesnt mean your parameter is the key, it means it is used in
> the key but the key is still a GeneratedCacheKey
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 15:56 GMT+02:00 Steve Goldsmith <sg...@gmail.com>:
>
> > I'm just not able to see the cached values by using:
> >
> >         final Cache<String, String> testCache =
> > cacheBean.getCacheManager().
> >                 getCache("testCache");
> >         log.info(String.format("Cache name: %s", testCache.getName()));
> >
> > *        // This should display value1, but it doesn't        log.info
> > <http://log.info>(String.format("Value: %s", testCache.get("key1")));*
> >
> > ehcache.xml:
> >
> > <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >          xsi:noNamespaceSchemaLocation="ehcache.xsd"
> >          updateCheck="true" monitoring="autodetect"
> >          dynamicConfig="true">
> >
> >     <defaultCache
> >         maxEntriesLocalHeap="1000000"
> >         eternal="false"
> >         timeToIdleSeconds="86400"
> >         timeToLiveSeconds="86400"
> >         memoryStoreEvictionPolicy="LRU">
> >     </defaultCache>
> >
> >     <cache name="testCache"
> >            maxEntriesLocalHeap="1000000"
> >            eternal="false"
> >            timeToIdleSeconds="600"
> >            timeToLiveSeconds="600"
> >            memoryStoreEvictionPolicy="LFU">
> >     </cache>
> >
> > </ehcache>
> >
> >
> >
> > On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >
> > wrote:
> >
> > > looks good, did you encounter any issue or did you ask only for a
> review?
> > >
> > > Note: beans.xml should be empty if already provided by ri jar.
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-27 15:41 GMT+02:00 sgjava <sg...@gmail.com>:
> > >
> > > > Your examples all have invokers, etc. but none of the other example
> > I've
> > > > seen require this. Since you don't have time to look, maybe you can
> see
> > > if
> > > > my structure looks good:
> > > >
> > > > pom.xml:
> > > >
> > > >         <dependency>
> > > >             <groupId>org.jsr107.ri</groupId>
> > > >             <artifactId>cache-annotations-ri-cdi</artifactId>
> > > >             <version>1.0.0</version>
> > > >         </dependency>
> > > >         <dependency>
> > > >             <groupId>org.ehcache</groupId>
> > > >             <artifactId>jcache</artifactId>
> > > >             <version>1.0.1</version>
> > > >             <scope>compile</scope>
> > > >         </dependency>
> > > >
> > > > beans.xml:
> > > >
> > > > <beans>
> > > >     <interceptors>
> > > >
> > >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > > >
> > > >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > > >
> > > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > > >
> >  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > > >     </interceptors>
> > > > </beans>
> > > >
> > > > Cache bean:
> > > >
> > > > @Singleton
> > > > @Startup
> > > > @Lock(READ)
> > > > public class CacheBean {
> > > >
> > > >     private static final Logger log = Logger.
> > > >             getLogger(CacheBean.class.getName());
> > > >
> > > >     /**
> > > >      * Caching provider.
> > > >      */
> > > >     private CachingProvider cachingProvider;
> > > >     /**
> > > >      * Cache manager.
> > > >      */
> > > >     private CacheManager cacheManager;
> > > >
> > > >     public CacheManager getCacheManager() {
> > > >         return cacheManager;
> > > >     }
> > > >
> > > >     /**
> > > >      * Using EHCache provider configured via ehcache.xml in
> classpath.
> > > >      */
> > > >     //CHECKSTYLE:OFF DesignForExtension
> > > >     @PostConstruct
> > > >     //CHECKSTYLE:ON DesignForExtension
> > > >     public void init() {
> > > >         log.info("PostConstruct");
> > > >         cachingProvider = Caching.getCachingProvider();
> > > >         cacheManager = cachingProvider.getCacheManager();
> > > >     }
> > > >
> > > >     /**
> > > >      * Destroy cache.
> > > >      */
> > > >     //CHECKSTYLE:OFF DesignForExtension
> > > >     @PreDestroy
> > > >     //CHECKSTYLE:ON DesignForExtension
> > > >     public void destroy() {
> > > >         log.info("PreDestroy");
> > > >         cacheManager.close();
> > > >         cachingProvider.close();
> > > >     }
> > > > }
> > > >
> > > > Bean to test annotations:
> > > >
> > > > @Stateless
> > > > @CacheDefaults(cacheName = "testCache")
> > > > public class KeyValueBean {
> > > >
> > > >     private static final Logger log = Logger.
> > > >             getLogger(KeyValueBean.class.getName());
> > > >
> > > >     @CacheResult
> > > >     public String add(@CacheKey String key, String value) {
> > > >         log.info(String.format("Adding key: %s, value: %s", key,
> > > value));
> > > >         return value;
> > > >     }
> > > >
> > > >     @CacheRemoveAll
> > > >     public void invalidateCache() {
> > > >         log.info("Cache invalidated");
> > > >     }
> > > > }
> > > >
> > > > Unit test:
> > > >
> > > > public class CacheBeanTest {
> > > >
> > > >     /**
> > > >      * Logger.
> > > >      */
> > > >     private static final Logger log =
> > > Logger.getLogger(CacheBeanTest.class.
> > > >             getName());
> > > >     /**
> > > >      * Injected cache bean.
> > > >      */
> > > >     @EJB
> > > >     private CacheBean cacheBean;
> > > >     /**
> > > >      * Our key/value bean.
> > > >      */
> > > >     @EJB
> > > >     private KeyValueBean keyValueBean;
> > > >
> > > >     /**
> > > >      * EJB container.
> > > >      */
> > > >     private static EJBContainer container;
> > > >
> > > >     /**
> > > >      * Start EJB container.
> > > >      */
> > > >     @BeforeClass
> > > >     public static void setUpClass() {
> > > >     }
> > > >
> > > >     /**
> > > >      * Close caching provider/manager and EJB container.
> > > >      */
> > > >     @AfterClass
> > > >     public static void tearDownClass() {
> > > >     }
> > > >
> > > >     /**
> > > >      * Set up.
> > > >      */
> > > >     @Before
> > > >     public void setUp() throws NamingException {
> > > >         log.info("setUp()");
> > > >         container = EJBContainer.createEJBContainer();
> > > >         container.getContext().bind("inject", this);
> > > >     }
> > > >
> > > >     /**
> > > >      * Tear down.
> > > >      */
> > > >     @After
> > > >     public void tearDown() throws NamingException {
> > > >         container.getContext().unbind("inject");
> > > >         container.close();
> > > >     }
> > > >
> > > >     /**
> > > >      * Test JSR-107 cache using EHCache provider.
> > > >      */
> > > >     @Test
> > > >     public final void testCache() {
> > > >         log.info("testCache");
> > > >         assertNotNull(cacheBean);
> > > >         log.info(String.format("Cache names: %s",
> > > > cacheBean.getCacheManager().
> > > >                 getCacheNames()));
> > > >         keyValueBean.add("key1", "value1");
> > > >         final Cache<String, String> testCache =
> > > > cacheBean.getCacheManager().
> > > >                 getCache("testCache");
> > > >         log.info(String.format("Cache name: %s",
> > testCache.getName()));
> > > >         // This should display value1, but it doesn't
> > > >         log.info(String.format("Value: %s", testCache.get("key1")));
> > > >         testCache.close();
> > > >     }
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE &
> > > OpenEJB] <
> > > > ml-node+s979440n4675949h30@n4.nabble.com> wrote:
> > > >
> > > > > dont have time to look now but here a sample i wrote which is green
> > > > there:
> > > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com>
> > > > >
> > > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > > >
> > > > > > I added my JCache attempt in my test project
> > > > > > https://github.com/sgjava/my-jaxrs-test
> > > > > >
> > > > > > I'm not sure the <interceptors> in beans.xml are being loaded or
> > > that I
> > > > > > have
> > > > > > the container set up right for the unit test
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > > >
> > > > > > I'm using the EHCache provider and it fires up fine and can
> > interact
> > > > > with
> > > > > > it, but CDI doesn't appear to be working. Any help getting the
> > > working
> > > > > in
> > > > > > TomEE 7 is appreciated.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > View this message in context:
> > > > > >
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > > >
> > > > >
> > > > >
> > > > > ------------------------------
> > > > > If you reply to this email, your message will be added to the
> > > discussion
> > > > > below:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > > To unsubscribe from JCache CDI, click here
> > > > > <
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> > > > >
> > > > > .
> > > > > NAML
> > > > > <
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Steven P. Goldsmith
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
>



-- 
Steven P. Goldsmith

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
no, @CacheKey doesnt mean your parameter is the key, it means it is used in
the key but the key is still a GeneratedCacheKey


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-27 15:56 GMT+02:00 Steve Goldsmith <sg...@gmail.com>:

> I'm just not able to see the cached values by using:
>
>         final Cache<String, String> testCache =
> cacheBean.getCacheManager().
>                 getCache("testCache");
>         log.info(String.format("Cache name: %s", testCache.getName()));
>
> *        // This should display value1, but it doesn't        log.info
> <http://log.info>(String.format("Value: %s", testCache.get("key1")));*
>
> ehcache.xml:
>
> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:noNamespaceSchemaLocation="ehcache.xsd"
>          updateCheck="true" monitoring="autodetect"
>          dynamicConfig="true">
>
>     <defaultCache
>         maxEntriesLocalHeap="1000000"
>         eternal="false"
>         timeToIdleSeconds="86400"
>         timeToLiveSeconds="86400"
>         memoryStoreEvictionPolicy="LRU">
>     </defaultCache>
>
>     <cache name="testCache"
>            maxEntriesLocalHeap="1000000"
>            eternal="false"
>            timeToIdleSeconds="600"
>            timeToLiveSeconds="600"
>            memoryStoreEvictionPolicy="LFU">
>     </cache>
>
> </ehcache>
>
>
>
> On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > looks good, did you encounter any issue or did you ask only for a review?
> >
> > Note: beans.xml should be empty if already provided by ri jar.
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-27 15:41 GMT+02:00 sgjava <sg...@gmail.com>:
> >
> > > Your examples all have invokers, etc. but none of the other example
> I've
> > > seen require this. Since you don't have time to look, maybe you can see
> > if
> > > my structure looks good:
> > >
> > > pom.xml:
> > >
> > >         <dependency>
> > >             <groupId>org.jsr107.ri</groupId>
> > >             <artifactId>cache-annotations-ri-cdi</artifactId>
> > >             <version>1.0.0</version>
> > >         </dependency>
> > >         <dependency>
> > >             <groupId>org.ehcache</groupId>
> > >             <artifactId>jcache</artifactId>
> > >             <version>1.0.1</version>
> > >             <scope>compile</scope>
> > >         </dependency>
> > >
> > > beans.xml:
> > >
> > > <beans>
> > >     <interceptors>
> > >
> >  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> > >
> > >
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> > >
> > > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> > >
>  <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> > >     </interceptors>
> > > </beans>
> > >
> > > Cache bean:
> > >
> > > @Singleton
> > > @Startup
> > > @Lock(READ)
> > > public class CacheBean {
> > >
> > >     private static final Logger log = Logger.
> > >             getLogger(CacheBean.class.getName());
> > >
> > >     /**
> > >      * Caching provider.
> > >      */
> > >     private CachingProvider cachingProvider;
> > >     /**
> > >      * Cache manager.
> > >      */
> > >     private CacheManager cacheManager;
> > >
> > >     public CacheManager getCacheManager() {
> > >         return cacheManager;
> > >     }
> > >
> > >     /**
> > >      * Using EHCache provider configured via ehcache.xml in classpath.
> > >      */
> > >     //CHECKSTYLE:OFF DesignForExtension
> > >     @PostConstruct
> > >     //CHECKSTYLE:ON DesignForExtension
> > >     public void init() {
> > >         log.info("PostConstruct");
> > >         cachingProvider = Caching.getCachingProvider();
> > >         cacheManager = cachingProvider.getCacheManager();
> > >     }
> > >
> > >     /**
> > >      * Destroy cache.
> > >      */
> > >     //CHECKSTYLE:OFF DesignForExtension
> > >     @PreDestroy
> > >     //CHECKSTYLE:ON DesignForExtension
> > >     public void destroy() {
> > >         log.info("PreDestroy");
> > >         cacheManager.close();
> > >         cachingProvider.close();
> > >     }
> > > }
> > >
> > > Bean to test annotations:
> > >
> > > @Stateless
> > > @CacheDefaults(cacheName = "testCache")
> > > public class KeyValueBean {
> > >
> > >     private static final Logger log = Logger.
> > >             getLogger(KeyValueBean.class.getName());
> > >
> > >     @CacheResult
> > >     public String add(@CacheKey String key, String value) {
> > >         log.info(String.format("Adding key: %s, value: %s", key,
> > value));
> > >         return value;
> > >     }
> > >
> > >     @CacheRemoveAll
> > >     public void invalidateCache() {
> > >         log.info("Cache invalidated");
> > >     }
> > > }
> > >
> > > Unit test:
> > >
> > > public class CacheBeanTest {
> > >
> > >     /**
> > >      * Logger.
> > >      */
> > >     private static final Logger log =
> > Logger.getLogger(CacheBeanTest.class.
> > >             getName());
> > >     /**
> > >      * Injected cache bean.
> > >      */
> > >     @EJB
> > >     private CacheBean cacheBean;
> > >     /**
> > >      * Our key/value bean.
> > >      */
> > >     @EJB
> > >     private KeyValueBean keyValueBean;
> > >
> > >     /**
> > >      * EJB container.
> > >      */
> > >     private static EJBContainer container;
> > >
> > >     /**
> > >      * Start EJB container.
> > >      */
> > >     @BeforeClass
> > >     public static void setUpClass() {
> > >     }
> > >
> > >     /**
> > >      * Close caching provider/manager and EJB container.
> > >      */
> > >     @AfterClass
> > >     public static void tearDownClass() {
> > >     }
> > >
> > >     /**
> > >      * Set up.
> > >      */
> > >     @Before
> > >     public void setUp() throws NamingException {
> > >         log.info("setUp()");
> > >         container = EJBContainer.createEJBContainer();
> > >         container.getContext().bind("inject", this);
> > >     }
> > >
> > >     /**
> > >      * Tear down.
> > >      */
> > >     @After
> > >     public void tearDown() throws NamingException {
> > >         container.getContext().unbind("inject");
> > >         container.close();
> > >     }
> > >
> > >     /**
> > >      * Test JSR-107 cache using EHCache provider.
> > >      */
> > >     @Test
> > >     public final void testCache() {
> > >         log.info("testCache");
> > >         assertNotNull(cacheBean);
> > >         log.info(String.format("Cache names: %s",
> > > cacheBean.getCacheManager().
> > >                 getCacheNames()));
> > >         keyValueBean.add("key1", "value1");
> > >         final Cache<String, String> testCache =
> > > cacheBean.getCacheManager().
> > >                 getCache("testCache");
> > >         log.info(String.format("Cache name: %s",
> testCache.getName()));
> > >         // This should display value1, but it doesn't
> > >         log.info(String.format("Value: %s", testCache.get("key1")));
> > >         testCache.close();
> > >     }
> > > }
> > >
> > >
> > >
> > >
> > >
> > > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE &
> > OpenEJB] <
> > > ml-node+s979440n4675949h30@n4.nabble.com> wrote:
> > >
> > > > dont have time to look now but here a sample i wrote which is green
> > > there:
> > > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > > >
> > > > > I added my JCache attempt in my test project
> > > > > https://github.com/sgjava/my-jaxrs-test
> > > > >
> > > > > I'm not sure the <interceptors> in beans.xml are being loaded or
> > that I
> > > > > have
> > > > > the container set up right for the unit test
> > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > > >
> > > > > I'm using the EHCache provider and it fires up fine and can
> interact
> > > > with
> > > > > it, but CDI doesn't appear to be working. Any help getting the
> > working
> > > > in
> > > > > TomEE 7 is appreciated.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > View this message in context:
> > > > >
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > >
> > > >
> > > >
> > > > ------------------------------
> > > > If you reply to this email, your message will be added to the
> > discussion
> > > > below:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > > To unsubscribe from JCache CDI, click here
> > > > <
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> > > >
> > > > .
> > > > NAML
> > > > <
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > >
> >
>
>
>
> --
> Steven P. Goldsmith
>

Re: JCache CDI

Posted by Steve Goldsmith <sg...@gmail.com>.
I'm just not able to see the cached values by using:

        final Cache<String, String> testCache = cacheBean.getCacheManager().
                getCache("testCache");
        log.info(String.format("Cache name: %s", testCache.getName()));

*        // This should display value1, but it doesn't        log.info
<http://log.info>(String.format("Value: %s", testCache.get("key1")));*

ehcache.xml:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ehcache.xsd"
         updateCheck="true" monitoring="autodetect"
         dynamicConfig="true">

    <defaultCache
        maxEntriesLocalHeap="1000000"
        eternal="false"
        timeToIdleSeconds="86400"
        timeToLiveSeconds="86400"
        memoryStoreEvictionPolicy="LRU">
    </defaultCache>

    <cache name="testCache"
           maxEntriesLocalHeap="1000000"
           eternal="false"
           timeToIdleSeconds="600"
           timeToLiveSeconds="600"
           memoryStoreEvictionPolicy="LFU">
    </cache>

</ehcache>



On Thu, Aug 27, 2015 at 9:49 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> looks good, did you encounter any issue or did you ask only for a review?
>
> Note: beans.xml should be empty if already provided by ri jar.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-27 15:41 GMT+02:00 sgjava <sg...@gmail.com>:
>
> > Your examples all have invokers, etc. but none of the other example I've
> > seen require this. Since you don't have time to look, maybe you can see
> if
> > my structure looks good:
> >
> > pom.xml:
> >
> >         <dependency>
> >             <groupId>org.jsr107.ri</groupId>
> >             <artifactId>cache-annotations-ri-cdi</artifactId>
> >             <version>1.0.0</version>
> >         </dependency>
> >         <dependency>
> >             <groupId>org.ehcache</groupId>
> >             <artifactId>jcache</artifactId>
> >             <version>1.0.1</version>
> >             <scope>compile</scope>
> >         </dependency>
> >
> > beans.xml:
> >
> > <beans>
> >     <interceptors>
> >
>  <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
> >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
> >
> > <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
> >         <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
> >     </interceptors>
> > </beans>
> >
> > Cache bean:
> >
> > @Singleton
> > @Startup
> > @Lock(READ)
> > public class CacheBean {
> >
> >     private static final Logger log = Logger.
> >             getLogger(CacheBean.class.getName());
> >
> >     /**
> >      * Caching provider.
> >      */
> >     private CachingProvider cachingProvider;
> >     /**
> >      * Cache manager.
> >      */
> >     private CacheManager cacheManager;
> >
> >     public CacheManager getCacheManager() {
> >         return cacheManager;
> >     }
> >
> >     /**
> >      * Using EHCache provider configured via ehcache.xml in classpath.
> >      */
> >     //CHECKSTYLE:OFF DesignForExtension
> >     @PostConstruct
> >     //CHECKSTYLE:ON DesignForExtension
> >     public void init() {
> >         log.info("PostConstruct");
> >         cachingProvider = Caching.getCachingProvider();
> >         cacheManager = cachingProvider.getCacheManager();
> >     }
> >
> >     /**
> >      * Destroy cache.
> >      */
> >     //CHECKSTYLE:OFF DesignForExtension
> >     @PreDestroy
> >     //CHECKSTYLE:ON DesignForExtension
> >     public void destroy() {
> >         log.info("PreDestroy");
> >         cacheManager.close();
> >         cachingProvider.close();
> >     }
> > }
> >
> > Bean to test annotations:
> >
> > @Stateless
> > @CacheDefaults(cacheName = "testCache")
> > public class KeyValueBean {
> >
> >     private static final Logger log = Logger.
> >             getLogger(KeyValueBean.class.getName());
> >
> >     @CacheResult
> >     public String add(@CacheKey String key, String value) {
> >         log.info(String.format("Adding key: %s, value: %s", key,
> value));
> >         return value;
> >     }
> >
> >     @CacheRemoveAll
> >     public void invalidateCache() {
> >         log.info("Cache invalidated");
> >     }
> > }
> >
> > Unit test:
> >
> > public class CacheBeanTest {
> >
> >     /**
> >      * Logger.
> >      */
> >     private static final Logger log =
> Logger.getLogger(CacheBeanTest.class.
> >             getName());
> >     /**
> >      * Injected cache bean.
> >      */
> >     @EJB
> >     private CacheBean cacheBean;
> >     /**
> >      * Our key/value bean.
> >      */
> >     @EJB
> >     private KeyValueBean keyValueBean;
> >
> >     /**
> >      * EJB container.
> >      */
> >     private static EJBContainer container;
> >
> >     /**
> >      * Start EJB container.
> >      */
> >     @BeforeClass
> >     public static void setUpClass() {
> >     }
> >
> >     /**
> >      * Close caching provider/manager and EJB container.
> >      */
> >     @AfterClass
> >     public static void tearDownClass() {
> >     }
> >
> >     /**
> >      * Set up.
> >      */
> >     @Before
> >     public void setUp() throws NamingException {
> >         log.info("setUp()");
> >         container = EJBContainer.createEJBContainer();
> >         container.getContext().bind("inject", this);
> >     }
> >
> >     /**
> >      * Tear down.
> >      */
> >     @After
> >     public void tearDown() throws NamingException {
> >         container.getContext().unbind("inject");
> >         container.close();
> >     }
> >
> >     /**
> >      * Test JSR-107 cache using EHCache provider.
> >      */
> >     @Test
> >     public final void testCache() {
> >         log.info("testCache");
> >         assertNotNull(cacheBean);
> >         log.info(String.format("Cache names: %s",
> > cacheBean.getCacheManager().
> >                 getCacheNames()));
> >         keyValueBean.add("key1", "value1");
> >         final Cache<String, String> testCache =
> > cacheBean.getCacheManager().
> >                 getCache("testCache");
> >         log.info(String.format("Cache name: %s", testCache.getName()));
> >         // This should display value1, but it doesn't
> >         log.info(String.format("Value: %s", testCache.get("key1")));
> >         testCache.close();
> >     }
> > }
> >
> >
> >
> >
> >
> > On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE &
> OpenEJB] <
> > ml-node+s979440n4675949h30@n4.nabble.com> wrote:
> >
> > > dont have time to look now but here a sample i wrote which is green
> > there:
> > > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> > >
> > > > I added my JCache attempt in my test project
> > > > https://github.com/sgjava/my-jaxrs-test
> > > >
> > > > I'm not sure the <interceptors> in beans.xml are being loaded or
> that I
> > > > have
> > > > the container set up right for the unit test
> > > >
> > > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > > >
> > > > I'm using the EHCache provider and it fires up fine and can interact
> > > with
> > > > it, but CDI doesn't appear to be working. Any help getting the
> working
> > > in
> > > > TomEE 7 is appreciated.
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > >
> > >
> > >
> > > ------------------------------
> > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > > To unsubscribe from JCache CDI, click here
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> > >
> > > .
> > > NAML
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>



-- 
Steven P. Goldsmith

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
looks good, did you encounter any issue or did you ask only for a review?

Note: beans.xml should be empty if already provided by ri jar.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-27 15:41 GMT+02:00 sgjava <sg...@gmail.com>:

> Your examples all have invokers, etc. but none of the other example I've
> seen require this. Since you don't have time to look, maybe you can see if
> my structure looks good:
>
> pom.xml:
>
>         <dependency>
>             <groupId>org.jsr107.ri</groupId>
>             <artifactId>cache-annotations-ri-cdi</artifactId>
>             <version>1.0.0</version>
>         </dependency>
>         <dependency>
>             <groupId>org.ehcache</groupId>
>             <artifactId>jcache</artifactId>
>             <version>1.0.1</version>
>             <scope>compile</scope>
>         </dependency>
>
> beans.xml:
>
> <beans>
>     <interceptors>
>         <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
>
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
>
> <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
>         <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
>     </interceptors>
> </beans>
>
> Cache bean:
>
> @Singleton
> @Startup
> @Lock(READ)
> public class CacheBean {
>
>     private static final Logger log = Logger.
>             getLogger(CacheBean.class.getName());
>
>     /**
>      * Caching provider.
>      */
>     private CachingProvider cachingProvider;
>     /**
>      * Cache manager.
>      */
>     private CacheManager cacheManager;
>
>     public CacheManager getCacheManager() {
>         return cacheManager;
>     }
>
>     /**
>      * Using EHCache provider configured via ehcache.xml in classpath.
>      */
>     //CHECKSTYLE:OFF DesignForExtension
>     @PostConstruct
>     //CHECKSTYLE:ON DesignForExtension
>     public void init() {
>         log.info("PostConstruct");
>         cachingProvider = Caching.getCachingProvider();
>         cacheManager = cachingProvider.getCacheManager();
>     }
>
>     /**
>      * Destroy cache.
>      */
>     //CHECKSTYLE:OFF DesignForExtension
>     @PreDestroy
>     //CHECKSTYLE:ON DesignForExtension
>     public void destroy() {
>         log.info("PreDestroy");
>         cacheManager.close();
>         cachingProvider.close();
>     }
> }
>
> Bean to test annotations:
>
> @Stateless
> @CacheDefaults(cacheName = "testCache")
> public class KeyValueBean {
>
>     private static final Logger log = Logger.
>             getLogger(KeyValueBean.class.getName());
>
>     @CacheResult
>     public String add(@CacheKey String key, String value) {
>         log.info(String.format("Adding key: %s, value: %s", key, value));
>         return value;
>     }
>
>     @CacheRemoveAll
>     public void invalidateCache() {
>         log.info("Cache invalidated");
>     }
> }
>
> Unit test:
>
> public class CacheBeanTest {
>
>     /**
>      * Logger.
>      */
>     private static final Logger log = Logger.getLogger(CacheBeanTest.class.
>             getName());
>     /**
>      * Injected cache bean.
>      */
>     @EJB
>     private CacheBean cacheBean;
>     /**
>      * Our key/value bean.
>      */
>     @EJB
>     private KeyValueBean keyValueBean;
>
>     /**
>      * EJB container.
>      */
>     private static EJBContainer container;
>
>     /**
>      * Start EJB container.
>      */
>     @BeforeClass
>     public static void setUpClass() {
>     }
>
>     /**
>      * Close caching provider/manager and EJB container.
>      */
>     @AfterClass
>     public static void tearDownClass() {
>     }
>
>     /**
>      * Set up.
>      */
>     @Before
>     public void setUp() throws NamingException {
>         log.info("setUp()");
>         container = EJBContainer.createEJBContainer();
>         container.getContext().bind("inject", this);
>     }
>
>     /**
>      * Tear down.
>      */
>     @After
>     public void tearDown() throws NamingException {
>         container.getContext().unbind("inject");
>         container.close();
>     }
>
>     /**
>      * Test JSR-107 cache using EHCache provider.
>      */
>     @Test
>     public final void testCache() {
>         log.info("testCache");
>         assertNotNull(cacheBean);
>         log.info(String.format("Cache names: %s",
> cacheBean.getCacheManager().
>                 getCacheNames()));
>         keyValueBean.add("key1", "value1");
>         final Cache<String, String> testCache =
> cacheBean.getCacheManager().
>                 getCache("testCache");
>         log.info(String.format("Cache name: %s", testCache.getName()));
>         // This should display value1, but it doesn't
>         log.info(String.format("Value: %s", testCache.get("key1")));
>         testCache.close();
>     }
> }
>
>
>
>
>
> On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE & OpenEJB] <
> ml-node+s979440n4675949h30@n4.nabble.com> wrote:
>
> > dont have time to look now but here a sample i wrote which is green
> there:
> > https://gist.github.com/rmannibucau/323f3de99309f856fe81
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
> >
> > > I added my JCache attempt in my test project
> > > https://github.com/sgjava/my-jaxrs-test
> > >
> > > I'm not sure the <interceptors> in beans.xml are being loaded or that I
> > > have
> > > the container set up right for the unit test
> > >
> > >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> > >
> > > I'm using the EHCache provider and it fires up fine and can interact
> > with
> > > it, but CDI doesn't appear to be working. Any help getting the working
> > in
> > > TomEE 7 is appreciated.
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> > To unsubscribe from JCache CDI, click here
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5
> >
> > .
> > NAML
> > <
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
> --
> Steven P. Goldsmith
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: JCache CDI

Posted by sgjava <sg...@gmail.com>.
Your examples all have invokers, etc. but none of the other example I've
seen require this. Since you don't have time to look, maybe you can see if
my structure looks good:

pom.xml:

        <dependency>
            <groupId>org.jsr107.ri</groupId>
            <artifactId>cache-annotations-ri-cdi</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.ehcache</groupId>
            <artifactId>jcache</artifactId>
            <version>1.0.1</version>
            <scope>compile</scope>
        </dependency>

beans.xml:

<beans>
    <interceptors>
        <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>

<class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>

<class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
        <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
    </interceptors>
</beans>

Cache bean:

@Singleton
@Startup
@Lock(READ)
public class CacheBean {

    private static final Logger log = Logger.
            getLogger(CacheBean.class.getName());

    /**
     * Caching provider.
     */
    private CachingProvider cachingProvider;
    /**
     * Cache manager.
     */
    private CacheManager cacheManager;

    public CacheManager getCacheManager() {
        return cacheManager;
    }

    /**
     * Using EHCache provider configured via ehcache.xml in classpath.
     */
    //CHECKSTYLE:OFF DesignForExtension
    @PostConstruct
    //CHECKSTYLE:ON DesignForExtension
    public void init() {
        log.info("PostConstruct");
        cachingProvider = Caching.getCachingProvider();
        cacheManager = cachingProvider.getCacheManager();
    }

    /**
     * Destroy cache.
     */
    //CHECKSTYLE:OFF DesignForExtension
    @PreDestroy
    //CHECKSTYLE:ON DesignForExtension
    public void destroy() {
        log.info("PreDestroy");
        cacheManager.close();
        cachingProvider.close();
    }
}

Bean to test annotations:

@Stateless
@CacheDefaults(cacheName = "testCache")
public class KeyValueBean {

    private static final Logger log = Logger.
            getLogger(KeyValueBean.class.getName());

    @CacheResult
    public String add(@CacheKey String key, String value) {
        log.info(String.format("Adding key: %s, value: %s", key, value));
        return value;
    }

    @CacheRemoveAll
    public void invalidateCache() {
        log.info("Cache invalidated");
    }
}

Unit test:

public class CacheBeanTest {

    /**
     * Logger.
     */
    private static final Logger log = Logger.getLogger(CacheBeanTest.class.
            getName());
    /**
     * Injected cache bean.
     */
    @EJB
    private CacheBean cacheBean;
    /**
     * Our key/value bean.
     */
    @EJB
    private KeyValueBean keyValueBean;

    /**
     * EJB container.
     */
    private static EJBContainer container;

    /**
     * Start EJB container.
     */
    @BeforeClass
    public static void setUpClass() {
    }

    /**
     * Close caching provider/manager and EJB container.
     */
    @AfterClass
    public static void tearDownClass() {
    }

    /**
     * Set up.
     */
    @Before
    public void setUp() throws NamingException {
        log.info("setUp()");
        container = EJBContainer.createEJBContainer();
        container.getContext().bind("inject", this);
    }

    /**
     * Tear down.
     */
    @After
    public void tearDown() throws NamingException {
        container.getContext().unbind("inject");
        container.close();
    }

    /**
     * Test JSR-107 cache using EHCache provider.
     */
    @Test
    public final void testCache() {
        log.info("testCache");
        assertNotNull(cacheBean);
        log.info(String.format("Cache names: %s",
cacheBean.getCacheManager().
                getCacheNames()));
        keyValueBean.add("key1", "value1");
        final Cache<String, String> testCache = cacheBean.getCacheManager().
                getCache("testCache");
        log.info(String.format("Cache name: %s", testCache.getName()));
        // This should display value1, but it doesn't
        log.info(String.format("Value: %s", testCache.get("key1")));
        testCache.close();
    }
}





On Thu, Aug 20, 2015 at 8:47 PM, Romain Manni-Bucau [via TomEE & OpenEJB] <
ml-node+s979440n4675949h30@n4.nabble.com> wrote:

> dont have time to look now but here a sample i wrote which is green there:
> https://gist.github.com/rmannibucau/323f3de99309f856fe81
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-20 17:43 GMT-07:00 sgjava <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4675949&i=0>>:
>
> > I added my JCache attempt in my test project
> > https://github.com/sgjava/my-jaxrs-test
> >
> > I'm not sure the <interceptors> in beans.xml are being loaded or that I
> > have
> > the container set up right for the unit test
> >
> >
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
> >
> > I'm using the EHCache provider and it fires up fine and can interact
> with
> > it, but CDI doesn't appear to be working. Any help getting the working
> in
> > TomEE 7 is appreciated.
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675949.html
> To unsubscribe from JCache CDI, click here
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4675943&code=c2dqYXZhQGdtYWlsLmNvbXw0Njc1OTQzfC0xNzc0MzgwNjE5>
> .
> NAML
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Steven P. Goldsmith




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675981.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
dont have time to look now but here a sample i wrote which is green there:
https://gist.github.com/rmannibucau/323f3de99309f856fe81


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-20 17:43 GMT-07:00 sgjava <sg...@gmail.com>:

> I added my JCache attempt in my test project
> https://github.com/sgjava/my-jaxrs-test
>
> I'm not sure the <interceptors> in beans.xml are being loaded or that I
> have
> the container set up right for the unit test
>
> https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java
>
> I'm using the EHCache provider and it fires up fine and can interact with
> it, but CDI doesn't appear to be working. Any help getting the working in
> TomEE 7 is appreciated.
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

RE: JCache CDI

Posted by sgjava <sg...@gmail.com>.
I added my JCache attempt in my test project
https://github.com/sgjava/my-jaxrs-test

I'm not sure the <interceptors> in beans.xml are being loaded or that I have
the container set up right for the unit test
https://github.com/sgjava/my-jaxrs-test/blob/master/src/test/java/com/codeferm/services/jaxrs/CacheBeanTest.java

I'm using the EHCache provider and it fires up fine and can interact with
it, but CDI doesn't appear to be working. Any help getting the working in
TomEE 7 is appreciated. 




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-CDI-tp4675943p4675948.html
Sent from the TomEE Users mailing list archive at Nabble.com.

RE: JCache CDI

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Cdi part of jcache is pretty stable in term of impl AFAIK.
Le 20 août 2015 07:45, "Alten, Jessica-Aileen" <
Jessica-Aileen.Alten@liag-hannover.de> a écrit :

> > I also looked at http://www.knitelius.com/2015/06/29/using-jcache-in-
> > jee-67
> > which I was unable to get the annotations working or at least see the
> > values in the cache using cache.get after a @CacheResult. I can get
> > JCache working fine without the annotations, but CDI is the route I
> > want to go. So my question is do I wait for things to stabilize
> > (remember this is for
> > production) or is there a JCache CDI solution that works now that I can
> > feel confident that when included in Java EE 8 I will not have to
> > change any code. I'm in production with TomEE 2.0.0 and 7.0.0 and they
> > are very stable.
>
> Perhaps you can give Infinispan a try? There is a nice and small example at
> https://github.com/infinispan/infinispan-quickstart/tree/master/cdi
>
> The cheap trick (perhaps not only for Infinispan?) is to inject the
> annotated object via CDI.
>
> Something I didn't mastered until now is the @Observes CDI annotation for
> cache events in Infinispan.
>
> Greetings,
> Jessica
>
> Btw. I'm using a vanilla Tomcat 8 with Weld CDI, Infinispan, Jersey
> JAX-RS, and Eclipselink JPA.
>

RE: JCache CDI

Posted by "Alten, Jessica-Aileen" <Je...@liag-hannover.de>.
> I also looked at http://www.knitelius.com/2015/06/29/using-jcache-in-
> jee-67
> which I was unable to get the annotations working or at least see the
> values in the cache using cache.get after a @CacheResult. I can get
> JCache working fine without the annotations, but CDI is the route I
> want to go. So my question is do I wait for things to stabilize
> (remember this is for
> production) or is there a JCache CDI solution that works now that I can
> feel confident that when included in Java EE 8 I will not have to
> change any code. I'm in production with TomEE 2.0.0 and 7.0.0 and they
> are very stable.

Perhaps you can give Infinispan a try? There is a nice and small example at
https://github.com/infinispan/infinispan-quickstart/tree/master/cdi

The cheap trick (perhaps not only for Infinispan?) is to inject the annotated object via CDI.

Something I didn't mastered until now is the @Observes CDI annotation for cache events in Infinispan.

Greetings,
Jessica

Btw. I'm using a vanilla Tomcat 8 with Weld CDI, Infinispan, Jersey JAX-RS, and Eclipselink JPA.