KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > registries > locks > JahiaLock


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 package org.jahia.registries.locks;
14
15 import java.util.Date JavaDoc;
16 import java.util.Hashtable JavaDoc;
17
18
19 /**
20  * @auhtor Fulco Houkes
21  * @version 1.0
22  */

23 class JahiaLock
24 {
25     private String JavaDoc mLockName;
26     private Hashtable JavaDoc mLockData;
27     private int mTimeout;
28     private long mExpirationTime;
29
30
31     //-------------------------------------------------------------------------
32
public JahiaLock (String JavaDoc name, Hashtable JavaDoc data, int timeout) {
33         mLockName = name;
34         mLockData = data;
35
36         mTimeout = timeout * 1000;
37             // timeout in seconds, but the mExpirationTime is in milliseconds.
38

39         resetTimeout();
40     }
41
42
43     //-------------------------------------------------------------------------
44
public final String JavaDoc getLockName () {
45         return mLockName;
46     }
47
48     //-------------------------------------------------------------------------
49
public final Hashtable JavaDoc getLockData () {
50         return mLockData;
51     }
52
53     //-------------------------------------------------------------------------
54
public final void setLockData (Hashtable JavaDoc data) {
55         mLockData = data;
56     }
57
58     //-------------------------------------------------------------------------
59
public final void resetTimeout () {
60         Date JavaDoc date = new Date JavaDoc();
61         mExpirationTime = date.getTime() + mTimeout;
62     }
63
64     //-------------------------------------------------------------------------
65
public boolean isValid () {
66         Date JavaDoc date = new Date JavaDoc();
67         return (date.getTime() < mExpirationTime);
68     }
69 }
70
Popular Tags