com.solers.slp
Class ServiceLocationEnumerationImpl

java.lang.Object
  |
  +--com.solers.slp.ServiceLocationEnumerationImpl
All Implemented Interfaces:
Enumeration, ServiceLocationEnumeration

class ServiceLocationEnumerationImpl
extends Object
implements ServiceLocationEnumeration

Implements the ServiceLocationEnumeration interface defined in RFC 2614.

Author:
Patrick Callis

Field Summary
private  SLPConfiguration _conf
           
private  Vector _delivered
           
private  short _errorCode
          Holds the errorCode from the last response
private  int _maxWait
          Max time to wait for response to UA message
private  UAMessage _message
           
private  NetworkManager _net
           
private  Vector _received
           
private  boolean _requested
          Used to remember if we've asked for responses yet.
private  int[] _retry
          Array of timeout values read from configuration
private  DatagramSocket _uaSock
          Datagram socket for UA messages
private  org.apache.log4j.Category cat
          Default Logging category
private  ByteArrayOutputStream uaBos
          Used for writing UA messages
private  DataOutputStream uaDos
          Wrapper for ByteArrayOutputStream
 
Constructor Summary
(package private) ServiceLocationEnumerationImpl(NetworkManager net, UAMessage message)
           
 
Method Summary
 void destroy()
          Frees resources allocated by this enumeration.
 boolean hasMoreElements()
          Returns whether more responses exist.
 Object next()
          Returns the next SLP response received.
 Object nextElement()
           
private  short parseResponse(byte[] buf)
          Parses a datagram packet's buffer, adding responses to the list of received values.
(package private)  short readResponse()
          Listens for a response to a UA message.
private  void removeDups()
          Removes duplicate entries from the list of responses.
private  void transmitDatagram()
          Performs the actual transmission of a UA message.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

cat

private org.apache.log4j.Category cat
Default Logging category

_conf

private SLPConfiguration _conf

_net

private NetworkManager _net

_message

private UAMessage _message

uaBos

private ByteArrayOutputStream uaBos
Used for writing UA messages

uaDos

private DataOutputStream uaDos
Wrapper for ByteArrayOutputStream

_uaSock

private DatagramSocket _uaSock
Datagram socket for UA messages

_retry

private int[] _retry
Array of timeout values read from configuration

_maxWait

private int _maxWait
Max time to wait for response to UA message

_received

private Vector _received

_delivered

private Vector _delivered

_requested

private boolean _requested
Used to remember if we've asked for responses yet. If this is a unicast request, don't wait for more than one response.

_errorCode

private short _errorCode
Holds the errorCode from the last response
Constructor Detail

ServiceLocationEnumerationImpl

ServiceLocationEnumerationImpl(NetworkManager net,
                               UAMessage message)
                         throws ServiceLocationException
Method Detail

next

public Object next()
            throws ServiceLocationException
Returns the next SLP response received.
Specified by:
next in interface ServiceLocationEnumeration
Throws:
ServiceLocationException - if an error is received.
java.util.NoSuchElementException - if no more responses.

hasMoreElements

public boolean hasMoreElements()
Returns whether more responses exist. In order to allow clients to only block for responses they want, this method must try to receive more responses if none are queued.
Specified by:
hasMoreElements in interface Enumeration

nextElement

public Object nextElement()
Specified by:
nextElement in interface Enumeration
See Also:
next()

transmitDatagram

private void transmitDatagram()
                       throws IOException
Performs the actual transmission of a UA message.

readResponse

short readResponse()
             throws IOException
Listens for a response to a UA message. The message may be retransmitted if necessary. This method implements the multicast convergence algorithm described in RFC 2608.

removeDups

private void removeDups()
Removes duplicate entries from the list of responses.

parseResponse

private short parseResponse(byte[] buf)
                     throws IOException
Parses a datagram packet's buffer, adding responses to the list of received values.

destroy

public void destroy()
Frees resources allocated by this enumeration.
Specified by:
destroy in interface ServiceLocationEnumeration