Monday, September 20, 2010

Spring, AspectJ, Hazelcast Method Caching Aspect

After my recent discovery of Hazelcast, I decided to update my caching aspect project to include a Hazelcast implementation.

The source code for this project is available here

For more information please refer to the actual source or my original Ehcache post. The main difference here is that the Hazelcast implementation is by default a distributed cache, and takes advantage of all the other functionality that Hazelcast provides.
The main points of interest for this implementation are:
- The actual aspect class. See code below.
- The application context. See xml below.
- The Hazelcast configuration. I am using the default Hazelcast configuration, located in the hazelcast-version.jar. To use a custom one, you can define a hazelcast.xml and inject it via Spring.
- The CacheKeyStrategy in the code below is an interface defined to allow key generation for the cache for specific requirements. There is a default implementation that simply sorts and uses hashcodes of the values in the class. You can define a strategy per type you want to cache.

note: java docs only removed for size of post

The aspect:


The application context:


The test case:

7 comments:

  1. Any idea how this can be done using Guice?

    ReplyDelete
    Replies
    1. Hi, Guice require source-level access. If the annotation bothers you or you're using Guice to create objects. I found another advance tutorial here, you can see, http://beust.com/weblog/2012/08/21/advanced-dependency-injection-with-guice/

      However I love this post also, really appreciate your work. Thanks from dragonflygames.co.uk -best free ios games

      Delete
  2. Mmmm... I have never used Guice, just did a quick search and a little bit of reading... I could probably slap it together tomorrow. From what I can see Guice is also using AopAlliance.. and their implementation will be very similar to my original Spring 2.x or even 1.X implementation. You will need to Implement MethodInterceptor ... and use a MethodInvocation object instead of ProceedingJoinPoint.

    If you don't come right, let me know.. shouldn't take long to adapt this version.

    ReplyDelete
  3. Gr8 article. Thx for sharing. I linked up your article from my blog. Hope you do not mind :)... Cheers.

    Dinuka

    ReplyDelete
  4. Thank you... and of course I don't mind.

    ReplyDelete
  5. play casino games online:

    https://www.oobbg.com
    https://www.oobbg.com/theking
    https://www.oobbg.com/sands
    https://www.oobbg.com/first
    https://www.oobbg.com/yes
    https://www.oobbg.com/coin
    https://www.oobbg.com/33
    https://www.oobbg.com/world
    https://www.oobbg.com/merit
    https://www.oobbg.com/gatsby

    https://www.omgka.com
    https://www.omgka.com/theking
    https://www.omgka.com/sands
    https://www.omgka.com/first
    https://www.omgka.com/yes
    https://www.omgka.com/super
    https://www.omgka.com/gatsby
    https://www.omgka.com/33
    https://www.omgka.com/world
    https://www.omgka.com/merit


    https://www.bbdd66.com
    https://www.bbdd66.com/theking
    https://www.bbdd66.com/sands
    https://www.bbdd66.com/first
    https://www.bbdd66.com/yes
    https://www.bbdd66.com/super
    https://www.bbdd66.com/gatsby
    https://www.bbdd66.com/33
    https://www.bbdd66.com/world
    https://www.bbdd66.com/merit

    https://www.omgab.com
    https://www.omgab.com/theking
    https://www.omgab.com/sands
    https://www.omgab.com/first
    https://www.omgab.com/yes
    https://www.omgab.com/super
    https://www.omgab.com/gatsby
    https://www.omgab.com/33
    https://www.omgab.com/world
    https://www.omgab.com/merit

    https://www.omgqq.com
    https://www.omgqq.com/thekingcasino
    https://www.omgqq.com/sandscasino
    https://www.omgqq.com/firstcasino
    https://www.omgqq.com/yescasino
    https://www.omgqq.com/supercasino
    https://www.omgqq.com/gatsbycasino
    https://www.omgqq.com/33casino
    https://www.omgqq.com/worldcasino
    https://www.omgqq.com/merit

    ReplyDelete

Popular Posts

Followers