Search in sources :

Example 1 with EhcacheCachingProvider

use of org.ehcache.jsr107.EhcacheCachingProvider 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();
}
Also used : lombok.val(lombok.val) Jsr107Configuration(org.ehcache.jsr107.config.Jsr107Configuration) DefaultConfiguration(org.ehcache.core.config.DefaultConfiguration) EhcacheCachingProvider(org.ehcache.jsr107.EhcacheCachingProvider) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with EhcacheCachingProvider

use of org.ehcache.jsr107.EhcacheCachingProvider in project oncotree by cBioPortal.

the class OncoTreeAppConfig method cachingProvider.

@Bean
public CachingProvider cachingProvider() throws Exception {
    logger.info("cachingProvider() called");
    CachingProvider cachingProvider = new EhcacheCachingProvider();
    return cachingProvider;
}
Also used : EhcacheCachingProvider(org.ehcache.jsr107.EhcacheCachingProvider) EhcacheCachingProvider(org.ehcache.jsr107.EhcacheCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) Bean(org.springframework.context.annotation.Bean)

Example 3 with EhcacheCachingProvider

use of org.ehcache.jsr107.EhcacheCachingProvider in project tutorials by jhkim105.

the class CacheConfig method hibernatePropertiesCustomizer.

@Bean
public HibernatePropertiesCustomizer hibernatePropertiesCustomizer() {
    CachingProvider cachingProvider = new EhcacheCachingProvider();
    CacheManager cacheManager = cachingProvider.getCacheManager();
    MutableConfiguration<String, Object> configuration = new MutableConfiguration<>();
    configuration.setStoreByValue(false).setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));
    cacheManager.createCache("user", configuration);
    return hibernateProperties -> hibernateProperties.put(ConfigSettings.CACHE_MANAGER, cacheManager);
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) EhcacheCachingProvider(org.ehcache.jsr107.EhcacheCachingProvider) HibernatePropertiesCustomizer(org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer) MutableConfiguration(javax.cache.configuration.MutableConfiguration) CacheManager(javax.cache.CacheManager) Bean(org.springframework.context.annotation.Bean) CachingProvider(javax.cache.spi.CachingProvider) ConfigSettings(org.hibernate.cache.jcache.ConfigSettings) Duration(javax.cache.expiry.Duration) CacheManager(javax.cache.CacheManager) Duration(javax.cache.expiry.Duration) EhcacheCachingProvider(org.ehcache.jsr107.EhcacheCachingProvider) MutableConfiguration(javax.cache.configuration.MutableConfiguration) EhcacheCachingProvider(org.ehcache.jsr107.EhcacheCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) Bean(org.springframework.context.annotation.Bean)

Example 4 with EhcacheCachingProvider

use of org.ehcache.jsr107.EhcacheCachingProvider in project solarnetwork-central by SolarNetwork.

the class BufferingDelegatingCacheTests method createCacheManager.

public static CacheManager createCacheManager() {
    try {
        File path = Files.createTempDirectory("net.solarnetwork.central.common.test").toFile();
        path.deleteOnExit();
        EhcacheCachingProvider cachingProvider = (EhcacheCachingProvider) Caching.getCachingProvider("org.ehcache.jsr107.EhcacheCachingProvider");
        DefaultConfiguration configuration = new DefaultConfiguration(cachingProvider.getDefaultClassLoader(), new DefaultPersistenceConfiguration(path));
        return cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), configuration);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : DefaultConfiguration(org.ehcache.core.config.DefaultConfiguration) DefaultPersistenceConfiguration(org.ehcache.impl.config.persistence.DefaultPersistenceConfiguration) IOException(java.io.IOException) EhcacheCachingProvider(org.ehcache.jsr107.EhcacheCachingProvider) File(java.io.File)

Example 5 with EhcacheCachingProvider

use of org.ehcache.jsr107.EhcacheCachingProvider in project solarnetwork-central by SolarNetwork.

the class UserNodeEventTaskProcessorJobTests method createCacheManager.

public static CacheManager createCacheManager() {
    try {
        File path = Files.createTempDirectory("net.solarnetwork.central.user.event.dao.jobs.test").toFile();
        path.deleteOnExit();
        EhcacheCachingProvider cachingProvider = (EhcacheCachingProvider) Caching.getCachingProvider("org.ehcache.jsr107.EhcacheCachingProvider");
        DefaultConfiguration configuration = new DefaultConfiguration(cachingProvider.getDefaultClassLoader(), new DefaultPersistenceConfiguration(path));
        return cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), configuration);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : DefaultConfiguration(org.ehcache.core.config.DefaultConfiguration) DefaultPersistenceConfiguration(org.ehcache.impl.config.persistence.DefaultPersistenceConfiguration) IOException(java.io.IOException) EhcacheCachingProvider(org.ehcache.jsr107.EhcacheCachingProvider) File(java.io.File)

Aggregations

EhcacheCachingProvider (org.ehcache.jsr107.EhcacheCachingProvider)10 Bean (org.springframework.context.annotation.Bean)7 CacheManager (javax.cache.CacheManager)4 CachingProvider (javax.cache.spi.CachingProvider)4 DefaultConfiguration (org.ehcache.core.config.DefaultConfiguration)4 File (java.io.File)3 IOException (java.io.IOException)3 MutableConfiguration (javax.cache.configuration.MutableConfiguration)3 DefaultPersistenceConfiguration (org.ehcache.impl.config.persistence.DefaultPersistenceConfiguration)3 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)3 IdMCacheConfiguration (eu.bcvsolutions.idm.core.api.config.cache.IdMCacheConfiguration)2 MutableCacheEntryListenerConfiguration (javax.cache.configuration.MutableCacheEntryListenerConfiguration)2 Qualifier (org.springframework.beans.factory.annotation.Qualifier)2 CacheObjectWrapper (eu.bcvsolutions.idm.core.api.config.cache.domain.CacheObjectWrapper)1 SerializableCacheObjectWrapper (eu.bcvsolutions.idm.core.api.config.cache.domain.SerializableCacheObjectWrapper)1 InetSocketAddress (java.net.InetSocketAddress)1 Arrays (java.util.Arrays)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1