01: package dalma.container;
02:
03: import dalma.Conversation;
04:
05: /**
06: * Implemented by the application to specify the log preservation policy.
07: *
08: * @author Kohsuke Kawaguchi
09: */
10: public interface LogRotationPolicy {
11: /**
12: * Called to determine if the log data of the given completed
13: * conversation shall be kept or discarded.
14: *
15: * @param conv
16: * always non-null, valid completed conversation.
17: * @return
18: * true to indicate that this log be kept. false to discard.
19: */
20: boolean keep(Conversation conv);
21:
22: /**
23: * Default policy.
24: *
25: * Currently it's 7 days from completion, but may change in the future.
26: */
27: public static final LogRotationPolicy DEFAULT = new LogRotationPolicy() {
28: public boolean keep(Conversation conv) {
29: long diff = System.currentTimeMillis()
30: - conv.getCompletionDate().getTime();
31: return diff > 7 * 24 * 60 * 60 * 1000;
32: }
33: };
34:
35: /**
36: * {@link LogRotationPolicy} that keeps everything.
37: */
38: public static final LogRotationPolicy NEVER = new LogRotationPolicy() {
39: public boolean keep(Conversation conv) {
40: return true;
41: }
42: };
43: }
|