Java Code Examples for com.google.common.cache.CacheBuilderSpec#parse()
The following examples show how to use
com.google.common.cache.CacheBuilderSpec#parse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfiguredAssetsBundle.java From dropwizard-configurable-assets-bundle with Apache License 2.0 | 5 votes |
@Override public void run(AssetsBundleConfiguration bundleConfig, Environment env) throws Exception { AssetsConfiguration config = bundleConfig.getAssetsConfiguration(); // Let the cache spec from the configuration override the one specified in the code CacheBuilderSpec spec = (config.getCacheSpec() != null) ? CacheBuilderSpec.parse(config.getCacheSpec()) : cacheBuilderSpec; Iterable<Map.Entry<String, String>> overrides = config.getOverrides().entrySet(); Iterable<Map.Entry<String, String>> mimeTypes = config.getMimeTypes().entrySet(); Iterable<Map.Entry<String, String>> servletResourcePathToUriMappings; if (!config.getResourcePathToUriMappings().isEmpty()) { servletResourcePathToUriMappings = config.getResourcePathToUriMappings().entrySet(); } else { servletResourcePathToUriMappings = resourcePathToUriMappings; } AssetServlet servlet = new AssetServlet(servletResourcePathToUriMappings, indexFile, Charsets.UTF_8, spec, overrides, mimeTypes); for (Map.Entry<String, String> mapping : servletResourcePathToUriMappings) { String mappingPath = mapping.getValue(); if (!mappingPath.endsWith("/")) { mappingPath += '/'; } mappingPath += "*"; servlet.setCacheControlHeader(config.getCacheControlHeader()); LOGGER.info("Registering ConfiguredAssetBundle with name: {} for path {}", assetsName, mappingPath); env.servlets().addServlet(assetsName, servlet).addMapping(mappingPath); } }
Example 2
Source File: Converters.java From bazel with Apache License 2.0 | 5 votes |
@Override public CacheBuilderSpec convert(String spec) throws OptionsParsingException { try { return Strings.isNullOrEmpty(spec) ? null : CacheBuilderSpec.parse(spec); } catch (IllegalArgumentException e) { throw new OptionsParsingException("Failed to parse CacheBuilderSpec: " + e.getMessage(), e); } }
Example 3
Source File: GraphQLFactory.java From dropwizard-graphql with Apache License 2.0 | 4 votes |
@JsonProperty public void setQueryCache(String queryCache) { this.queryCache = CacheBuilderSpec.parse(queryCache); }
Example 4
Source File: GuavaCacheManager.java From emodb with Apache License 2.0 | 4 votes |
public GuavaCacheManager(CacheRegistry cacheRegistry, String cacheBuilderSpec) { _spec = CacheBuilderSpec.parse(checkNotNull(cacheBuilderSpec)); _cacheRegistry = cacheRegistry; }
Example 5
Source File: BasicAuthBuilder.java From eagle with Apache License 2.0 | 4 votes |
private Authenticator<BasicCredentials, User> cache(Authenticator<BasicCredentials, User> authenticator) { return new CachingAuthenticator<>(environment.metrics(), authenticator, CacheBuilderSpec.parse(authConfig.getCachePolicy())); }
Example 6
Source File: CachingAuthenticatorTest.java From dropwizard-java8 with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { when(underlying.authenticate(anyString())).thenReturn(Optional.<Principal>of(new PrincipalImpl("principal"))); cached = new CachingAuthenticator<>(new MetricRegistry(), underlying, CacheBuilderSpec.parse("maximumSize=1")); }