com.threerings.presents.server
Class PresentsServer

java.lang.Object
  extended by com.threerings.presents.server.PresentsServer
Direct Known Subclasses:
CrowdServer, Rejector

public class PresentsServer
extends Object

The presents server provides a central point of access to the various facilities that make up the presents framework. To facilitate extension and customization, a single instance of the presents server should be created and initialized in a process. To facilitate easy access to the services provided by the presents server, static references to the various managers are made available in the PresentsServer class. These will be configured when the singleton instance is initialized.


Nested Class Summary
static class PresentsServer.PresentsModule
          Configures dependencies needed by the Presents services.
static class PresentsServer.PresentsServerModule
          Binds PresentsServer to a particular class.
 
Field Summary
protected  Invoker _authInvoker
          Used to invoke authentication tasks.
protected  ClientManager _clmgr
          The manager of clients.
protected  PresentsConnectionManager _conmgr
          The manager of network connections.
protected  DatagramChannelReader _datagramReader
           
protected  InvocationManager _invmgr
          The manager of invocation services.
protected  Invoker _invoker
          Used to invoke background tasks that should not be allowed to tie up the distributed object manager thread (generally talking to databases and other relatively slow entities).
protected  Lifecycle _lifecycle
          Handles orderly initialization and shutdown of our managers, etc.
protected  PresentsDObjectMgr _omgr
          The manager of distributed objects.
protected  ServerSocketChannelAcceptor _socketAcceptor
           
static InvocationManager invmgr
          Deprecated. 
static PresentsDObjectMgr omgr
          Deprecated. 
 
Constructor Summary
PresentsServer()
           
 
Method Summary
protected  AccessController createDefaultObjectAccessController()
          Defines the default object access policy for all DObject instances.
protected  ServerSocketChannelAcceptor createSocketAcceptor()
           
protected  String getBindHostname()
          Returns the hostname on which the connection manager will listen for TCP traffic, or null to bind to the wildcard address.
protected  String getDatagramHostname()
          Returns the hostname on which the connection will listen for datagram traffic, or null to bind to the wildcard address.
protected  int[] getDatagramPorts()
          Returns the ports on which the connection manager will listen for datagrams or an empty array if no datagrams are desired.
protected  int[] getListenPorts()
          Returns the port on which the connection manager will listen for client connections or an empty array to skip binding and have an external entity transfer accepted sockets into the connection manager.
 void init(com.google.inject.Injector injector)
          Initializes all of the server services and prepares for operation.
protected  void invokerDidShutdown()
          Called once the invoker and distributed object manager have both completed processing all remaining events and are fully shutdown.
static void main(String[] args)
          The default entry point for the server.
protected  void openToThePublic()
          Opens the server for connections after the event thread is running and all the invokers are clear after starting up.
 void queueShutdown()
          Queues up a request to shutdown on the event thread.
protected  void registerSignalHandlers(com.google.inject.Injector injector)
           
 void run()
          Starts up all of the server services and enters the main server event loop.
static void runServer(com.google.inject.Module... modules)
          Inits and runs the PresentsServer bound in the given modules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

omgr

@Deprecated
public static PresentsDObjectMgr omgr
Deprecated. 
Legacy static reference to the main distributed object manager. Don't use this. If you're writing a game, use PlaceManager._omgr.


invmgr

@Deprecated
public static InvocationManager invmgr
Deprecated. 
Legacy static reference to the invocation manager. Don't use this. If you're writing a game, use PlaceManager._invmgr.


_socketAcceptor

protected ServerSocketChannelAcceptor _socketAcceptor

_datagramReader

protected DatagramChannelReader _datagramReader

_omgr

@Inject
protected PresentsDObjectMgr _omgr
The manager of distributed objects.


_conmgr

@Inject
protected PresentsConnectionManager _conmgr
The manager of network connections.


_clmgr

@Inject
protected ClientManager _clmgr
The manager of clients.


_invmgr

@Inject
protected InvocationManager _invmgr
The manager of invocation services.


_lifecycle

@Inject
protected Lifecycle _lifecycle
Handles orderly initialization and shutdown of our managers, etc.


_invoker

@Inject
protected Invoker _invoker
Used to invoke background tasks that should not be allowed to tie up the distributed object manager thread (generally talking to databases and other relatively slow entities).


_authInvoker

@Inject
protected Invoker _authInvoker
Used to invoke authentication tasks.

Constructor Detail

PresentsServer

public PresentsServer()
Method Detail

runServer

public static void runServer(com.google.inject.Module... modules)
Inits and runs the PresentsServer bound in the given modules. This blocks until the server is shut down.


main

public static void main(String[] args)
The default entry point for the server.


init

public void init(com.google.inject.Injector injector)
          throws Exception
Initializes all of the server services and prepares for operation.

Throws:
Exception

registerSignalHandlers

protected void registerSignalHandlers(com.google.inject.Injector injector)

createSocketAcceptor

protected ServerSocketChannelAcceptor createSocketAcceptor()

run

public void run()
Starts up all of the server services and enters the main server event loop.


openToThePublic

protected void openToThePublic()
Opens the server for connections after the event thread is running and all the invokers are clear after starting up.


queueShutdown

public void queueShutdown()
Queues up a request to shutdown on the event thread. This method may be safely called from any thread.


createDefaultObjectAccessController

protected AccessController createDefaultObjectAccessController()
Defines the default object access policy for all DObject instances. The default default policy is to allow all subscribers but reject all modifications by the client.


getBindHostname

protected String getBindHostname()
Returns the hostname on which the connection manager will listen for TCP traffic, or null to bind to the wildcard address.


getDatagramHostname

protected String getDatagramHostname()
Returns the hostname on which the connection will listen for datagram traffic, or null to bind to the wildcard address.


getListenPorts

protected int[] getListenPorts()
Returns the port on which the connection manager will listen for client connections or an empty array to skip binding and have an external entity transfer accepted sockets into the connection manager.


getDatagramPorts

protected int[] getDatagramPorts()
Returns the ports on which the connection manager will listen for datagrams or an empty array if no datagrams are desired.


invokerDidShutdown

protected void invokerDidShutdown()
Called once the invoker and distributed object manager have both completed processing all remaining events and are fully shutdown. Note: this is called as the last act of the invoker on the invoker thread. In theory no other (important) threads are running, so thread safety should not be an issue, but be careful!