1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.modeshape.jboss.managed;
25
26 import java.util.Comparator;
27 import net.jcip.annotations.Immutable;
28 import org.jboss.managed.api.annotation.ManagementComponent;
29 import org.jboss.managed.api.annotation.ManagementObject;
30 import org.jboss.managed.api.annotation.ManagementObjectID;
31 import org.jboss.managed.api.annotation.ManagementProperties;
32 import org.jboss.managed.api.annotation.ManagementProperty;
33 import org.jboss.managed.api.annotation.ViewUse;
34 import org.joda.time.DateTime;
35 import org.modeshape.common.util.CheckArg;
36
37
38
39
40 @Immutable
41 @ManagementObject( description = "A ModeShape node lock", componentType = @ManagementComponent( type = "ModeShape", subtype = "Lock" ), properties = ManagementProperties.EXPLICIT )
42 public final class ManagedLock implements ModeShapeManagedObject {
43
44
45
46
47 public static final Comparator<ManagedLock> SORT_BY_OWNER = new Comparator<ManagedLock>() {
48 @Override
49 public int compare( ManagedLock thisLock,
50 ManagedLock thatLock ) {
51 return thisLock.getOwner().compareTo(thatLock.getOwner());
52 }
53 };
54
55
56
57
58 private final boolean deep;
59
60
61
62
63 private final DateTime expiration;
64
65
66
67
68 private final String id;
69
70
71
72
73
74 private final String sessionId;
75
76
77
78
79 private final String owner;
80
81
82
83
84 private final boolean sessionBased;
85
86
87
88
89
90 private final String workspaceName;
91
92
93
94
95
96
97
98
99
100
101
102
103 public ManagedLock( String workspaceName,
104 boolean sessionBased,
105 String sessionId,
106 DateTime expiration,
107 String id,
108 String owner,
109 boolean deep ) {
110 CheckArg.isNotEmpty(workspaceName, "workspaceName");
111 CheckArg.isNotEmpty(sessionId, "sessionId");
112 CheckArg.isNotNull(expiration, "expiration");
113 CheckArg.isNotEmpty(id, "id");
114 CheckArg.isNotEmpty(owner, "owner");
115
116 this.deep = deep;
117 this.expiration = expiration;
118 this.id = id;
119 this.sessionId = sessionId;
120 this.owner = owner;
121 this.sessionBased = sessionBased;
122 this.workspaceName = workspaceName;
123 }
124
125
126
127
128
129
130 @ManagementProperty( name = "Expiration Time", description = "The time this lock will expire", readOnly = true, use = ViewUse.RUNTIME )
131 public DateTime getExpiration() {
132 return this.expiration;
133 }
134
135
136
137
138
139
140 @ManagementProperty( name = "Lock ID", description = "The lock's unique identifier", readOnly = true, use = ViewUse.RUNTIME )
141 @ManagementObjectID( prefix = "ModeShapeLock-" )
142 public String getId() {
143 return this.id;
144 }
145
146
147
148
149
150
151 @ManagementProperty( name = "Owner", description = "The owner of the lock", readOnly = true, use = ViewUse.RUNTIME )
152 public String getOwner() {
153 return this.owner;
154 }
155
156
157
158
159
160
161 @ManagementProperty( name = "Session ID", description = "The identifier of the session this lock belongs to", readOnly = true, use = ViewUse.RUNTIME )
162 public String getSessionId() {
163 return this.sessionId;
164 }
165
166
167
168
169
170
171 @ManagementProperty( name = "Workspace", description = "The name of the workspace lock belongs to", readOnly = true, use = ViewUse.RUNTIME )
172 public String getWorkspaceName() {
173 return this.workspaceName;
174 }
175
176
177
178
179
180
181 @ManagementProperty( name = "Deep", description = "Indicates if this lock is a deep lock", readOnly = true, use = ViewUse.RUNTIME )
182 public boolean isDeep() {
183 return this.deep;
184 }
185
186
187
188
189
190
191 @ManagementProperty( name = "Session-Based", description = "Indicates if this lock is a session-based lock", readOnly = true, use = ViewUse.RUNTIME )
192 public boolean isSessionBased() {
193 return this.sessionBased;
194 }
195
196 }