net.sf.farrago.server
Class FarragoAbstractServer

java.lang.Object
  extended by net.sf.farrago.server.FarragoAbstractServer
Direct Known Subclasses:
FarragoRmiJdbcServer, FarragoVjdbcServer

public abstract class FarragoAbstractServer
extends Object

FarragoAbstractServer is a common base for implementations of Farrago network servers.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/server/FarragoAbstractServer.java#10 $
Author:
John V. Sichi

Field Summary
protected  long connectionTimeoutMillis
           
protected  PrintWriter pw
           
protected static Registry rmiRegistry
           
protected  int rmiRegistryPort
           
protected  int singleListenerPort
           
 
Constructor Summary
protected FarragoAbstractServer()
          Creates a new FarragoServer instance, with console output to System.out.
protected FarragoAbstractServer(PrintWriter pw)
          Creates a new FarragoServer instance, with redirected console output.
 
Method Summary
protected  void configureNetwork(FarragoReleaseProperties releaseProps, FemFarragoConfig config)
           
protected  int getGroundReferences()
          Returns the number of ground references for this server.
 PrintWriter getPrintWriter()
           
protected  void locateRmiRegistry()
          Locates the RMI registry.
 void runConsole()
          Implements console interaction from stdin after the server has successfully started.
 void start(FarragoJdbcServerDriver jdbcDriver)
          Starts the server.
protected abstract  int startNetwork(FarragoJdbcServerDriver jdbcDriver)
          Starts the network.
 void stopHard()
          Stops the server, killing any sessions.
protected  void stopNetwork()
          Stops the network.
 boolean stopSoft()
          Stops the server if there are no sessions.
protected  void unbindRegistry()
          Unbinds all items remaining in the RMI registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rmiRegistry

protected static Registry rmiRegistry

pw

protected final PrintWriter pw

rmiRegistryPort

protected int rmiRegistryPort

singleListenerPort

protected int singleListenerPort

connectionTimeoutMillis

protected long connectionTimeoutMillis
Constructor Detail

FarragoAbstractServer

protected FarragoAbstractServer()
Creates a new FarragoServer instance, with console output to System.out. This constructor can be used to embed a FarragoServer inside of another container such as a J2EE app server.


FarragoAbstractServer

protected FarragoAbstractServer(PrintWriter pw)
Creates a new FarragoServer instance, with redirected console output. This constructor can be used to embed a FarragoAbstractServer inside of another container such as a J2EE app server.

Parameters:
pw - receives console output
Method Detail

configureNetwork

protected void configureNetwork(FarragoReleaseProperties releaseProps,
                                FemFarragoConfig config)

startNetwork

protected abstract int startNetwork(FarragoJdbcServerDriver jdbcDriver)
                             throws Exception
Starts the network.

Parameters:
jdbcDriver - the JDBC driver which will be served to remote clients
Returns:
network port on which server is configured to listen
Throws:
Exception

stopNetwork

protected void stopNetwork()
Stops the network. Default implementation is to call unbindRegistry, but subclasses can override.


locateRmiRegistry

protected void locateRmiRegistry()
Locates the RMI registry. RMI-based servers should use this during startNetwork after creating a registry.


unbindRegistry

protected void unbindRegistry()
Unbinds all items remaining in the RMI registry. RMI-based servers should use this in stopNetwork.


start

public void start(FarragoJdbcServerDriver jdbcDriver)
           throws Exception
Starts the server.

Parameters:
jdbcDriver - the JDBC driver which will be served to remote clients
Throws:
Exception

stopSoft

public boolean stopSoft()
Stops the server if there are no sessions.

Returns:
whether server was stopped

getGroundReferences

protected int getGroundReferences()
Returns the number of ground references for this server. Ground references are references pinned at startup time. For the base implementation of FarragoServer this is always 1. Farrago extensions, especially those that initialize resources via FarragoSessionFactory.specializedInitialization( FarragoAllocationOwner), may need to alter this value.

Returns:
the number of ground references for this server

stopHard

public void stopHard()
Stops the server, killing any sessions.


getPrintWriter

public PrintWriter getPrintWriter()
Returns:
redirected console output

runConsole

public void runConsole()
Implements console interaction from stdin after the server has successfully started.