View Javadoc

1   package com.atlassian.vcache.internal.memcached;
2   
3   import com.atlassian.vcache.internal.BegunTransactionalActivityHandler;
4   import com.atlassian.vcache.internal.ExternalCacheExceptionListener;
5   import com.atlassian.vcache.internal.RequestContext;
6   import com.atlassian.vcache.internal.VCacheCreationHandler;
7   import com.atlassian.vcache.internal.VCacheSettingsDefaultsProvider;
8   import com.atlassian.vcache.internal.core.ExternalCacheKeyGenerator;
9   import com.atlassian.vcache.internal.core.metrics.MetricsCollector;
10  import net.spy.memcached.MemcachedClientIF;
11  
12  import java.time.Duration;
13  import java.util.function.Function;
14  import java.util.function.Supplier;
15  
16  import static java.util.Objects.requireNonNull;
17  
18  /**
19   * Represents the settings for a {@link MemcachedVCacheService}.
20   * They are created using the {@link MemcachedVCacheServiceSettingsBuilder},
21   * which you should consult for the description of each property.
22   *
23   * @since 1.3.0
24   */
25  public class MemcachedVCacheServiceSettings {
26      private final Supplier<MemcachedClientIF> clientSupplier;
27      private final Supplier<RequestContext> contextSupplier;
28      private final VCacheSettingsDefaultsProvider defaultsProvider;
29      private final VCacheCreationHandler creationHandler;
30      private final MetricsCollector metricsCollector;
31      private final ExternalCacheKeyGenerator externalCacheKeyGenerator;
32      private final BegunTransactionalActivityHandler begunTransactionalActivityHandler;
33      private final Function<String, Boolean> dontExternaliseCache;
34      private final boolean serializationHack;
35      private final Duration lockTimeout;
36      private Supplier<RequestContext> workContextContextSupplier;
37      private final ExternalCacheExceptionListener externalCacheExceptionListener;
38  
39      MemcachedVCacheServiceSettings(Supplier<MemcachedClientIF> clientSupplier,
40                                     Supplier<RequestContext> contextSupplier,
41                                     Supplier<RequestContext> workContextContextSupplier,
42                                     VCacheSettingsDefaultsProvider defaultsProvider,
43                                     VCacheCreationHandler creationHandler,
44                                     MetricsCollector metricsCollector,
45                                     ExternalCacheKeyGenerator externalCacheKeyGenerator,
46                                     BegunTransactionalActivityHandler begunTransactionalActivityHandler,
47                                     Function<String, Boolean> dontExternaliseCache,
48                                     boolean serializationHack,
49                                     Duration lockTimeout,
50                                     ExternalCacheExceptionListener externalCacheExceptionListener) {
51          this.clientSupplier = requireNonNull(clientSupplier);
52          this.contextSupplier = requireNonNull(contextSupplier);
53          this.workContextContextSupplier = requireNonNull(workContextContextSupplier);
54          this.defaultsProvider = requireNonNull(defaultsProvider);
55          this.creationHandler = requireNonNull(creationHandler);
56          this.metricsCollector = requireNonNull(metricsCollector);
57          this.externalCacheKeyGenerator = requireNonNull(externalCacheKeyGenerator);
58          this.begunTransactionalActivityHandler = requireNonNull(begunTransactionalActivityHandler);
59          this.dontExternaliseCache = requireNonNull(dontExternaliseCache);
60          this.serializationHack = serializationHack;
61          this.lockTimeout = requireNonNull(lockTimeout);
62          this.externalCacheExceptionListener = requireNonNull(externalCacheExceptionListener);
63      }
64  
65      public Supplier<MemcachedClientIF> getClientSupplier() {
66          return clientSupplier;
67      }
68  
69      public Supplier<RequestContext> getContextSupplier() {
70          return contextSupplier;
71      }
72  
73      public VCacheSettingsDefaultsProvider getDefaultsProvider() {
74          return defaultsProvider;
75      }
76  
77      public VCacheCreationHandler getCreationHandler() {
78          return creationHandler;
79      }
80  
81      public MetricsCollector getMetricsCollector() {
82          return metricsCollector;
83      }
84  
85      public ExternalCacheKeyGenerator getExternalCacheKeyGenerator() {
86          return externalCacheKeyGenerator;
87      }
88  
89      public BegunTransactionalActivityHandler getBegunTransactionalActivityHandler() {
90          return begunTransactionalActivityHandler;
91      }
92  
93      public Function<String, Boolean> getDontExternaliseCache() {
94          return dontExternaliseCache;
95      }
96  
97      public Supplier<RequestContext> getWorkContextContextSupplier() {
98          return workContextContextSupplier;
99      }
100 
101     public boolean isSerializationHack() {
102         return serializationHack;
103     }
104 
105     public Duration getLockTimeout() {
106         return lockTimeout;
107     }
108 
109     public ExternalCacheExceptionListener getExternalCacheExceptionListener() {
110         return externalCacheExceptionListener;
111     }
112 }