edu.cuny.cat.server
Class GameController

java.lang.Object
  extended by java.util.Observable
      extended by edu.cuny.cat.server.GameController
All Implemented Interfaces:
AuctionEventListener, edu.cuny.config.param.Parameterizable

public final class GameController
extends java.util.Observable
implements edu.cuny.config.param.Parameterizable, AuctionEventListener

A class used at GameServer as a control hub, initializing various components, event passing, etc.

The game console and clock controller configured should match to support different ways of running cat games.

Parameters

base.registry
class, implementing Registry
(the type of registry facility to restore game activities for run-time access)
base.console
class, implementing Console
(the console for user to control the game)
base.clockcontroller
class, implementing ClockController
(the way to control the game clock, including how to start and stop the clock)
base.report
class, implementing GameReport
(the type of report facility to log game activities)
base.gc
boolean (false by default)
(whether running garbage collector following DayClosedEvent)
base.logging
boolean (true by default)
(whether to allow log globally, used by some reports only)

Version:
$Revision: 1.64 $
Author:
Jinzhong Niu

Field Summary
protected  ClientBehaviorController behaviorController
           
protected  ChargeValidator chargeValidator
           
protected  GameClock clock
           
protected  ClockController clockController
           
protected  ConnectionManager connManager
           
protected  Console console
           
protected  boolean dailyGC
           
protected  ClientIdentityController identityController
           
protected static GameController instance
           
static java.lang.String P_CONSOLE
           
static java.lang.String P_GC
           
static java.lang.String P_LOGGING
           
static java.lang.String P_REGISTRY
           
static java.lang.String P_REPORT
           
protected  Registry registry
           
protected  GameReport report
           
protected  SecurityManager securityManager
           
protected  ShoutValidator shoutValidator
           
protected  boolean showWinnerList
           
protected  TimeoutController timeoutController
           
protected  TransactionValidator transactionValidator
           
protected  ValuerFactory valuerFactory
           
 
Constructor Summary
GameController()
           
 
Method Summary
 void addReport(GameReport newReport)
           
 void dispose()
           
 void eventOccurred(AuctionEvent event)
          listens to game clock's notifications
 void exit()
           
 ClientBehaviorController getBehaviorController()
           
 ChargeValidator getChargeValidator()
           
 GameClock getClock()
           
 ClockController getClockController()
           
 ConnectionManager getConnectionManager()
           
 Console getConsole()
           
static GameController getInstance()
           
 Registry getRegistry()
           
 GameReport getReport()
           
<R extends GameReport>
R
getReport(java.lang.Class<R> reportClass)
           
 SecurityManager getSecurityManager()
           
 ShoutValidator getShoutValidator()
           
 TimeoutController getTimeController()
           
 TransactionValidator getTransactionValidator()
           
 ValuerFactory getValuerFactory()
           
 void initialize()
          to initialize the game controller and make the server ready for clients to check in.
protected  void notifyInsideListener(AuctionEventListener listener, AuctionEvent event)
          notifies a listener of an auction event.
 void processEventInsideServer(AuctionEvent event)
          sends auction events to registry, console, and reports.
 void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
           
 void start()
          to start the game.
 void stop()
          to stop the game.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P_REGISTRY

public static final java.lang.String P_REGISTRY
See Also:
Constant Field Values

P_CONSOLE

public static final java.lang.String P_CONSOLE
See Also:
Constant Field Values

P_REPORT

public static final java.lang.String P_REPORT
See Also:
Constant Field Values

P_LOGGING

public static final java.lang.String P_LOGGING
See Also:
Constant Field Values

P_GC

public static final java.lang.String P_GC
See Also:
Constant Field Values

connManager

protected ConnectionManager connManager

timeoutController

protected TimeoutController timeoutController

registry

protected Registry registry

instance

protected static GameController instance

clock

protected GameClock clock

clockController

protected ClockController clockController

shoutValidator

protected ShoutValidator shoutValidator

transactionValidator

protected TransactionValidator transactionValidator

chargeValidator

protected ChargeValidator chargeValidator

console

protected Console console

valuerFactory

protected ValuerFactory valuerFactory

showWinnerList

protected boolean showWinnerList

report

protected GameReport report

identityController

protected ClientIdentityController identityController

behaviorController

protected ClientBehaviorController behaviorController

securityManager

protected SecurityManager securityManager

dailyGC

protected boolean dailyGC
Constructor Detail

GameController

public GameController()
Method Detail

getInstance

public static GameController getInstance()

setup

public void setup(edu.cuny.config.param.ParameterDatabase parameters,
                  edu.cuny.config.param.Parameter base)
Specified by:
setup in interface edu.cuny.config.param.Parameterizable

initialize

public void initialize()
to initialize the game controller and make the server ready for clients to check in.


start

public void start()
to start the game.


stop

public void stop()
to stop the game.


dispose

public void dispose()

exit

public void exit()

getClock

public GameClock getClock()

getClockController

public ClockController getClockController()

getShoutValidator

public ShoutValidator getShoutValidator()

getTransactionValidator

public TransactionValidator getTransactionValidator()

getChargeValidator

public ChargeValidator getChargeValidator()

getConnectionManager

public ConnectionManager getConnectionManager()

getTimeController

public TimeoutController getTimeController()

getBehaviorController

public ClientBehaviorController getBehaviorController()

getSecurityManager

public SecurityManager getSecurityManager()

getRegistry

public Registry getRegistry()

getConsole

public Console getConsole()

getValuerFactory

public ValuerFactory getValuerFactory()

getReport

public GameReport getReport()

getReport

public <R extends GameReport> R getReport(java.lang.Class<R> reportClass)

addReport

public void addReport(GameReport newReport)

processEventInsideServer

public void processEventInsideServer(AuctionEvent event)
sends auction events to registry, console, and reports.

Parameters:
event -

notifyInsideListener

protected void notifyInsideListener(AuctionEventListener listener,
                                    AuctionEvent event)
notifies a listener of an auction event.

Parameters:
listener -
event -

eventOccurred

public void eventOccurred(AuctionEvent event)
listens to game clock's notifications

Specified by:
eventOccurred in interface AuctionEventListener