Package net.shibboleth.idp.attribute.resolver.spring.dc.impl

# Class CacheConfigParser

java.lang.Object
net.shibboleth.idp.attribute.resolver.spring.dc.impl.CacheConfigParser

public class CacheConfigParser extends Object
Utility class for parsing v2 cache configuration.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final Element`
`configElement`
Base XML element.
`static final long`
`DEFAULT_CACHE_ENTRIES`
Documented maximumCachedElements maximum (500).
`static final Duration`
`DEFAULT_TTL_MS`
Documented cache lifetime (4 hours).
`private final org.slf4j.Logger`
`log`
Class logger.
`static final QName`
`RESULT_CACHE`
ResultCache name.
`static final QName`
`RESULT_CACHE_BEAN`
ResultCacheBean name.

## Constructor Summary

Constructors
Constructor
Description
`CacheConfigParser(Element config)`
Creates a new cache config parser with the supplied ResultsCache element.

## Method Summary

Modifier and Type
Method
Description
`static Cache<String,Map<String,IdPAttribute>>`
`buildCacheAccess(String timeToLive, String maximumSize)`
Factory method to leverage spring property replacement functionality.
`static Cache<String,Map<String,IdPAttribute>>`
`buildCacheWrite(String timeToLive, String maximumSize)`
Factory method to leverage spring property replacement functionality.
`BeanDefinition`
`createCache()`
Creates a new cache bean definition from a v2 XML configuration.
`static String`
`getBeanResultCacheID(Element config)`
Get the bean ID of an externally defined result cache.
`private static long`
`getMaxSize(String maximumSize)`
Helper function to return size provided with a suitable default.
`private static Duration`
`getTimeToLive(String timeToLive)`
Helper function to return the TTL with a suitable default.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### RESULT_CACHE

@Nonnull public static final QName RESULT_CACHE
ResultCache name.

### RESULT_CACHE_BEAN

@Nonnull public static final QName RESULT_CACHE_BEAN
ResultCacheBean name.

### DEFAULT_CACHE_ENTRIES

public static final long DEFAULT_CACHE_ENTRIES
Documented maximumCachedElements maximum (500). Unfortunately it has to be here since we do not own the implemented class

See Also:
  - Constant Field Values

### DEFAULT_TTL_MS

@Nonnull public static final Duration DEFAULT_TTL_MS
Documented cache lifetime (4 hours). Unfortunately it has to be here since we do not own the implemented class.

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### configElement

@Nonnull private final Element configElement
Base XML element.

## Constructor Details

### CacheConfigParser

public CacheConfigParser(@Nonnull Element config)
Creates a new cache config parser with the supplied ResultsCache element.

Parameters:
  `config` - LDAPDirectory element

## Method Details

### createCache

@Nullable public BeanDefinition createCache()
Creates a new cache bean definition from a v2 XML configuration.

Returns:
  cache bean definition

### getMaxSize

private static long getMaxSize(@Nullable String maximumSize)
Helper function to return size provided with a suitable default.

Parameters:
  `maximumSize` - long string
Returns:
  the input as a long, or DEFAULT_CACHE_ENTRIES

### getTimeToLive

@Nonnull private static Duration getTimeToLive(@Nullable String timeToLive)
Helper function to return the TTL with a suitable default.

Parameters:
  `timeToLive` - duration string
Returns:
  the input as a long, or DEFAULT_TTL_MS

### buildCacheAccess

@Nullable public static Cache<String,Map<String,IdPAttribute>> buildCacheAccess(@Nullable String timeToLive, @Nullable String maximumSize)
Factory method to leverage spring property replacement functionality. The default settings are a max size of `DEFAULT_CACHE_ENTRIES` and an expiration time `DEFAULT_TTL_MS`. The Cache is set to reset the timer on Access

Parameters:
  `timeToLive` - duration string
  `maximumSize` - long string
Returns:
  cache

### buildCacheWrite

@Nullable public static Cache<String,Map<String,IdPAttribute>> buildCacheWrite(@Nullable String timeToLive, @Nullable String maximumSize)
Factory method to leverage spring property replacement functionality. The default settings are a max size of `DEFAULT_CACHE_ENTRIES` and an expiration time `DEFAULT_TTL_MS`. The Cache is set to set the timer on Populate

Parameters:
  `timeToLive` - duration string
  `maximumSize` - long string
Returns:
  cache

### getBeanResultCacheID

@Nullable public static String getBeanResultCacheID(@Nonnull Element config)
Get the bean ID of an externally defined result cache.

Parameters:
  `config` - the config element
Returns:
  data source bean ID