edu.cuny.cat
Class Game

java.lang.Object
  extended by edu.cuny.cat.Game

public final class Game
extends java.lang.Object

Main class of jcat when jcat is run as a Java application to launch a game, including a GameServer and multiple GameClients.

Parameters

cat.server
(the parameter base for GameServer)
cat.agent.n
int >=0
(the number of subpopulations of trader clients)
cat.agent.n
class, being or inheriting TraderClient
(the class of trader clients for the nth trader subpopulation)
cat.specialist.n
int >=0
(the number of subpopulations of specialist clients)
cat.specialist.n
class, being or inheriting MarketClient
(the class of market clients for the nth specialist subpopulation)
cat.specialist.optional.dir
string
(the directory to look for the configurations of optional market clients)
cat.specialist.optional.base
string
(the base of parameters used to specify the configurations of optional market clients in the parameter files located in cat.specialist.optional.dir)

Version:
$Revision: 1.62 $
Author:
Jinzhong Niu

Field Summary
static java.lang.String BANNER
           
protected static ClientSynchronizer clientSynchronizer
           
static java.lang.String EMAIL
           
protected static IdentityOffice identityOffice
           
static int majorVersion
           
static int minorVersion
           
static java.lang.String NAME
           
static java.lang.String P_AGENT
           
static java.lang.String P_BASE
           
static java.lang.String P_CAT
           
static java.lang.String P_DIR
           
static java.lang.String P_GUI_APPENDER
           
static java.lang.String P_INFRASTRUCTURE
           
static java.lang.String P_NAME
           
static java.lang.String P_NUM
           
static java.lang.String P_OPTIONAL
           
static java.lang.String P_SERVER
           
static java.lang.String P_SPECIALIST
           
static java.lang.String P_VERSION
           
 
Constructor Summary
Game()
           
 
Method Summary
static void cleanUpAfterInitialization()
           
static void cleanupObjectRegistry()
           
static java.util.Collection<? extends MarketClient> createMarkets()
          creates multiple market/specialist clients using the default parameter base for specialists.
static java.util.Collection<? extends MarketClient> createMarkets(edu.cuny.config.param.Parameter base)
          creates multiple market/specialist clients, each an instance of MarketClient, initializes them with parameter database in ObjectRegistry using the given parameter base.
