SK.gnome.dwarf.utils.dns
Class DNSService

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.utils.dns.DNSService
All Implemented Interfaces:
Service

public class DNSService
extends GenericService

This is a service for the DNS name lookups.

The DNS server address must be set via the setServer(InetAddress) method prior to initializing this service.


Field Summary
protected  java.net.InetAddress server
          The DNS server address.
protected  boolean stream
          Whether the TCP will be used instead of the default UDP.
protected  int timeout
          The DNS query timeout in seconds.
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
DNSService(java.lang.String name)
          Creates a new DNSService.
 
Method Summary
 void init(Server parent)
          Initializes the service.
 Message query(Question question)
          Performs a DNS query.
 void setServer(java.net.InetAddress server)
          Sets the DNS server.
 void setStream(boolean enable)
          Sets whether the TCP will be used instead of the UDP.
 void setTimeout(int timeout)
          Sets the query timeout.
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, shutdown, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

server

protected java.net.InetAddress server
The DNS server address.

See Also:
setServer(InetAddress)

timeout

protected int timeout
The DNS query timeout in seconds.

Default value: DNSClient.DEFAULT_LOOKUP_TIMEOUT

See Also:
setTimeout(int)

stream

protected boolean stream
Whether the TCP will be used instead of the default UDP.

See Also:
setStream(boolean)
Constructor Detail

DNSService

public DNSService(java.lang.String name)
Creates a new DNSService.

Method Detail

setServer

public void setServer(java.net.InetAddress server)
Sets the DNS server.

Parameters:
server - the DNS server
See Also:
server

setTimeout

public void setTimeout(int timeout)
Sets the query timeout.

Parameters:
timeout - the query timeout in seconds
See Also:
timeout

setStream

public void setStream(boolean enable)
Sets whether the TCP will be used instead of the UDP.

Parameters:
enable - true to enable TCP connections
See Also:
stream

init

public void init(Server parent)
          throws ServiceException
Description copied from interface: Service
Initializes the service.

This method changes the service state to Service.INITIALIZED.

If the parent argument is not null, it means that the service is becomig a part of the server which the parent argument points to.

After a successful initialization the service can be started by invoking the Service.start() method, or it can be shut down by invoking the Service.shutdown() method.

Specified by:
init in interface Service
Overrides:
init in class GenericService
Throws:
ServiceException

query

public Message query(Question question)
              throws java.io.IOException
Performs a DNS query.

Parameters:
question - the DNS query
Returns:
the DNS answer message
Throws:
java.io.IOException - if an error occurs


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.