All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.cache.annotation.CacheDefaults Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
/**
 *  Copyright (c) 2011-2013 Terracotta, Inc.
 *  Copyright (c) 2011-2013 Oracle and/or its affiliates.
 *
 *  All rights reserved. Use is subject to license terms.
 */

package javax.cache.annotation;

import javax.enterprise.util.Nonbinding;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


/**
 * Allows the configuration of defaults for {@link CacheResult}, {@link CachePut},
 * {@link CacheRemoveEntry}, and {@link CacheRemoveAll} at the class level. Without
 * the method level annotations this annotation has no effect.
 * 

* Example of specifying a default cache name that is used by the annotations on the * getDomain and deleteDomain methods. The annotation for getAllDomains would use the * "allDomains" cache name specified in the method level annotation. *

 * package my.app;
 * 

* @CacheDefaults(cacheName="domainCache") * public class DomainDao { * @CacheResult * public Domain getDomain(String domainId, int index) { * ... * } *

* @CacheRemoveEntry * public void deleteDomain(String domainId, int index) { * ... * } *

* @CacheResult(cacheName="allDomains") * public List<Domain> getAllDomains() { * ... * } * } *

* * @author Rick Hightower * @since 1.0 */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface CacheDefaults { /** * The default name of the cache for the annotated class *

* If not specified defaults to: package.name.ClassName.methodName(package.ParameterType,package.ParameterType) *

* Applicable for {@link CacheResult}, {@link CachePut}, {@link CacheRemoveEntry}, and {@link CacheRemoveAll} */ @Nonbinding String cacheName() default ""; /** * The {@link CacheResolverFactory} used to find the {@link CacheResolver} to use at runtime. *

* The default resolver pair will resolve the cache by name from the default {@link javax.cache.CacheManager} *

* Applicable for {@link CacheResult}, {@link CachePut}, {@link CacheRemoveEntry}, and {@link CacheRemoveAll} */ @Nonbinding Class cacheResolverFactory() default CacheResolverFactory.class; /** * The {@link CacheKeyGenerator} to use to generate the {@link GeneratedCacheKey} for interacting * with the specified Cache. *

* Defaults to a key generator that uses {@link java.util.Arrays#deepHashCode(Object[])} and * {@link java.util.Arrays#deepEquals(Object[], Object[])} with the array returned by * {@link CacheKeyInvocationContext#getKeyParameters()} *

* Applicable for {@link CacheResult}, {@link CachePut}, and {@link CacheRemoveEntry} * * @see CacheKey */ @Nonbinding Class cacheKeyGenerator() default CacheKeyGenerator.class; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy