1 package com.atlassian.vcache.internal;
2
3 import com.atlassian.vcache.ExternalCacheSettings;
4 import com.atlassian.vcache.JvmCacheSettings;
5 import com.atlassian.vcache.VCacheException;
6
7 /**
8 * Specifies the interface for a handler that is called before a cache is created.
9 * <p>
10 * The implementation is passed the proposed cache details and must return
11 * the ultimate cache settings that will be used. None of the returned settings are allowed to be
12 * {@link java.util.Optional#empty()}. The implementation should throw a
13 * {@link com.atlassian.vcache.VCacheException} if the cache should not be created.
14 * </p>
15 *
16 * @since 1.0.0
17 */
18 public interface VCacheCreationHandler {
19 /**
20 * Validates the settings for a {@link com.atlassian.vcache.JvmCache}.
21 *
22 * @param details the proposed details for the cache.
23 * @return the complete settings to be used.
24 * @throws VCacheException if the cache should not be created
25 */
26 JvmCacheSettings jvmCacheCreation(JvmCacheDetails details) throws VCacheException;
27
28 /**
29 * Validates the settings for a {@link com.atlassian.vcache.RequestCache}.
30 *
31 * @param name the proposed name for the cache.
32 * @throws VCacheException if the cache should not be created
33 */
34 void requestCacheCreation(String name);
35
36 /**
37 * Validates the settings for a {@link com.atlassian.vcache.ExternalCache}.
38 *
39 * @param details the proposed details for the cache.
40 * @return the complete settings to be used.
41 * @throws VCacheException if the cache should not be created
42 */
43 ExternalCacheSettings externalCacheCreation(ExternalCacheDetails details);
44 }