com.arsdigita.mail
Class SimpleServer

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.arsdigita.mail.SimpleServer
All Implemented Interfaces:
Runnable, com.arsdigita.mail.ServerModes

public class SimpleServer
extends Thread
implements com.arsdigita.mail.ServerModes

A simple SMTP server for testing the ACS Mail service. This class provides one method, SimpleServer.startup(), that starts SMTP servers running on a range of ports on the local host. By default it redirects all mail traffic to the server running in NORMAL mode.

Using the SimpleServer.setMode() method, clients can force connections to any of the available servers running in that particular testing mode. The server threads are maintained statically, so additional calls to startup() are simply ignored.

Only the following SMTP operating modes are supported. Use these constants as the argument to setMode() to redirect SMTP traffic to the appropriate server.

Version:
$Id: //core-platform/dev/src/com/arsdigita/mail/SimpleServer.java#12 $
Author:
Ron Henderson, Joseph Bank, Stefan Deusch

Field Summary
static int HANGING
           
static int INSUFFICIENTMEM
           
static int INTERRUPT
           
static int NORMAL
           
static int SYNTAXERROR
           
static int TRANSACTIONABORT
           
static int TRANSACTIONFAILED
           
static int UNAVAILABLE
           
static int UNRECOGNIZEDCMD
           
static int UNSUPPORTEDMETH
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
static int getReceivedCount()
          Gets the number of messages received.
static int getSuccessCount()
          Gets the number of succesfully processed connections to any SimpleServer.
static void reset()
          Resets the counters of received and successful messages.
 void run()
          The run method for SimpleServer.
static void setMode(int mode)
          Configures the mail system to communicate with the correct server.
static void startup()
          Initializes the SimpleServer system.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

INTERRUPT

public static final int INTERRUPT
See Also:
Constant Field Values

HANGING

public static final int HANGING
See Also:
Constant Field Values

UNAVAILABLE

public static final int UNAVAILABLE
See Also:
Constant Field Values

TRANSACTIONABORT

public static final int TRANSACTIONABORT
See Also:
Constant Field Values

INSUFFICIENTMEM

public static final int INSUFFICIENTMEM
See Also:
Constant Field Values

UNRECOGNIZEDCMD

public static final int UNRECOGNIZEDCMD
See Also:
Constant Field Values

SYNTAXERROR

public static final int SYNTAXERROR
See Also:
Constant Field Values

UNSUPPORTEDMETH

public static final int UNSUPPORTEDMETH
See Also:
Constant Field Values

TRANSACTIONFAILED

public static final int TRANSACTIONFAILED
See Also:
Constant Field Values
Method Detail

getSuccessCount

public static int getSuccessCount()
Gets the number of succesfully processed connections to any SimpleServer.

Returns:
the number of succesfully processed connections to any SimpleServer.

getReceivedCount

public static int getReceivedCount()
Gets the number of messages received.

Returns:
the number of messages.

reset

public static void reset()
Resets the counters of received and successful messages.


startup

public static void startup()
Initializes the SimpleServer system. Starts a listener for each type of server operating mode on a specific port. If any servers fail to initialize (usually because the port is busy), the entire system will fail and report the error.


setMode

public static void setMode(int mode)
Configures the mail system to communicate with the correct server. After calling this method, the next message sent using Mail.send() will connect to the appropriate server for requested responsee mode.


run

public void run()
The run method for SimpleServer. This accepts a connection on the specified port and hands the Socket to a SocketHandler for processing.

Specified by:
run in interface Runnable


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC