Alachisoft.NCache.Common.LockOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
package Alachisoft.NCache.Common;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
import com.alachisoft.ncache.runtime.util.NCDateTime;
import com.alachisoft.ncache.runtime.util.TimeSpan;
import com.alachisoft.ncache.serialization.core.io.ICompactSerializable;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectInput;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectOutput;
import java.io.IOException;
import java.util.Date;
//#if VS2005
//#else
//#endif
/**
* Provides options for locking.
*/
public final class LockOptions implements ICompactSerializable {
private Object _lockId;
private java.util.Date _lockDate = new java.util.Date(0);
private TimeSpan _lockAge = new TimeSpan();
public LockOptions() {
try {
NCDateTime time = new NCDateTime(1970, 1, 1, 0, 0, 0, 0);
_lockDate = time.getDate();
} catch (Exception e) {
}
}
public LockOptions(Object lockId, java.util.Date lockDate) {
this._lockId = lockId;
this._lockDate = lockDate;
}
/**
* Gets or Sets a unique lock value for a cache key.
*/
public Object getLockId() {
return _lockId;
}
public void setLockId(Object value) {
_lockId = value;
}
/**
* The DateTime when this lock was acquired on the cachekey. This DateTime is set on the cache server not on the web server.
*/
public java.util.Date getLockDate() {
return _lockDate;
}
public void setLockDate(java.util.Date value) {
_lockDate = value;
}
/**
* The lock Age of the current lock. This is computed on the cache server are returned to the client.
*/
public TimeSpan getLockAge() {
return _lockAge;
}
public void setLockAge(TimeSpan value) {
_lockAge = value;
}
@Override
public void serialize(NCacheObjectOutput writer) throws IOException {
writer.writeObject(_lockId);
writer.writeObject(_lockDate);
writer.writeObject(_lockAge);
}
@Override
public void deserialize(NCacheObjectInput reader) throws IOException, ClassNotFoundException {
_lockId = reader.readObject();
_lockDate = (Date) reader.readObject();
_lockAge = (TimeSpan) reader.readObject();
}
}