Declarative Caching using Spring, Ehcache and Java 5 Annotations

Java Class

package services.interfaces;

import org.springmodules.cache.annotations.Cacheable;
import services.model.Location;

public interface LocationService {
       
        @Cacheable(modelId="getLocationCacheModel")
        public Location getLocation(String zipcode);
}

ehcache.xml

<ehcache>
        <defaultCache
                maxElementsInMemory="500"
                eternal="true"
                overflowToDisk="false"
                memoryStoreEvictionPolicy="LFU" />
               
        <cache name="getLocationCache"
                maxElementsInMemory="50"
                eternal="true"
                overflowToDisk="false"
                memoryStoreEvictionPolicy="LFU" />
</ehcache>

Spring Configuration File

Add the following namespace definition:
http://www.springmodules.org/schema/ehcache
http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd

<ehcache:config configLocation="classpath:ehcache.xml" />
<ehcache:annotations>
        <ehcache:caching id="getLocationCacheModel"
                cacheName="getLocationCache" />
</ehcache:annotations>

Comments

I am one of the authors of a new project intended to provide Ehcache integration for Spring 3 projects via annotations:

http://code.google.com/p/ehcache-spring-annotations/

We are excited to announce the general availability of the first production release, 1.0.1.

This release provides 2 method-level annotations in the spirit of Spring’s @Transactional:

@Cacheable
@TriggersRemove

When appropriately configured in your Spring application, this project will create caching aspects at runtime around your @Cacheable annotated methods.

Usage documentation can be found on the project wiki:

http://code.google.com/p/ehcache-spring-annotations/wiki/UsingCacheAnnot...
http://code.google.com/p/ehcache-spring-annotations/wiki/UsingTriggersRe...

Implausibly quickly service and especial quality essays online complying with my requirements. Research paper was good above my expectations and I look forward to buy more essay papers in the future and tip to you this service.