Fixing issues on other computers.

This commit is contained in:
marcins78@gmail.com
2012-08-23 20:40:05 +00:00
parent 06ba4af039
commit 157f55e1a4
4 changed files with 40 additions and 30 deletions

View File

@@ -0,0 +1,30 @@
package com.gempukku.lotro.common;
import org.apache.log4j.Logger;
import java.io.File;
import java.util.Properties;
public class ApplicationConfiguration {
private static Logger LOGGER = Logger.getLogger(ApplicationConfiguration.class);
private static Properties _properties;
private static File _root;
private synchronized static Properties getProperties() {
if (_properties == null) {
Properties props = new Properties();
try {
props.load(ApplicationConfiguration.class.getResourceAsStream("/gemp-lotr.properties"));
_properties = props;
} catch (Exception exp) {
LOGGER.error("Can't load application configuration", exp);
throw new RuntimeException("Unable to load application configuration", exp);
}
}
return _properties;
}
public static String getProperty(String property) {
return getProperties().getProperty(property);
}
}

View File

@@ -1,26 +0,0 @@
package com.gempukku.lotro.common;
import org.apache.log4j.Logger;
import java.io.File;
import java.util.Properties;
public class ApplicationRoot {
private static Logger LOGGER = Logger.getLogger(ApplicationRoot.class);
private static File _root;
public synchronized static File getRoot() {
if (_root == null) {
Properties props = new Properties();
try {
props.load(ApplicationRoot.class.getResourceAsStream("/gemp-lotr.properties"));
_root = new File(props.getProperty("application.root"));
LOGGER.debug("Application root is: "+_root.getAbsolutePath());
} catch (Exception exp) {
LOGGER.error("Can't find application root", exp);
throw new RuntimeException("Unable to load gemp-lotr.properties");
}
}
return _root;
}
}

View File

@@ -1,3 +1,9 @@
## Application root, used for example for storing replay files
application.root=/etc/gemp-lotr
## My home location
#application.root=i:\gemp-lotr
## DB connection
db.connection.class=org.gjt.mm.mysql.Driver
db.connection.url=jdbc:mysql://localhost/gemp-lotr
db.connection.username=gemp-lotr
db.connection.password=gemp-lotr
db.connection.validateQuery=/* ping */ select 1

View File

@@ -1,6 +1,6 @@
package com.gempukku.lotro.game;
import com.gempukku.lotro.common.ApplicationRoot;
import com.gempukku.lotro.common.ApplicationConfiguration;
import com.gempukku.lotro.game.state.EventSerializer;
import com.gempukku.lotro.game.state.GameEvent;
import com.gempukku.lotro.game.state.GatheringParticipantCommunicationChannel;
@@ -71,7 +71,7 @@ public class GameRecorder {
}
private File getRecordingFile(String playerId, String gameId) {
File gameReplayFolder = new File(ApplicationRoot.getRoot(), "replay");
File gameReplayFolder = new File(ApplicationConfiguration.getProperty("application.root"), "replay");
File playerReplayFolder = new File(gameReplayFolder, playerId);
return new File(playerReplayFolder, gameId + ".xml.gz");
}