edu.ou.mlfw.config
Class ClientInitializer

java.lang.Object
  extended by edu.ou.mlfw.config.ClientInitializer

public class ClientInitializer
extends java.lang.Object

A ClientInitializer is the means by which a World finds, loads, and initializes a Client. From the point of view of a Client developer, the ClientInitializer is a minimal set of configuration necessary for specifying the Client implementation class (which must be available on the classpath), the file that the client may use for configuration purposes, and the file the client may use for data loading purposes. A ClientInitializer also allows the developer to specify the name that should be associated with the Client for display purposes (on the ladder, for instance). A ClientInitializer will normally be created by deserializing from an xml file (see the fromXMLFile method), the location of which is given as part of a ClientMapping in a WorldConfig.


Constructor Summary
ClientInitializer(java.lang.Class<? extends Client> clientClass, java.io.File configuration, java.io.File data, java.lang.String displayName)
          Constructor for a ClientInitializer.
 
Method Summary
static ClientInitializer fromXMLFile(java.io.File f)
          Factory method to generate a ClientInitializer from the given file.
 java.lang.Class<? extends Client> getClientClass()
          Each client will be an instance of a class submitted by students.
 java.io.File getConfiguration()
          Each client can be configured independently, using any format the client wishes to use.
 java.io.File getData()
          Each client can specify the location of any data that should be loaded when the simulator starts up.
 java.lang.String getDisplayName()
          Each client can specify the name that should be associated with that client for display purposes.
static com.thoughtworks.xstream.XStream getXStream()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientInitializer

public ClientInitializer(java.lang.Class<? extends Client> clientClass,
                         java.io.File configuration,
                         java.io.File data,
                         java.lang.String displayName)
Constructor for a ClientInitializer.

Parameters:
clientClass - The client class
configuration - The file location of the client's configuration.
data - The file location of the client's data.
displayName - The name that should be displayed for the client.
Method Detail

getClientClass

public java.lang.Class<? extends Client> getClientClass()
Each client will be an instance of a class submitted by students. We don't know ahead of time what that class will be named, what package it will live in, etc, so we make the client's class configurable.

Returns:
Return the class that should be used to instantiate the client object.

getConfiguration

public java.io.File getConfiguration()
Each client can be configured independently, using any format the client wishes to use. The only caveat is that the config fit into a single file. This returns that file location.

Returns:
The location of the client's configuration file.

getData

public java.io.File getData()
Each client can specify the location of any data that should be loaded when the simulator starts up.

Returns:
The location of the client's data file.

getDisplayName

public java.lang.String getDisplayName()
Each client can specify the name that should be associated with that client for display purposes.

Returns:
The display name of the client.

getXStream

public static com.thoughtworks.xstream.XStream getXStream()
Returns:
An XStream object properly initialized for serializing and deserializing a ClientInitializer.

fromXMLFile

public static ClientInitializer fromXMLFile(java.io.File f)
                                     throws java.io.IOException
Factory method to generate a ClientInitializer from the given file. This uses Xstream to deserialize an XML representation of the ClientInitializer object; additional documentation on the required format for this file can be found in the example ClientInitializer config file included in the samples distribution.

Parameters:
f - The file to deserialize.
Returns:
The deserialized ClientInitializer
Throws:
java.io.IOException