use of org.ehcache.jsr107.config.Jsr107Configuration in project ehcache3 by ehcache.
the class Jsr107ServiceConfigurationParser method parse.
@Override
public Jsr107Configuration parse(final Element fragment, ClassLoader classLoader) {
boolean jsr107CompliantAtomics = true;
ConfigurationElementState enableManagementAll = ConfigurationElementState.UNSPECIFIED;
ConfigurationElementState enableStatisticsAll = ConfigurationElementState.UNSPECIFIED;
if (fragment.hasAttribute(JSR_107_COMPLIANT_ATOMICS_ATTRIBUTE)) {
jsr107CompliantAtomics = parseBoolean(fragment.getAttribute(JSR_107_COMPLIANT_ATOMICS_ATTRIBUTE));
}
if (fragment.hasAttribute(ENABLE_MANAGEMENT_ALL_ATTRIBUTE)) {
enableManagementAll = parseBoolean(fragment.getAttribute(ENABLE_MANAGEMENT_ALL_ATTRIBUTE)) ? ConfigurationElementState.ENABLED : ConfigurationElementState.DISABLED;
}
if (fragment.hasAttribute(ENABLE_STATISTICS_ALL_ATTRIBUTE)) {
enableStatisticsAll = parseBoolean(fragment.getAttribute(ENABLE_STATISTICS_ALL_ATTRIBUTE)) ? ConfigurationElementState.ENABLED : ConfigurationElementState.DISABLED;
}
final String defaultTemplate = fragment.getAttribute(DEFAULT_TEMPLATE_ATTRIBUTE);
final HashMap<String, String> templates = new HashMap<>();
final NodeList childNodes = fragment.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
final Node node = childNodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
final Element item = (Element) node;
templates.put(item.getAttribute(CACHE_NAME_ATTRIBUTE), item.getAttribute(TEMPLATE_NAME_ATTRIBUTE));
}
}
return new Jsr107Configuration(defaultTemplate, templates, jsr107CompliantAtomics, enableManagementAll, enableStatisticsAll);
}
use of org.ehcache.jsr107.config.Jsr107Configuration in project cas by apereo.
the class Ehcache3TicketRegistryConfiguration method ehcache3TicketCacheManager.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "ehcache3TicketCacheManager")
public CacheManager ehcache3TicketCacheManager(final ConfigurableApplicationContext applicationContext, @Qualifier("ehcache3CacheManagerConfiguration") final ServiceCreationConfiguration ehcache3CacheManagerConfiguration, final CasConfigurationProperties casProperties) {
return BeanSupplier.of(CacheManager.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
val ehcacheProperties = casProperties.getTicket().getRegistry().getEhcache3();
val ehcacheProvider = (EhcacheCachingProvider) Caching.getCachingProvider(EhcacheCachingProvider.class.getName());
val statisticsAllEnabled = ehcacheProperties.isEnableStatistics() ? ConfigurationElementState.ENABLED : ConfigurationElementState.DISABLED;
val managementEnabled = ehcacheProperties.isEnableManagement() ? ConfigurationElementState.ENABLED : ConfigurationElementState.DISABLED;
val jsr107Config = new Jsr107Configuration(null, new HashMap<>(), false, managementEnabled, statisticsAllEnabled);
val configuration = new DefaultConfiguration(ehcacheProvider.getDefaultClassLoader(), ehcache3CacheManagerConfiguration, jsr107Config);
return ehcacheProvider.getCacheManager(ehcacheProvider.getDefaultURI(), configuration);
}).otherwiseProxy().get();
}
use of org.ehcache.jsr107.config.Jsr107Configuration in project ehcache3 by ehcache.
the class DefaultJsr107Service method getTemplateNameForCache.
@Override
public String getTemplateNameForCache(String cacheAlias) {
final Jsr107Configuration cfg = configuration;
if (cfg == null) {
return null;
}
String template = cfg.getTemplates().get(cacheAlias);
if (template != null) {
return template;
}
return cfg.getDefaultTemplate();
}
use of org.ehcache.jsr107.config.Jsr107Configuration in project ehcache3 by ehcache.
the class Jsr107ServiceConfigurationParserTest method testTranslateServiceCreationConfiguration.
@Test(expected = XmlConfigurationException.class)
public void testTranslateServiceCreationConfiguration() throws IOException, ParserConfigurationException, SAXException {
Jsr107ServiceConfigurationParser configTranslator = new Jsr107ServiceConfigurationParser();
Map<String, String> templateMap = new HashMap<>();
templateMap.put("testCache", "simpleCacheTemplate");
templateMap.put("testCache1", "simpleCacheTemplate1");
boolean jsr107CompliantAtomics = true;
Jsr107Configuration serviceCreationConfiguration = new Jsr107Configuration("tiny-template", templateMap, jsr107CompliantAtomics, ConfigurationElementState.ENABLED, ConfigurationElementState.DISABLED);
configTranslator.unparse(createDocumentRoot(configTranslator.getSchema().values()), serviceCreationConfiguration);
}
Aggregations