ar.com.ktulu.dict
Class Server

java.lang.Object
  |
  +--ar.com.ktulu.dict.Server

public class Server
extends java.lang.Object

DICT Server as defined in RFC 2229. It parses initialization arguments supplied by the user and creates an instance of ServerThread for each connection. It also manages the list of Databases and Strategies known.

Author:
Luis Parravicini
See Also:
ServerThread, Strategy, Database

Field Summary
(package private)  java.util.Vector connections
           
(package private)  java.util.LinkedList dbs
          Dictionaries.
(package private)  int delay
          Maximum number of seconds a connection can be idle.
(package private)  java.util.Hashtable hash_dbs
           
(package private)  int maxConns
          Maximun number of simultaneously open connections.
(package private)  int queue
          Queue length for incoming connections.
(package private)  long startup
           
(package private)  java.util.Hashtable strategies
           
 
Constructor Summary
Server()
          Uses default values for arguments.
Server(java.lang.String[] args)
           
 
Method Summary
protected  boolean addConnection(java.net.Socket s)
          Creates a new ServerThread and adds it to the list of open connections
 java.util.Iterator databases()
           
 int databaseSize()
           
protected  java.lang.String ensureLength(java.lang.String s, int l)
          Returns a new string with minimum length l.
protected  java.lang.String getConfBaseDir()
          Returns the default base dir for the configuration files.
 Database getDatabase(java.lang.String name)
           
protected  java.util.Properties getDefaultConfig()
          Returns default values for configuration parameters.
 Strategy getStrategy(java.lang.String name)
           
protected  void initStrategies(java.lang.String conf)
           
 boolean isLogging()
           
 void loginfo(java.lang.String s)
           
static void main(java.lang.String[] args)
           
protected  java.util.Properties processCL(java.lang.String[] args)
          Parses command line arguments
protected  boolean propIsNumber(java.util.Properties props, java.lang.String name)
           
protected  void readConfig(java.lang.String conf)
          Parses dictd.conf and initializes the databases defined in it.
protected  org.w3c.dom.Document readDOMDocument(java.lang.String fname)
           
 void removeConnection(ServerThread st)
          Used by ServerThread when the connection is closed to notify the server that this connection is no longer open.
 void run()
           
 java.util.Iterator strategies()
           
 int strategiesSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbs

java.util.LinkedList dbs
Dictionaries.


hash_dbs

java.util.Hashtable hash_dbs

strategies

java.util.Hashtable strategies

maxConns

int maxConns
Maximun number of simultaneously open connections.


connections

java.util.Vector connections

queue

int queue
Queue length for incoming connections.


delay

int delay
Maximum number of seconds a connection can be idle.


startup

long startup
Constructor Detail

Server

public Server()
       throws java.io.IOException,
              java.lang.ClassNotFoundException,
              java.lang.IllegalAccessException,
              java.lang.InstantiationException
Uses default values for arguments.


Server

public Server(java.lang.String[] args)
       throws java.io.IOException,
              java.lang.ClassNotFoundException,
              java.lang.IllegalAccessException,
              java.lang.InstantiationException
Method Detail

isLogging

public boolean isLogging()

loginfo

public void loginfo(java.lang.String s)

getConfBaseDir

protected java.lang.String getConfBaseDir()
Returns the default base dir for the configuration files.


ensureLength

protected java.lang.String ensureLength(java.lang.String s,
                                        int l)
Returns a new string with minimum length l. If the length of s is shorter than l, spaces are added at the end of s.


processCL

protected java.util.Properties processCL(java.lang.String[] args)
Parses command line arguments


propIsNumber

protected boolean propIsNumber(java.util.Properties props,
                               java.lang.String name)

getDefaultConfig

protected java.util.Properties getDefaultConfig()
Returns default values for configuration parameters. See dictd(8) for the explanation of each.


initStrategies

protected void initStrategies(java.lang.String conf)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException,
                              java.lang.IllegalAccessException,
                              java.lang.InstantiationException
java.io.IOException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException

readDOMDocument

protected org.w3c.dom.Document readDOMDocument(java.lang.String fname)
                                        throws java.io.IOException,
                                               org.xml.sax.SAXException,
                                               javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

readConfig

protected void readConfig(java.lang.String conf)
                   throws java.io.IOException
Parses dictd.conf and initializes the databases defined in it.

java.io.IOException

getDatabase

public Database getDatabase(java.lang.String name)

databaseSize

public int databaseSize()

databases

public java.util.Iterator databases()

getStrategy

public Strategy getStrategy(java.lang.String name)

strategiesSize

public int strategiesSize()

strategies

public java.util.Iterator strategies()

addConnection

protected boolean addConnection(java.net.Socket s)
Creates a new ServerThread and adds it to the list of open connections

See Also:
ServerThread

removeConnection

public void removeConnection(ServerThread st)
Used by ServerThread when the connection is closed to notify the server that this connection is no longer open.

See Also:
ServerThread

run

public void run()

main

public static void main(java.lang.String[] args)
                 throws java.util.NoSuchElementException,
                        java.lang.IllegalAccessException,
                        java.lang.InstantiationException
java.util.NoSuchElementException
java.lang.IllegalAccessException
java.lang.InstantiationException