1 package org.sourceforge.jemm.database.persistent.berkeley;
2
3 import java.util.LinkedList;
4
5 import com.sleepycat.persist.model.Entity;
6 import com.sleepycat.persist.model.PrimaryKey;
7
8 import org.sourceforge.jemm.database.ClientId;
9 import org.sourceforge.jemm.database.ClientThreadId;
10 import org.sourceforge.jemm.database.components.UserLockInfo;
11 import org.sourceforge.jemm.types.ID;
12
13 @Entity
14 public class UserLockEntry {
15
16 @PrimaryKey
17 long id;
18
19 String clientId;
20 String threadId;
21
22 LinkedList<ClientThreadId> lockQueue;
23
24 public UserLockEntry() {}
25
26 public UserLockEntry(UserLockInfo info) {
27 this.id = info.getId().getIDValue();
28 ClientThreadId clientThreadId = info.getHolder();
29 if(clientThreadId == null) {
30 clientId = null;
31 threadId = null;
32 } else {
33 clientId = clientThreadId.getClientId().getInternalRep();
34 threadId = clientThreadId.getThreadId();
35 }
36 this.lockQueue = info.getLockQueue();
37 }
38
39 public UserLockInfo convert() {
40 ClientThreadId ctId;
41 if(clientId == null)
42 ctId = null;
43 else
44 ctId = new ClientThreadId(new ClientId(clientId),threadId);
45
46 return new UserLockInfo(new ID(id),ctId,lockQueue);
47 }
48 }