jxl.jxta
Class LeaseManager

java.lang.Object
  extended by jxl.jxta.LeaseManager
All Implemented Interfaces:
java.lang.Runnable

public final class LeaseManager
extends java.lang.Object
implements java.lang.Runnable

Helper class to manage the publication of a jxta Advertisement. LeaseManger will publish a supplied Advertisement at a regular intervole specified in the constructor. This allows the Advertisement (and the service it describres) to have a small lifetime, so that it will disapear quickly when it is gone.

Author:
Alex Lynch

Field Summary
static long MIN_LEASE_TIME
          The minimum lease time that may be given the the LeaseManager
 
Constructor Summary
LeaseManager(net.jxta.peergroup.PeerGroup group, net.jxta.document.Advertisement adv, long lease, java.lang.Object referent)
          Creates a new instance of LeaseManager.
 
Method Summary
 void run()
           
 void start()
           
 void stop()
          Stop the publication thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_LEASE_TIME

public static final long MIN_LEASE_TIME
The minimum lease time that may be given the the LeaseManager

See Also:
Constant Field Values
Constructor Detail

LeaseManager

public LeaseManager(net.jxta.peergroup.PeerGroup group,
                    net.jxta.document.Advertisement adv,
                    long lease,
                    java.lang.Object referent)
Creates a new instance of LeaseManager. referent will be stored internally by weak reference. When the weak reference is cleared (meaning referent has been cleared by the gc) The LeaseManager will stop publishing the advertisement and its thread will exit. Thus best practice is to supply a reference to the service that adv represents as the referent.

Parameters:
group - The PeerGroup to publish the adv in.
adv - The Advertisement to publish
lease - The time between publications.
referent - Object to reference.
Method Detail

stop

public void stop()
Stop the publication thread. It should be possible to restart the thread after a stop but that will depend on the state of the thread.


start

public void start()

run

public void run()
Specified by:
run in interface java.lang.Runnable