001/* 002 * Copyright 2012 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.web.workflow.archive; 017 018/** 019 * Archive contents scheduler: launches a cron which archives contents when 020 * necessary. 021 * This scheduler is the same as the CMS' ArchiveContentsScheduler, except it runs the web version of ArchiveContentsEngine. 022 */ 023public class ArchiveContentsScheduler extends org.ametys.cms.workflow.archive.ArchiveContentsScheduler 024{ 025 @Override 026 public void run() 027 { 028 ArchiveContentsEngine archiveContentsEngine = new ArchiveContentsEngine(); 029 030 try 031 { 032 // Initialize and configure the engine. 033 archiveContentsEngine.initialize(_manager, _context); 034 archiveContentsEngine.configure(_configuration); 035 } 036 catch (Exception e) 037 { 038 throw new RuntimeException("Unable to initialize the archive engine", e); 039 } 040 041 // The thread will be started as daemon, as the scheduler is marked 042 // daemon itself. 043 new Thread(archiveContentsEngine, "ArchiveContentsEngine").start(); 044 } 045}