This commit is contained in:
BetaSteward 2010-03-21 03:54:48 +00:00
parent 2aaa8312f4
commit 41d9cb30de
5 changed files with 20 additions and 5 deletions

View file

@ -50,7 +50,7 @@ javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jaxbwiz.endorsed.dirs="${netbeans.home}/../ide9/modules/ext/jaxb/api"
jaxbwiz.endorsed.dirs=${netbeans.home}/../ide9/modules/ext/jaxb/api
jaxbwiz.gensrc.classpath=${libs.jaxb.classpath}
jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath}
jaxbwiz.xjcrun.classpath=${libs.jaxb.classpath}
@ -73,7 +73,7 @@ run-sys-prop.java.endorsed.dirs=${jaxbwiz.endorsed.dirs}
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
run.jvmargs=-server -Djava.security.policy=src/security.policy
run.jvmargs=-server -Djava.security.policy=config/security.policy
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}

View file

@ -48,6 +48,8 @@ public class Main {
private static Logger logger = Logging.getLogger(Main.class.getName());
private final static String testModeArg = "-testMode=";
/**
* @param args the command line arguments
*/
@ -61,7 +63,13 @@ public class Main {
for (Plugin plugin: config.getPlayerTypes()) {
PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin));
}
Server server = new ServerImpl(config.getPort(), config.getServerName());
boolean testMode = false;
for (String arg: args) {
if (arg.startsWith(testModeArg)) {
testMode = Boolean.valueOf(arg.replace(testModeArg, ""));
}
}
Server server = new ServerImpl(config.getPort(), config.getServerName(), testMode);
}

View file

@ -62,13 +62,17 @@ public class ServerImpl implements Server {
private final static Logger logger = Logging.getLogger("Mage Server");
public ServerImpl(int port, String name) {
private boolean testMode;
public ServerImpl(int port, String name, boolean testMode) {
try {
System.setSecurityManager(null);
Registry reg = LocateRegistry.createRegistry(port);
Server server = (Server) UnicastRemoteObject.exportObject(this, 0);
reg.rebind(name, server);
this.testMode = testMode;
logger.info("Started MAGE server - listening on port " + port);
logger.info("MAGE server running in test mode");
} catch (RemoteException ex) {
logger.log(Level.SEVERE, "Failed to start RMI server at port " + port, ex);
}
@ -425,7 +429,8 @@ public class ServerImpl implements Server {
@Override
public void cheat(UUID gameId, UUID sessionId, DeckCardLists deckList) throws MageException {
try {
// GameManager.getInstance().cheat(gameId, sessionId, deckList);
if (testMode)
GameManager.getInstance().cheat(gameId, sessionId, deckList);
}
catch (Exception ex) {
handleException(ex);

View file

@ -347,6 +347,7 @@ public class GameController implements GameCallback {
return new CardsView(cards.values());
}
@Override
public void gameResult(String result) {
endGame(result);
}

View file

@ -57,6 +57,7 @@ public class GameWorker implements Callable {
result.gameResult(game.getWinner());
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
result.gameResult("Server Error");
}
return null;
}