use of org.springframework.scheduling.annotation.Scheduled in project cas by apereo.
the class AbstractServicesManager method load.
/**
* Load services that are provided by the DAO.
*/
@Scheduled(initialDelayString = "${cas.serviceRegistry.schedule.startDelay:20000}", fixedDelayString = "${cas.serviceRegistry.schedule.repeatInterval:60000}")
@Override
@PostConstruct
public void load() {
LOGGER.debug("Loading services from [{}]", this.serviceRegistry);
this.services = this.serviceRegistry.load().stream().collect(Collectors.toConcurrentMap(r -> {
LOGGER.debug("Adding registered service [{}]", r.getServiceId());
return r.getId();
}, Function.identity(), (r, s) -> s == null ? r : s));
loadInternal();
publishEvent(new CasRegisteredServicesLoadedEvent(this, getAllServices()));
evaluateExpiredServiceDefinitions();
LOGGER.info("Loaded [{}] service(s) from [{}].", this.services.size(), this.serviceRegistry.getName());
}
use of org.springframework.scheduling.annotation.Scheduled in project cas by apereo.
the class MultifactorAuthenticationTrustStorageCleaner method clean.
/**
* Clean up expired records.
*/
@Scheduled(initialDelayString = "${cas.authn.mfa.trusted.cleaner.schedule.startDelay:PT10S}", fixedDelayString = "${cas.authn.mfa.trusted.cleaner.schedule.repeatInterval:PT60S}")
public void clean() {
if (!trustedProperties.getCleaner().getSchedule().isEnabled()) {
LOGGER.debug("[{}] is disabled. Expired trusted authentication records will not automatically be cleaned up by CAS", getClass().getName());
return;
}
try {
LOGGER.debug("Proceeding to clean up expired trusted authentication records...");
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
final LocalDate validDate = LocalDate.now().minus(trustedProperties.getExpiration(), DateTimeUtils.toChronoUnit(trustedProperties.getTimeUnit()));
LOGGER.info("Expiring records that are on/before [{}]", validDate);
this.storage.expire(validDate);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
use of org.springframework.scheduling.annotation.Scheduled in project CzechIdMng by bcvsolutions.
the class DefaultAttachmentManager method purgeTempFiles.
/**
* Purge old temporary files once per day.
* Temporary files older than configured ttl will be purged.
*
* @return purged files count
*/
@Scheduled(fixedDelay = 3600000)
public void purgeTempFiles() {
int purgedFiles = 0;
long ttl = attachmentConfiguration.getTempTtl();
if (ttl == 0) {
LOG.warn("Removing old temporary files is disabled. Configure property [{}] - time to live in milliseconds (greater than zero).", AttachmentConfiguration.PROPERTY_TEMP_TTL);
return;
}
//
// purge older temporary files than purge time
long purgeTime = System.currentTimeMillis() - ttl;
File temp = new File(getTempPath());
if (temp.isDirectory()) {
File[] files = temp.listFiles();
if (files != null) {
for (File f : files) {
try {
if (f.getName().endsWith("." + DEFAULT_TEMP_FILE_EXTENSION) && f.lastModified() < purgeTime) {
f.delete();
purgedFiles++;
}
} catch (Exception ex) {
LOG.error("Removing old temporary [.{}] file [{}] failed", DEFAULT_TEMP_FILE_EXTENSION, f.getName(), ex);
}
}
}
}
LOG.debug("Temporary files were purged [{}]", purgedFiles);
}
use of org.springframework.scheduling.annotation.Scheduled in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManager method scheduleProcessCreated.
/**
* Spring schedule new task after previous task ended (don't run concurrently)
*/
@Scheduled(fixedDelayString = "${" + SchedulerConfiguration.PROPERTY_EVENT_QUEUE_PROCESS + ":" + SchedulerConfiguration.DEFAULT_EVENT_QUEUE_PROCESS + "}")
public void scheduleProcessCreated() {
if (!eventConfiguration.isAsynchronous()) {
// prevent to debug some messages into log - usable for devs
return;
}
// run as system - called from scheduler internally
securityService.setSystemAuthentication();
//
// calculate events to process
String instanceId = configurationService.getInstanceId();
List<IdmEntityEventDto> events = getCreatedEvents(instanceId);
LOG.trace("Events to process [{}] on instance [{}].", events.size(), instanceId);
for (IdmEntityEventDto event : events) {
// @Transactional
context.getBean(this.getClass()).executeEvent(event);
;
}
}
use of org.springframework.scheduling.annotation.Scheduled in project uplace.es by Uplace.
the class UserService method removeNotActivatedUsers.
/**
* Not activated users should be automatically deleted after 3 days.
* <p>
* This is scheduled to get fired everyday, at 01:00 (am).
*/
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS));
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE).evict(user.getLogin());
cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE).evict(user.getEmail());
}
}
Aggregations