From 157f55e1a4ad0aefe026c6a8e61b7356eaed2aab Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Thu, 23 Aug 2012 20:40:05 +0000 Subject: [PATCH] Fixing issues on other computers. --- .../common/ApplicationConfiguration.java | 30 +++++++++++++++++++ .../lotro/common/ApplicationRoot.java | 26 ---------------- .../src/main/resources/gemp-lotr.properties | 10 +++++-- .../com/gempukku/lotro/game/GameRecorder.java | 4 +-- 4 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/ApplicationConfiguration.java delete mode 100644 gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/ApplicationRoot.java diff --git a/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/ApplicationConfiguration.java b/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/ApplicationConfiguration.java new file mode 100644 index 000000000..60415a649 --- /dev/null +++ b/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/ApplicationConfiguration.java @@ -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); + } +} diff --git a/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/ApplicationRoot.java b/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/ApplicationRoot.java deleted file mode 100644 index a3492b6fb..000000000 --- a/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/ApplicationRoot.java +++ /dev/null @@ -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; - } -} diff --git a/gemp-lotr/gemp-lotr-common/src/main/resources/gemp-lotr.properties b/gemp-lotr/gemp-lotr-common/src/main/resources/gemp-lotr.properties index 62e5a7c49..11c21922f 100644 --- a/gemp-lotr/gemp-lotr-common/src/main/resources/gemp-lotr.properties +++ b/gemp-lotr/gemp-lotr-common/src/main/resources/gemp-lotr.properties @@ -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 \ No newline at end of file + +## 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 diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/GameRecorder.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/GameRecorder.java index fa9c5af43..75dbd7de7 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/GameRecorder.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/GameRecorder.java @@ -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"); }