Class LuteceCacheLiteral

java.lang.Object
jakarta.enterprise.util.AnnotationLiteral<LuteceCache>
fr.paris.lutece.portal.service.cache.LuteceCacheLiteral
All Implemented Interfaces:
Annotation

public class LuteceCacheLiteral extends jakarta.enterprise.util.AnnotationLiteral<LuteceCache> implements LuteceCache
The LuteceCacheLiteral class is an implementation of the LuteceCache annotation that is used in the context of dependency injection frameworks. This class provides a way to create literal instances of the LuteceCache annotation which can be used for various purposes such as programmatic configuration or injection in a framework that requires annotation literals.

This class extends AnnotationLiteral<LuteceCache> and implements the LuteceCache interface, allowing it to serve as a concrete representation of the LuteceCache annotation.

Constructor:

 
 LuteceCacheLiteral(String cacheName, Class<?> keyType, Class<?> valueType, boolean enable)
 
 

Parameters:

  • cacheName: The name of the cache to be used. This is a required parameter.
  • keyType: The class type of the cache keys. Defaults to Object.class if not specified.
  • valueType: The class type of the cache values. Defaults to Object.class if not specified.
  • enable: A boolean flag indicating whether the cache injection should be enabled. Defaults to false.

Methods:

  • cacheName(): Returns the name of the cache.
  • keyType(): Returns the class type of the cache keys.
  • valueType(): Returns the class type of the cache values.
  • enable(): Returns whether the cache injection is enabled.

Example usage:

 
 LuteceCacheLiteral literal = new LuteceCacheLiteral("myCache", Integer.class, String.class, true);
 String cacheName = literal.cacheName();  // "myCache"
 Class<?> keyType = literal.keyType();    // Integer.class
 Class<?> valueType = literal.valueType(); // String.class
 boolean isEnabled = literal.enable();    // true
 
 

This class is typically used in environments where annotations need to be programmatically created and used, such as in custom CDI (Contexts and Dependency Injection) implementations or configuration setups.

See Also:
  • Constructor Details

    • LuteceCacheLiteral

      public LuteceCacheLiteral(String cacheName, Class<?> keyType, Class<?> valueType, boolean enable, boolean preventGlobalReset)
      Constructs a new LuteceCacheLiteral with the specified parameters.
      Parameters:
      cacheName - the name of the cache
      keyType - the class type of the cache keys
      valueType - the class type of the cache values
      enable - whether cache injection is enabled
      preventGlobalReset - whether the cache can be reset by global resets
    • LuteceCacheLiteral

      public LuteceCacheLiteral(String cacheName, Class<?> keyType, Class<?> valueType, boolean enable, boolean preventGlobalReset, boolean required, boolean preventReset)
      Constructs a new LuteceCacheLiteral of a cache the webapp cannot run without.
      Parameters:
      cacheName - the name of the cache
      keyType - the class type of the cache keys
      valueType - the class type of the cache values
      enable - whether cache injection is enabled
      preventGlobalReset - whether the cache can be reset by global resets
      required - whether the cache is always enabled
      preventReset - whether every reset of the cache is prevented
  • Method Details

    • cacheName

      public String cacheName()
    • keyType

      public Class<?> keyType()
    • valueType

      public Class<?> valueType()
    • enable

      public boolean enable()
    • preventGlobalReset

      public boolean preventGlobalReset()
    • required

      public boolean required()
    • preventReset

      public boolean preventReset()