com.maverick.nio
Class Daemon

java.lang.Object
  extended by com.maverick.nio.Daemon

public abstract class Daemon
extends java.lang.Object

This class provides an abstract daemon for servicing any number of protocol contexts.

Author:
Lee David Painter

Constructor Summary
Daemon()
          Constructs the Daemon.
 
Method Summary
protected abstract  void configure(DaemonContext context)
          Called before the server is started so that you can configure the server to your own requirements.
 DaemonContext getContext()
          Get the context for this Daemon.
static java.util.Date getReleaseDate()
          Returns the release date of the current version.
static java.lang.String getVersion()
          Returns the current version of the API.
 boolean isStarted()
          Get whether the daemon is currently started
 boolean isStarting()
           
 void registerAcceptor(ClientAcceptor acceptor, java.nio.channels.ServerSocketChannel socketChannel)
          Register a client acceptor with the daemon.
 void registerConnector(ClientConnector connector, java.nio.channels.SocketChannel socketChannel)
          Register a client connector with the daemon.
 void registerHandler(SocketHandler handler, java.nio.channels.SelectableChannel channel)
          Register a socket handler with the daemon.
 void registerHandler(SocketHandler handler, java.nio.channels.SelectableChannel channel, SelectorThread thread)
          Register a socket handler with the daemon.
 void removeAcceptor(ListeningInterface li)
           
 void shutdown()
          Shutdown the server.
protected  boolean startListeningInterface(ListeningInterface li)
           
 boolean startup()
          Starts the daemon, first calling the #configure(ConfigurationContext) method to allow your server to configure itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Daemon

public Daemon()
Constructs the Daemon.

Method Detail

getContext

public DaemonContext getContext()
Get the context for this Daemon.

Returns:
DaemonContext

getVersion

public static java.lang.String getVersion()
Returns the current version of the API.


getReleaseDate

public static java.util.Date getReleaseDate()
Returns the release date of the current version.


isStarting

public boolean isStarting()

startup

public boolean startup()
                throws java.io.IOException
Starts the daemon, first calling the #configure(ConfigurationContext) method to allow your server to configure itself.

Returns:
true if at least one interface started, otherwise false.
Throws:
java.io.IOException

startListeningInterface

protected boolean startListeningInterface(ListeningInterface li)
                                   throws java.io.IOException
Throws:
java.io.IOException

removeAcceptor

public void removeAcceptor(ListeningInterface li)

isStarted

public boolean isStarted()
Get whether the daemon is currently started

Returns:
started

shutdown

public void shutdown()
Shutdown the server. This does not exit the JVM


registerConnector

public void registerConnector(ClientConnector connector,
                              java.nio.channels.SocketChannel socketChannel)
                       throws java.io.IOException
Register a client connector with the daemon.

Parameters:
connector - ClientConnector
socketChannel - SocketChannel
Throws:
java.io.IOException

registerAcceptor

public void registerAcceptor(ClientAcceptor acceptor,
                             java.nio.channels.ServerSocketChannel socketChannel)
                      throws java.io.IOException
Register a client acceptor with the daemon.

Parameters:
acceptor - ClientAcceptor
socketChannel - ServerSocketChannel
Throws:
java.io.IOException

registerHandler

public void registerHandler(SocketHandler handler,
                            java.nio.channels.SelectableChannel channel)
                     throws java.io.IOException
Register a socket handler with the daemon.

Parameters:
handler - SocketHandler
channel - SelectableChannel
Throws:
java.io.IOException

registerHandler

public void registerHandler(SocketHandler handler,
                            java.nio.channels.SelectableChannel channel,
                            SelectorThread thread)
                     throws java.io.IOException
Register a socket handler with the daemon.

Parameters:
handler - SocketHandler
channel - SelectableChannel
thread - SelectorThread
Throws:
java.io.IOException

configure

protected abstract void configure(DaemonContext context)
                           throws java.io.IOException
Called before the server is started so that you can configure the server to your own requirements.

Parameters:
context -
Throws:
java.io.IOException


Copyright © 2003-2008 SSHTools LTD. All Rights Reserved.