edu.UCL.xmiddle.host
Class SimpleLocalHost

java.lang.Object
  |
  +--edu.UCL.xmiddle.framework.host.Host
        |
        +--edu.UCL.xmiddle.host.UDPHost
              |
              +--edu.UCL.xmiddle.host.SimpleLocalHost
All Implemented Interfaces:
HostListener, LocalHost, java.lang.Runnable

public class SimpleLocalHost
extends UDPHost
implements LocalHost

SimpleLocalHost.java The SimpleLocalHost is essentially a Host which also services requests. Examples of requests include linking, reconciliation etc Created: Mon Jul 30 12:36:40 2001


Field Summary
 
Fields inherited from class edu.UCL.xmiddle.host.UDPHost
primaryID, secondaryID
 
Fields inherited from class edu.UCL.xmiddle.framework.host.Host
links
 
Constructor Summary
SimpleLocalHost(java.lang.String primaryID, java.lang.String secondaryID)
          Creates a new instance.
 
Method Summary
 void addHostListener(HostListener application)
          Registers a general HostListener with this LocalHost.
 void addHostListener(java.lang.Object primaryID, HostListener application)
          Registers a HostListener with this LocalHost.
 void exit()
          Signals that we are about to exit;
 void flushqueue()
          Clears the queue
 LinkTable getLinks()
          Returns the local host's linktable.
 java.lang.Object getPrimaryID()
          Returns the primary ID of the host
 java.lang.Object getSecondaryID()
          Returns the secondary ID of the host
 void hostInReach(Host host)
          Called by the Locator when it detects a new online host It traverses the list of HostListeners and notifies any hosts registered to receive online events for the given host.
 void hostOutOfReach(Host host)
          Called by the Locator when it detects a host going offline It traverses the list of HostListeners and notifies any hosts registered to receive offline events for the given host.
 void pause()
          Signals that we should stop servicing requests
 void queue(java.lang.Object[] request)
          Enqueue a request to be serviced
 void removeHostListener(HostListener application)
          Unregisters a HostListener with this localhost.
 void removeHostListener(java.lang.Object primaryID, HostListener application)
          Unregisters a HostListener for a given host with this localhost.
 void run()
          The SimpleLocalHost thread, when running, gets requests off the queue, and launches them onto a new ProtocolChooser thread
 void start()
          Starts servicing requests
 
Methods inherited from class edu.UCL.xmiddle.host.UDPHost
getAddress, getPort, getSegmentSize
 
Methods inherited from class edu.UCL.xmiddle.framework.host.Host
setLinks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleLocalHost

public SimpleLocalHost(java.lang.String primaryID,
                       java.lang.String secondaryID)
Creates a new instance.

Parameters:
primaryID - a String value
secondaryID - a String value
Method Detail

getSecondaryID

public java.lang.Object getSecondaryID()
Description copied from interface: LocalHost
Returns the secondary ID of the host

Specified by:
getSecondaryID in interface LocalHost
Overrides:
getSecondaryID in class UDPHost
Returns:
The secondary ID

getPrimaryID

public java.lang.Object getPrimaryID()
Description copied from interface: LocalHost
Returns the primary ID of the host

Specified by:
getPrimaryID in interface LocalHost
Overrides:
getPrimaryID in class UDPHost
Returns:
The primary ID

getLinks

public LinkTable getLinks()
Description copied from interface: LocalHost
Returns the local host's linktable.

Specified by:
getLinks in interface LocalHost
Overrides:
getLinks in class Host
Returns:
The LinkTable

exit

public void exit()
Signals that we are about to exit;

Specified by:
exit in interface LocalHost

pause

public void pause()
Signals that we should stop servicing requests

Specified by:
pause in interface LocalHost

start

public void start()
Starts servicing requests

Specified by:
start in interface LocalHost

run

public void run()
The SimpleLocalHost thread, when running, gets requests off the queue, and launches them onto a new ProtocolChooser thread

Specified by:
run in interface LocalHost

flushqueue

public void flushqueue()
Clears the queue

Specified by:
flushqueue in interface LocalHost

queue

public void queue(java.lang.Object[] request)
Enqueue a request to be serviced

Specified by:
queue in interface LocalHost
Parameters:
request - The request and its parameters

addHostListener

public void addHostListener(HostListener application)
Registers a general HostListener with this LocalHost. The HostListener will be notified when any host comes online or goes offline.

Specified by:
addHostListener in interface LocalHost
Parameters:
application - The HostListener to be notified.

addHostListener

public void addHostListener(java.lang.Object primaryID,
                            HostListener application)
Registers a HostListener with this LocalHost. The HostListener will be notified when a given host comes online or goes offline.

Specified by:
addHostListener in interface LocalHost
Parameters:
primaryID - The host, identified by its primary ID.
application - The HostListener to be notified.

removeHostListener

public void removeHostListener(HostListener application)
Unregisters a HostListener with this localhost.

Specified by:
removeHostListener in interface LocalHost
Parameters:
application - The HostListener not to be notified any more

removeHostListener

public void removeHostListener(java.lang.Object primaryID,
                               HostListener application)
Unregisters a HostListener for a given host with this localhost.

Specified by:
removeHostListener in interface LocalHost
Parameters:
primaryID - The host, identified by its primaryID
application - The object not to be notified any more

hostInReach

public void hostInReach(Host host)
Called by the Locator when it detects a new online host It traverses the list of HostListeners and notifies any hosts registered to receive online events for the given host. If no hosts are registered, it does nothing.

Specified by:
hostInReach in interface HostListener
Parameters:
host - The online host

hostOutOfReach

public void hostOutOfReach(Host host)
Called by the Locator when it detects a host going offline It traverses the list of HostListeners and notifies any hosts registered to receive offline events for the given host. If no hosts are registered, it does nothing.

Specified by:
hostOutOfReach in interface HostListener
Parameters:
host - The offline host