1 17 18 package org.sape.carbon.services.scheduler; 19 20 import java.util.Timer ; 21 22 import org.sape.carbon.core.config.InvalidConfigurationException; 23 24 import org.sape.carbon.services.threadpool.ThreadPool; 25 26 35 class FixedDelayTask extends AbstractTask { 36 37 private long period; 38 39 40 private long delay; 41 42 46 protected FixedDelayTask( 47 FixedDelayTaskConfiguration taskConfiguration, 48 ThreadPool threadPool) { 49 50 super(taskConfiguration, threadPool); 51 52 this.period = taskConfiguration.getPeriod(); 53 this.delay = taskConfiguration.getInitialDelay(); 54 55 if (this.period < 0) { 56 throw new InvalidConfigurationException( 57 this.getClass(), 58 taskConfiguration.getConfigurationName(), 59 "Period", 60 "Period cannot be less than 0"); 61 } 62 if (this.delay < 0) { 63 throw new InvalidConfigurationException( 64 this.getClass(), 65 taskConfiguration.getConfigurationName(), 66 "Delay", 67 "Delay cannot be less than 0"); 68 } 69 } 70 71 74 public void schedule(Timer timer) { 75 timer.schedule(getTask(), this.delay, this.period); 76 } 77 } 78 79 80 | Popular Tags |