Search in sources :

Example 1 with CacheConfiguration

use of org.gluu.service.cache.CacheConfiguration in project oxCore by GluuFederation.

the class InMemoryCacheProviderTest method beforeClass.

@BeforeClass
public void beforeClass() {
    CacheConfiguration cacheConfiguration = new CacheConfiguration();
    cache = new InMemoryCacheProvider();
    cache.configure(cacheConfiguration);
    cache.create();
}
Also used : InMemoryCacheProvider(org.gluu.service.cache.InMemoryCacheProvider) CacheConfiguration(org.gluu.service.cache.CacheConfiguration) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with CacheConfiguration

use of org.gluu.service.cache.CacheConfiguration in project oxCore by GluuFederation.

the class ConfigurationFactory method loadCacheConfiguration.

private CacheConfiguration loadCacheConfiguration() {
    SharedConfigurationEntry sharedConfigurationEntry = persistenceEntryManager.find(SharedConfigurationEntry.class, SHARED_CONFIGURATION_DN);
    if (sharedConfigurationEntry == null) {
        LOG.error("Failed to load share configuration from DB. Please fix it!!!.");
        throw new ConfigurationException("Failed to load shared configuration from DB.");
    }
    CacheConfiguration cacheConfiguration = sharedConfigurationEntry.getCacheConfiguration();
    if (cacheConfiguration == null || cacheConfiguration.getCacheProviderType() == null) {
        LOG.error("Failed to read cache configuration from DB. Please check configuration oxCacheConfiguration attribute " + "that must contain cache configuration JSON represented by CacheConfiguration.class. Shared configuration DN: " + SHARED_CONFIGURATION_DN);
        LOG.info("Creating fallback IN-MEMORY cache configuration ... ");
        cacheConfiguration = new CacheConfiguration();
        cacheConfiguration.setInMemoryConfiguration(new InMemoryConfiguration());
        LOG.info("IN-MEMORY cache configuration is created.");
    }
    LOG.info("Cache configuration: " + cacheConfiguration);
    return cacheConfiguration;
}
Also used : InMemoryConfiguration(org.gluu.service.cache.InMemoryConfiguration) ConfigurationException(org.gluu.util.exception.ConfigurationException) SharedConfigurationEntry(org.gluu.conf.model.SharedConfigurationEntry) CacheConfiguration(org.gluu.service.cache.CacheConfiguration)

Example 3 with CacheConfiguration

use of org.gluu.service.cache.CacheConfiguration in project oxCore by GluuFederation.

the class DummyConfigurationFactoryTest method checkCacheConfiguration.

@Test(enabled = false)
public void checkCacheConfiguration() {
    CacheConfiguration cacheConfiguration = dummyConfigurationFactory.getCacheConfiguration();
    assertNotNull(cacheConfiguration);
    assertNotNull(cacheConfiguration.getCacheProviderType());
}
Also used : CacheConfiguration(org.gluu.service.cache.CacheConfiguration) Test(org.testng.annotations.Test)

Example 4 with CacheConfiguration

use of org.gluu.service.cache.CacheConfiguration in project oxTrust by GluuFederation.

the class ApplicationFactory method getCacheConfiguration.

@Produces
@ApplicationScoped
public CacheConfiguration getCacheConfiguration() {
    CacheConfiguration cacheConfiguration = configurationService.getConfiguration().getCacheConfiguration();
    if ((cacheConfiguration == null) || (cacheConfiguration.getCacheProviderType() == null)) {
        log.error("Failed to read cache configuration from DB. Please check configuration oxCacheConfiguration attribute " + "that must contain cache configuration JSON represented by CacheConfiguration.class. Appliance DN: " + configurationService.getConfiguration().getDn());
        log.info("Creating fallback IN-MEMORY cache configuration ... ");
        cacheConfiguration = new CacheConfiguration();
        cacheConfiguration.setInMemoryConfiguration(new InMemoryConfiguration());
        log.info("IN-MEMORY cache configuration is created.");
    } else if (cacheConfiguration.getNativePersistenceConfiguration() != null) {
        cacheConfiguration.getNativePersistenceConfiguration().setBaseDn(appConfiguration.getBaseDN());
    }
    log.info("Cache configuration: " + cacheConfiguration);
    return cacheConfiguration;
}
Also used : InMemoryConfiguration(org.gluu.service.cache.InMemoryConfiguration) CacheConfiguration(org.gluu.service.cache.CacheConfiguration) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 5 with CacheConfiguration

use of org.gluu.service.cache.CacheConfiguration in project oxAuth by GluuFederation.

the class ApplicationFactory method getCacheConfiguration.

@Produces
@ApplicationScoped
public CacheConfiguration getCacheConfiguration() {
    CacheConfiguration cacheConfiguration = configurationService.getConfiguration().getCacheConfiguration();
    if (cacheConfiguration == null || cacheConfiguration.getCacheProviderType() == null) {
        log.error("Failed to read cache configuration from DB. Please check configuration oxCacheConfiguration attribute " + "that must contain cache configuration JSON represented by CacheConfiguration.class. Appliance DN: " + configurationService.getConfiguration().getDn());
        log.info("Creating fallback IN-MEMORY cache configuration ... ");
        cacheConfiguration = new CacheConfiguration();
        cacheConfiguration.setInMemoryConfiguration(new InMemoryConfiguration());
        log.info("IN-MEMORY cache configuration is created.");
    }
    if (cacheConfiguration.getNativePersistenceConfiguration() != null) {
        if (!StringUtils.isEmpty(staticConfiguration.getBaseDn().getSessions())) {
            cacheConfiguration.getNativePersistenceConfiguration().setBaseDn(StringUtils.remove(staticConfiguration.getBaseDn().getSessions(), "ou=sessions,").trim());
        }
    }
    log.info("Cache configuration: " + cacheConfiguration);
    return cacheConfiguration;
}
Also used : InMemoryConfiguration(org.gluu.service.cache.InMemoryConfiguration) CacheConfiguration(org.gluu.service.cache.CacheConfiguration) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Aggregations

CacheConfiguration (org.gluu.service.cache.CacheConfiguration)5 InMemoryConfiguration (org.gluu.service.cache.InMemoryConfiguration)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Produces (javax.enterprise.inject.Produces)2 SharedConfigurationEntry (org.gluu.conf.model.SharedConfigurationEntry)1 InMemoryCacheProvider (org.gluu.service.cache.InMemoryCacheProvider)1 ConfigurationException (org.gluu.util.exception.ConfigurationException)1 BeforeClass (org.testng.annotations.BeforeClass)1 Test (org.testng.annotations.Test)1