jhomenet.server.console
Class ConsoleService

java.lang.Object
  extended by AbstractExecutableThreadService
      extended by jhomenet.server.console.ConsoleService
Direct Known Subclasses:
LocalConsoleService

public abstract class ConsoleService
extends AbstractExecutableThreadService

A service that is responsible for reading user input from the server console.

Id: $Id: $

Author:
Dave Irwin (jhomenet at gmail dot com)

Field Summary
protected  AuthManager authManager
          Reference to the authentication manager.
static java.lang.String ENV_HARDWAREMANAGER
          Known console environment object keys.
static java.lang.String ENV_WORKQUEUE
           
protected  java.util.ArrayList<Session> sessions
          List of sessions created by this service.
 
Constructor Summary
ConsoleService(java.lang.Boolean displayConsole, AuthManager authManager, PluginContext pluginContext, ServerContext serverContext)
           
 
Method Summary
protected abstract  Session acceptNewSession(IWorkQueue workQueue)
          Waits for a connection request.
protected  void checkForNewSessions()
          Listens for connection requests.
 void executeImpl()
          Execute the service.
 java.lang.String getServiceName()
           
 void serviceIsInitializing()
          This method is called by the service manager notifying this class (or service) that the service is initializing.
 void serviceIsStopping()
          This method is called by the service manager notifying this class (or service) that the service is about to stop.
 void sessionEnded(Session session)
          Notifies this server that a particular session is ending.
protected abstract  void sessionEndedInternal(Session session)
          Notify the implementing service class that a session has ended.
 void setDisplayConsole(java.lang.Boolean displayConsole)
           
 boolean shouldStartOnStartup()
           
 void shutDown()
          Requests that the server stop taking connections and terminate any current sessions.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sessions

protected final java.util.ArrayList<Session> sessions
List of sessions created by this service.


authManager

protected final AuthManager authManager
Reference to the authentication manager.


ENV_HARDWAREMANAGER

public static final java.lang.String ENV_HARDWAREMANAGER
Known console environment object keys. Use these keys to access actual objects from the environmentObjects map.

See Also:
Constant Field Values

ENV_WORKQUEUE

public static final java.lang.String ENV_WORKQUEUE
See Also:
Constant Field Values
Constructor Detail

ConsoleService

public ConsoleService(java.lang.Boolean displayConsole,
                      AuthManager authManager,
                      PluginContext pluginContext,
                      ServerContext serverContext)
Parameters:
loginService -
pluginContext -
serverContext -
serverConfiguration -
Method Detail

shouldStartOnStartup

public boolean shouldStartOnStartup()
See Also:
jhomenet.commons.service.IExecutableService#shouldStartOnStartup()

serviceIsInitializing

public void serviceIsInitializing()
This method is called by the service manager notifying this class (or service) that the service is initializing. This gives the service a chance to do any initializing before the service is actually started.

See Also:
jhomenet.commons.service.AbstractExecutableThreadService#serviceIsInitializing()

executeImpl

public void executeImpl()
Execute the service. This method will be run in a seperate thread.

See Also:
jhomenet.commons.service.AbstractExecutableThreadService#execute()

serviceIsStopping

public void serviceIsStopping()
This method is called by the service manager notifying this class (or service) that the service is about to stop. This gives the service a chance to do any last minute cleanup before the service is actually stopped.

See Also:
jhomenet.commons.service.AbstractExecutableThreadService#serviceIsStopping()

getServiceName

public java.lang.String getServiceName()
See Also:
jhomenet.commons.service.IService#getServiceName()

checkForNewSessions

protected void checkForNewSessions()
Listens for connection requests. This method blocks until a request is received. Once the new session is created, it is added to the list of known sessions.


acceptNewSession

protected abstract Session acceptNewSession(IWorkQueue workQueue)
                                     throws java.lang.InterruptedException
Waits for a connection request. This method should block until a request is received. When a request is made, it should create, initialize, and return a new Session to handle that connection.

Returns:
a new Session
Throws:
java.lang.InterruptedException

setDisplayConsole

public final void setDisplayConsole(java.lang.Boolean displayConsole)
Parameters:
displayConsole - the displayConsole to set

shutDown

public void shutDown()
Requests that the server stop taking connections and terminate any current sessions. Cycles through the list of known sessions, closing down each one and then cleaning up its own system resources.


sessionEnded

public void sessionEnded(Session session)
Notifies this server that a particular session is ending. Removes the closing session from the list of known sessions.

Parameters:
session - the session that has terminated

sessionEndedInternal

protected abstract void sessionEndedInternal(Session session)
Notify the implementing service class that a session has ended.

Parameters:
session - The session that has ended

toString

public java.lang.String toString()
See Also:
Object.toString()


Copyright © 2004-2007 David Irwin. All Rights Reserved.