|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--de.uni_paderborn.robots.robotArenaInterface.proxy.ProxyFactory
This (singleton) class provides a method for easy integrating a proxy between the arena and a robot.
Now just call:
RobotFunctions robotFunctions = null;
...
robotFunctions = ProxyFactory.getInstance().getProxy(new SomeRobot());
Instead of:
RobotFunctions robotFunctions = null;
...
robotFunctions = new SomeRobot();
Proxy,
RobotFunctions| Field Summary | |
private java.sql.PreparedStatement |
actionCardLog
Prepared SQL statement for logging the cards in the robot's action. |
private java.sql.PreparedStatement |
actionFieldLog
Prepared SQL statement for logging the fields in the robot's action. |
private java.sql.PreparedStatement |
actionLog
Prepared SQL statement for logging the robot's action. |
private java.lang.String |
arenaName
The name of the arena. |
private java.sql.Connection |
connection
The connection to the database. |
private java.sql.PreparedStatement |
exchangeLog
Prepared SQL statement for logging the robot's exchange behaviour. |
private long |
gameUID
A unique identifier for the game. |
private java.sql.PreparedStatement |
irregularityLog
Prepared SQL statement for logging irregularities of the arena. |
private boolean |
logging
Status bit for logging. |
private int |
nextRobotUID
The unique identifier for the next registered robot. |
private static ProxyFactory |
proxyFactory
The only instance of this class. |
private ProxyLogWindow |
proxyLogWindow
The window for standard and error output. |
private boolean |
proxyProductionReady
Indicates whether the proxy factory is ready to produce proxies. |
| Constructor Summary | |
private |
ProxyFactory()
Constructs this class. |
| Method Summary | |
static int |
correctSingleGame(java.sql.Connection connection,
java.lang.String arenaName,
long gameUID)
Does final corrections on a single game. |
(package private) void |
doFinalCorrectionsOnGame()
Does final corrections on the current game. |
(package private) boolean |
doneSomething(Proxy proxy)
Notices that the robot has done at least one action (i.e., especially, that the game has already started). |
protected void |
finalize()
Called by the garbage collector when garbage collection determines that there are no more references to this object. |
static ProxyFactory |
getInstance()
Returns the one and only instance of this (singleton) class. |
Proxy |
getProxy(RobotFunctions robot)
Wraps a proxy around a robot. |
private void |
initGame()
Does the required initialization for a new game. |
void |
println(java.lang.String line)
Prints a line of text to the log window. |
(package private) boolean |
writeActionLog(int round,
int robotUID,
FieldData currentField,
FieldData leftField,
FieldData frontField,
FieldData rightField,
int energy,
CardData[] hand,
AbstractRobotAction returnedAction,
long time)
Inserts an action log entry into the database. |
(package private) boolean |
writeExchangeLog(int round,
int firstRobotUID,
int secondRobotUID,
CardData firstProposal,
CardData secondProposal,
boolean firstOk,
boolean secondOk)
Inserts an exchange log entry into the database. |
(package private) boolean |
writeIrregularityLog(int round,
java.lang.String description)
Inserts an irregularity log entry into the database. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static ProxyFactory proxyFactory
private boolean proxyProductionReady
private java.lang.String arenaName
private long gameUID
private int nextRobotUID
private boolean logging
private java.sql.Connection connection
private java.sql.PreparedStatement actionLog
private java.sql.PreparedStatement actionFieldLog
private java.sql.PreparedStatement actionCardLog
private java.sql.PreparedStatement exchangeLog
private java.sql.PreparedStatement irregularityLog
private ProxyLogWindow proxyLogWindow
| Constructor Detail |
private ProxyFactory()
throws java.lang.ClassNotFoundException,
java.io.IOException,
ProxyFactoryException,
java.sql.SQLException
java.lang.ClassNotFoundException - if the database driver could not be foundjava.io.IOException - if an error occurred reading the config fileProxyFactoryException - if an error occurred during initialization of this classjava.sql.SQLException - if an error occurred accessing the database| Method Detail |
private void initGame()
throws java.sql.SQLException
java.sql.SQLException - if an error occurred accessing the database
public static ProxyFactory getInstance()
throws java.lang.ClassNotFoundException,
java.io.IOException,
ProxyFactoryException,
java.sql.SQLException
java.lang.ClassNotFoundException - if the database driver could not be foundjava.io.IOException - if an error occurred reading the config fileProxyFactoryException - if an error occurred during initialization of this classjava.sql.SQLException - if an error occurred accessing the database
public Proxy getProxy(RobotFunctions robot)
throws java.lang.ClassNotFoundException,
java.sql.SQLException
robot - the robot to wrap a proxy aroundjava.lang.ClassNotFoundException - if the database driver could not be foundjava.sql.SQLException - if an error occurred during initialization of the proxyboolean doneSomething(Proxy proxy)
proxy - the proxy which has done somethingtrue if the proxy factory succeeded write the robot name log entry, false otherwisepublic void println(java.lang.String line)
line - the line of text to print
boolean writeActionLog(int round,
int robotUID,
FieldData currentField,
FieldData leftField,
FieldData frontField,
FieldData rightField,
int energy,
CardData[] hand,
AbstractRobotAction returnedAction,
long time)
round - the round of the actionrobotUID - the unique identifier of the robot which executed the actioncurrentField - the robot's current fieldleftField - the robot's left fieldfrontField - the robot's front fieldrightField - the robot's right fieldenergy - the robot's energyhand - the robot's handreturnedAction - the action the robot wanted to be executedtime - the time the robot needed for thinking (measurements in the arena may be delayed through the database access)true if the proxy factory succeeded write the action log entry, false otherwise
boolean writeExchangeLog(int round,
int firstRobotUID,
int secondRobotUID,
CardData firstProposal,
CardData secondProposal,
boolean firstOk,
boolean secondOk)
round - the round of the exchangefirstRobotUID - the unique identifier of the first robotsecondRobotUID - the unique identifier of the second robotfirstProposal - the proposal of the first robotsecondProposal - the proposal of the second robotfirstOk - the ok value of the first robotsecondOk - the ok value of the second robottrue if the proxy factory succeeded write the exchange log entry, false otherwise
boolean writeIrregularityLog(int round,
java.lang.String description)
round - the round which the irregularity occurred indescription - a description of the irregularitytrue if the proxy factory succeeded write the irregularity log entry, false otherwise
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable - the Exception raised by this methodvoid doFinalCorrectionsOnGame()
public static int correctSingleGame(java.sql.Connection connection,
java.lang.String arenaName,
long gameUID)
throws java.sql.SQLException,
ProxyFactoryException
connection - the connection to the databasearenaName - the name of the arenagameUID - the unique identifier of the gamejava.sql.SQLException - if an error occurred accessing or manipulating the databaseProxyFactoryException - if there is an internal error in the data
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||