Search in sources :

Example 1 with CacheRefreshEvent

use of org.gluu.oxtrust.service.cdi.event.CacheRefreshEvent in project oxTrust by GluuFederation.

the class CacheRefreshTimer method initTimer.

public void initTimer() {
    log.info("Initializing Cache Refresh Timer");
    this.isActive = new AtomicBoolean(false);
    // Clean up previous Inum cache
    CacheRefreshConfiguration cacheRefreshConfiguration = configurationFactory.getCacheRefreshConfiguration();
    if (cacheRefreshConfiguration != null) {
        String snapshotFolder = cacheRefreshConfiguration.getSnapshotFolder();
        if (StringHelper.isNotEmpty(snapshotFolder)) {
            String inumCachePath = getInumCachePath(cacheRefreshConfiguration);
            objectSerializationService.cleanup(inumCachePath);
        }
    }
    // Schedule to start cache refresh every 1 minute
    final int delay = 1 * 60;
    final int interval = DEFAULT_INTERVAL;
    timerEvent.fire(new TimerEvent(new TimerSchedule(delay, DEFAULT_INTERVAL), new CacheRefreshEvent(), Scheduled.Literal.INSTANCE));
    this.lastFinishedTime = System.currentTimeMillis();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TimerSchedule(org.xdi.service.timer.schedule.TimerSchedule) CacheRefreshConfiguration(org.xdi.config.oxtrust.CacheRefreshConfiguration) TimerEvent(org.xdi.service.timer.event.TimerEvent) CacheRefreshEvent(org.gluu.oxtrust.service.cdi.event.CacheRefreshEvent)

Aggregations

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 CacheRefreshEvent (org.gluu.oxtrust.service.cdi.event.CacheRefreshEvent)1 CacheRefreshConfiguration (org.xdi.config.oxtrust.CacheRefreshConfiguration)1 TimerEvent (org.xdi.service.timer.event.TimerEvent)1 TimerSchedule (org.xdi.service.timer.schedule.TimerSchedule)1