1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.waarp.ftp.core.utils;
19
20 import java.util.TimerTask;
21
22 import org.waarp.common.logging.WaarpLogger;
23 import org.waarp.common.logging.WaarpLoggerFactory;
24 import org.waarp.ftp.core.config.FtpConfiguration;
25
26
27
28
29
30
31
32 public class FtpTimerTask extends TimerTask {
33
34
35
36 private static final WaarpLogger logger = WaarpLoggerFactory
37 .getLogger(FtpTimerTask.class);
38
39
40
41
42 public static final int TIMER_EXIT = 1;
43
44
45
46 public static final int TIMER_CONTROL = 2;
47
48
49
50
51 private final int type;
52
53
54
55 private FtpConfiguration configuration = null;
56
57
58
59
60
61
62 public FtpTimerTask(int type) {
63 super();
64 this.type = type;
65 }
66
67 @Override
68 public void run() {
69 switch (type) {
70 case TIMER_EXIT:
71 logger.error("System will force EXIT");
72 System.exit(0);
73 break;
74 case TIMER_CONTROL:
75 logger.info("Exit Shutdown Command");
76 FtpChannelUtils.terminateCommandChannels(getConfiguration());
77 logger.warn("Exit end of Command Shutdown");
78
79 break;
80 default:
81 logger.info("Type unknown in TimerTask");
82 }
83 }
84
85
86
87
88 public FtpConfiguration getConfiguration() {
89 return configuration;
90 }
91
92
93
94
95 public void setConfiguration(FtpConfiguration configuration) {
96 this.configuration = configuration;
97 }
98 }