static java.util.Collection<? extends MarketClient> createMarkets(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
          creates multiple market/specialist clients, each an instance of MarketClient, initializes them with the given parameter database and using the given parameter base.
static java.util.Collection<? extends MarketClient> createOptionalMarkets()
          creates multiple market/specialist clients, each an instance of MarketClient, based on parameter files in the specified directory and its subdirectories.
static GameServer createServer()
          creates an instance of GameServer and initializes it with parameter database in the object galaxy.
static java.util.Collection<? extends TraderClient> createTraders()
          creates multiple traders, each an instance of TraderClient, initializes them with parameter database in the object galaxy, and starts them.
static java.lang.String getBanner()
           
static java.lang.String getDefaultParameterFile()
           
static java.lang.String getName()
           
static java.lang.String getParameterFile(java.lang.String[] args)
          retrieves the name of the parameter file from command line arguments; or the default file is used if no argument is present.
static java.lang.String getVersion()
           
static void main(java.lang.String[] args)
          initializes Galaxy, GameServer, MarketClients, and TraderClients.
static void makeSureUnsynchronousInfrastructure()
           
static void setupObjectRegistry()
           
static void setupPreferences(edu.cuny.config.param.ParameterDatabase parameters)
          sets up the preferences of JCAT using the parameter database.
static void setupPreferences(java.net.URL url, java.lang.String[] args)
           
static void setupPreferences(java.net.URL url, java.lang.String[] args, boolean startLogging)
          does the following: initializes log4j with the parameter file loads a parameter file into a ParameterDatabase invokes setupPreferences(ParameterDatabase) to setup preferences using the ParameterDatabase;
static void startMarkets(java.util.Collection<? extends MarketClient> marketColl)
           
static void startServer(GameServer server)
           
static void startTraders(java.util.Collection<? extends TraderClient> traderColl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minorVersion

public static final int minorVersion
See Also:
Constant Field Values

majorVersion

public static final int majorVersion
See Also:
Constant Field Values

NAME

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

EMAIL

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

BANNER

public static final java.lang.String BANNER

P_CAT

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

P_VERSION

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

P_NAME

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

P_INFRASTRUCTURE

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

P_GUI_APPENDER

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

P_SERVER

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

P_AGENT

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

P_SPECIALIST

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

P_OPTIONAL

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

P_DIR

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

P_BASE

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

P_NUM

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

identityOffice

protected static IdentityOffice identityOffice

clientSynchronizer

protected static ClientSynchronizer clientSynchronizer
Constructor Detail

Game

public Game()
Method Detail

getDefaultParameterFile

public static java.lang.String getDefaultParameterFile()

getParameterFile

public static java.lang.String getParameterFile(java.lang.String[] args)
retrieves the name of the parameter file from command line arguments; or the default file is used if no argument is present.

Parameters:
args - command line arguments
Returns:
the name of the parameter file

main

public static void main(java.lang.String[] args)
initializes Galaxy, GameServer, MarketClients, and TraderClients.

Parameters:
args - command line arguments

setupObjectRegistry

public static void setupObjectRegistry()

cleanupObjectRegistry

public static void cleanupObjectRegistry()

setupPreferences

public static void setupPreferences(java.net.URL url,
                                    java.lang.String[] args)

setupPreferences

public static void setupPreferences(java.net.URL url,
                                    java.lang.String[] args,
                                    boolean startLogging)
does the following:

Parameters:
url - where the parameter file is located.
args - command line arguments transferred from main().
startLogging - configures log4j for logging if true, or not otherwise.

setupPreferences

public static void setupPreferences(edu.cuny.config.param.ParameterDatabase parameters)
sets up the preferences of JCAT using the parameter database.

Parameters:
parameters -

createServer

public static GameServer createServer()
creates an instance of GameServer and initializes it with parameter database in the object galaxy.


startServer

public static void startServer(GameServer server)

createTraders

public static java.util.Collection<? extends TraderClient> createTraders()
                                                                  throws java.lang.InstantiationException,
                                                                         java.lang.IllegalAccessException
creates multiple traders, each an instance of TraderClient, initializes them with parameter database in the object galaxy, and starts them.

Throws:
java.lang.InstantiationException - if fails to instantiate trader clients
java.lang.IllegalAccessException

startTraders

public static void startTraders(java.util.Collection<? extends TraderClient> traderColl)

createMarkets

public static java.util.Collection<? extends MarketClient> createMarkets()
                                                                  throws java.lang.InstantiationException,
                                                                         java.lang.IllegalAccessException
creates multiple market/specialist clients using the default parameter base for specialists.

Throws:
java.lang.InstantiationException - if fails to instantiate market clients
java.lang.IllegalAccessException
See Also:
createMarkets(Parameter)

createMarkets

public static java.util.Collection<? extends MarketClient> createMarkets(edu.cuny.config.param.Parameter base)
                                                                  throws java.lang.InstantiationException,
                                                                         java.lang.IllegalAccessException
creates multiple market/specialist clients, each an instance of MarketClient, initializes them with parameter database in ObjectRegistry using the given parameter base.

Throws:
java.lang.InstantiationException - if fails to instantiate market clients
java.lang.IllegalAccessException

createMarkets

public static java.util.Collection<? extends MarketClient> createMarkets(edu.cuny.config.param.ParameterDatabase parameters,
                                                                         edu.cuny.config.param.Parameter base)
                                                                  throws java.lang.InstantiationException,
                                                                         java.lang.IllegalAccessException
creates multiple market/specialist clients, each an instance of MarketClient, initializes them with the given parameter database and using the given parameter base.

Parameters:
parameters -
base -
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

createOptionalMarkets

public static java.util.Collection<? extends MarketClient> createOptionalMarkets()
                                                                          throws java.lang.InstantiationException,
                                                                                 java.lang.IllegalAccessException
creates multiple market/specialist clients, each an instance of MarketClient, based on parameter files in the specified directory and its subdirectories. Each of these parameter files define a set of market clients using the specified parameter base. For example
 cat.specialist.optional.dir = params/elites
 cat.specialist.optional.base = elites
 
specifies to look for parameter files in the directory params/elites and all market clients are configured using the parameter base elites.

Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

startMarkets

public static void startMarkets(java.util.Collection<? extends MarketClient> marketColl)

cleanUpAfterInitialization

public static void cleanUpAfterInitialization()

makeSureUnsynchronousInfrastructure

public static void makeSureUnsynchronousInfrastructure()
                                                throws CatpServerUnavailableException
Throws:
CatpServerUnavailableException

getBanner

public static java.lang.String getBanner()

getVersion

public static java.lang.String getVersion()

getName

public static java.lang.String getName()