1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.gwe.utils.services;
18
19 import java.util.Date;
20
21
22
23
24
25 public class PermitRequest {
26
27 private static long count = 0;
28
29 public static PermitRequest createDescriptor() {
30 return new PermitRequest(count++);
31 }
32
33 private long id;
34 private Object lock;
35 private long creationTime;
36 private long scheduledTime;
37 private long completionTime;
38
39 private PermitRequest(long id) {
40 this.id = id;
41 this.lock = new Object();
42 creationTime = System.currentTimeMillis();
43 }
44
45 public void requestScheduled() {
46 scheduledTime = System.currentTimeMillis();
47 }
48
49 public void requestCompleted() {
50 completionTime = System.currentTimeMillis();
51 }
52
53 public Object getLock() {
54 return lock;
55 }
56
57 public long getCompletionTime() {
58 return completionTime;
59 }
60
61 public long getCreationTime() {
62 return creationTime;
63 }
64
65 public long getId() {
66 return id;
67 }
68
69 public long getScheduledTime() {
70 return scheduledTime;
71 }
72
73 public String toString() {
74 return "Id: " + id + ". Created @ " + new Date(creationTime) + ". Scheduled @ " + new Date(scheduledTime)
75 + ". Completed @ " + new Date(completionTime) + "\n";
76 }
77 }