コード例 #1
0
 /** Clears all the resources referenced into this instance of volatile cache. */
 public void clear() {
   final VolatileResourceCacheService current = this;
   try {
     ManagedThreadPool.invoke(
         () -> {
           try {
             current.deleteAllAttachments();
           } catch (RuntimeException e) {
             // This treatment must not disturb the server in any case, so nothing is thrown here.
             SilverLogger.getLogger(this)
                 .error("The clear of volatile cache did not end successfully...", e);
           }
         });
   } catch (RuntimeException e) {
     // This treatment must not disturb the server in any case, so nothing is thrown here.
     SilverLogger.getLogger(this)
         .error("The clear of volatile cache did not end successfully...", e);
   }
 }
  @Override
  public void init() throws Exception {

    // Job instance
    final TemporaryDataCleanerJob temporaryDataCleanerJob = new TemporaryDataCleanerJob();

    // Cleaning temporary data at start if requested
    startTask =
        ManagedThreadPool.invoke(
                () -> {
                  temporaryDataCleanerJob.clean(
                      TemporaryDataManagementSetting
                          .getTimeAfterThatFilesMustBeDeletedAtServerStart());
                })
            .iterator()
            .next();

    // Setting CRON
    final String cron = TemporaryDataManagementSetting.getJobCron();
    scheduler.unscheduleJob(JOB_NAME);
    if (StringUtil.isDefined(cron)) {
      scheduler.scheduleJob(temporaryDataCleanerJob, JobTrigger.triggerAt(cron));
    }
  }