1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.orchestra.conversation;
20
21 /***
22 * A conversation aspect which allows the conversation to automatically end after
23 * a given period of inactivity.
24 */
25 public class ConversationTimeoutableAspect extends ConversationAspect
26 {
27
28 private long timeout = -1;
29
30 public ConversationTimeoutableAspect(Conversation conversation)
31 {
32 super(conversation);
33 }
34
35 /***
36 * Get the timeout in msecs after which this conversation will be invalidated.
37 *
38 * @see #setTimeout
39 */
40 public long getTimeout()
41 {
42 return timeout;
43 }
44
45 /***
46 * Set the timeout in msecs after which this conversation will be invalidated.
47 * <p>
48 * A value of -1 means no timeout checking.
49 */
50 public void setTimeout(long timeout)
51 {
52 this.timeout = timeout;
53 }
54
55 /***
56 * Check if this conversation reached the timeout period.
57 */
58 public boolean isTimeoutReached()
59 {
60 return getTimeout() > -1 && (getConversation().getLastAccess() + getTimeout() < System.currentTimeMillis());
61 }
62 }