diff src/org/dancres/blitz/remote/view/ViewLeaseHandlerImpl.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/dancres/blitz/remote/view/ViewLeaseHandlerImpl.java	Sat Mar 21 11:00:06 2009 +0000
@@ -0,0 +1,46 @@
+package org.dancres.blitz.remote.view;
+
+import java.io.IOException;
+
+import net.jini.core.lease.UnknownLeaseException;
+import net.jini.core.lease.LeaseDeniedException;
+
+import org.dancres.blitz.lease.SpaceUID;
+import org.dancres.blitz.lease.LeaseHandler;
+import org.dancres.blitz.lease.LeaseBounds;
+
+import org.dancres.blitz.util.Time;
+
+public class ViewLeaseHandlerImpl implements LeaseHandler {
+    public boolean recognizes(SpaceUID aUID) {
+        return (aUID instanceof EntryViewUID);
+    }
+
+    public long renew(SpaceUID aUID, long aLeaseDuration)
+        throws UnknownLeaseException, LeaseDeniedException, IOException {
+
+        long myDuration = LeaseBounds.boundView(aLeaseDuration);
+        long myExpiry = Time.getAbsoluteTime(myDuration);
+
+        boolean myResult;
+
+        myResult = EntryViewFactory.get().renew((EntryViewUID) aUID,
+                                                myExpiry);
+
+        if (!myResult)
+            throw new UnknownLeaseException();
+
+        return myDuration;
+    }
+
+    public void cancel(SpaceUID aUID)
+        throws UnknownLeaseException, IOException {
+
+        boolean myResult;
+
+        myResult = EntryViewFactory.get().cancel((EntryViewUID) aUID);
+
+        if (!myResult)
+            throw new UnknownLeaseException();
+    }
+}