com.goldeninnovations.smp
Class SMPServer

java.lang.Object
  extended by com.goldeninnovations.smp.SMPServer
All Implemented Interfaces:
SMPServerMBean, com.goldeninnovations.smp.smtp.ConnectionListener

public class SMPServer
extends Object
implements SMPServerMBean, com.goldeninnovations.smp.smtp.ConnectionListener

Simple Message Processor Server


Constructor Summary
SMPServer(MessageProcessor messageProcessor)
           
SMPServer(MessageSpool spool, MessageFilter filter, MessageProcessor processor)
           
 
Method Summary
 void connectionClosed(com.goldeninnovations.smp.smtp.Connection connection)
          Remove closed Connections from the connectionMap
 int getCurrentConnectionCount()
          The number of open connections
 MessageFilter getMessageFilter()
           
 MessageProcessor getMessageProcessor()
           
 MessageSpool getMessageSpool()
          The MessageSpool currently being used.
 long getTotalConnectionCount()
          The total number of connections made to SMPServer
 void setMessageFilter(MessageFilter messageFilter)
           
 void setMessageProcessor(MessageProcessor messageProcessor)
           
 void setMessageSpool(MessageSpool messageSpool)
          Sets the MessageSpool to use.
 void setPort(int port)
          Sets the port that the Server will listen to SMTP connections on.
 void startServer()
          Starts the Server.
 void stopServer()
          Stops the server and waits for the thread to end.
 void stopServer(long millis)
          Stops the server and waits for the thread to end.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMPServer

public SMPServer(MessageProcessor messageProcessor)

SMPServer

public SMPServer(MessageSpool spool,
                 MessageFilter filter,
                 MessageProcessor processor)
Method Detail

setPort

public void setPort(int port)
Sets the port that the Server will listen to SMTP connections on. Default value is 25.

Must be set before calling start().

Parameters:
port - the port the server will listen on.

getMessageSpool

public MessageSpool getMessageSpool()
The MessageSpool currently being used.

Returns:
the current MessageSpool

setMessageSpool

public void setMessageSpool(MessageSpool messageSpool)
Sets the MessageSpool to use.

Parameters:
messageSpool - the MessageSpool to use.

getMessageFilter

public MessageFilter getMessageFilter()

setMessageFilter

public void setMessageFilter(MessageFilter messageFilter)

getMessageProcessor

public MessageProcessor getMessageProcessor()

setMessageProcessor

public void setMessageProcessor(MessageProcessor messageProcessor)

getCurrentConnectionCount

public int getCurrentConnectionCount()
Description copied from interface: SMPServerMBean
The number of open connections

Specified by:
getCurrentConnectionCount in interface SMPServerMBean
Returns:
the number of open connections.

getTotalConnectionCount

public long getTotalConnectionCount()
Description copied from interface: SMPServerMBean
The total number of connections made to SMPServer

Specified by:
getTotalConnectionCount in interface SMPServerMBean
Returns:
the total number of connections accepted.

startServer

public void startServer()
                 throws IOException
Starts the Server. Attempts to open port to listen for incoming connections and starts the processing thread.

This method returns as soon as the server is started.

Specified by:
startServer in interface SMPServerMBean
Throws:
IOException - thrown if the server was unable to open the specified port.

stopServer

public void stopServer()
                throws InterruptedException
Stops the server and waits for the thread to end.

Specified by:
stopServer in interface SMPServerMBean
Throws:
InterruptedException - thrown if interrupted while waiting for the server thread to end.

stopServer

public void stopServer(long millis)
                throws InterruptedException
Stops the server and waits for the thread to end.

Parameters:
millis - the time to wait for each inner thread to stop in milliseconds.
Throws:
InterruptedException - thrown if interrupted while waiting for the server thread to end.

connectionClosed

public void connectionClosed(com.goldeninnovations.smp.smtp.Connection connection)
Remove closed Connections from the connectionMap

Specified by:
connectionClosed in interface com.goldeninnovations.smp.smtp.ConnectionListener
Parameters:
connection - the connection that closed.


Copyright © 2010 Eric Daugherty. All Rights Reserved.