Fixing issues on other computers.

This commit is contained in:
marcins78@gmail.com
2012-08-23 20:17:50 +00:00
parent 7adc456684
commit 06ba4af039
10 changed files with 46 additions and 27 deletions

View File

@@ -11,6 +11,11 @@
<artifactId>gemp-lotr-common</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@@ -1,15 +1,26 @@
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 static void setRoot(File file) {
_root = file;
}
public static File getRoot() {
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

@@ -0,0 +1,3 @@
application.root=/etc/gemp-lotr
## My home location
#application.root=i:\gemp-lotr

View File

@@ -18,10 +18,12 @@ import com.gempukku.lotro.logic.timing.results.CharacterLostSkirmishResult;
import com.gempukku.lotro.logic.timing.results.CharacterWonSkirmishResult;
import com.gempukku.lotro.logic.timing.results.PlayCardResult;
import com.gempukku.lotro.logic.timing.rules.CharacterDeathRule;
import org.apache.log4j.Logger;
import java.util.*;
public class DefaultActionsEnvironment implements ActionsEnvironment {
private static Logger LOG = Logger.getLogger(DefaultActionsEnvironment.class);
private LotroGame _lotroGame;
private CharacterDeathRule _characterDeathRule;
private ActionStack _actionStack;
@@ -526,7 +528,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
if (action != null)
_actions.add(action);
else
System.out.println("Null action from: " + physicalCard.getBlueprint().getName());
LOG.error("Null action from: " + physicalCard.getBlueprint().getName());
}
}
final List<? extends ActivateCardAction> extraActions = _game.getModifiersQuerying().getExtraPhaseActions(_game.getGameState(), physicalCard);
@@ -535,7 +537,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
if (action != null)
_actions.add(action);
else
System.out.println("Null action from: " + physicalCard.getBlueprint().getName());
LOG.debug("Null action from: " + physicalCard.getBlueprint().getName());
}
}
}
@@ -568,7 +570,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
if (action != null)
_actions.add(action);
else
System.out.println("Null action from: " + physicalCard.getBlueprint().getName());
LOG.debug("Null action from: " + physicalCard.getBlueprint().getName());
}
}
}

View File

@@ -1,6 +1,9 @@
package com.gempukku.lotro;
import org.apache.log4j.Logger;
public abstract class AbstractServer {
private static Logger _logger = Logger.getLogger(AbstractServer.class);
private static ServerCleaner _cleaningTask = new ServerCleaner();
private boolean _started;
@@ -9,6 +12,7 @@ public abstract class AbstractServer {
if (!_started) {
_cleaningTask.addServer(this);
_started = true;
_logger.debug("Started: "+getClass().getSimpleName());
doAfterStartup();
}
}
@@ -21,6 +25,7 @@ public abstract class AbstractServer {
if (_started) {
_cleaningTask.removeServer(this);
_started = false;
_logger.debug("Stopped: "+getClass().getSimpleName());
}
}

View File

@@ -12,7 +12,7 @@ public class ServerCleaner {
private CleaningThread _thr;
public synchronized void addServer(AbstractServer server) {
System.out.println("Adding server: " + server.getClass());
LOG.debug("Adding server: " + server.getClass());
_servers.add(server);
if (_thr == null) {
_thr = new CleaningThread();

View File

@@ -6,6 +6,7 @@ import com.gempukku.lotro.db.PlayerDAO;
import com.gempukku.lotro.db.vo.CollectionType;
import com.gempukku.lotro.game.*;
import com.gempukku.lotro.packs.PacksStorage;
import org.apache.log4j.Logger;
import java.io.IOException;
import java.sql.SQLException;
@@ -15,6 +16,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class CollectionsManager {
private static Logger _logger = Logger.getLogger(CollectionsManager.class);
private ReentrantReadWriteLock _readWriteLock = new ReentrantReadWriteLock();
private Map<String, Map<String, CardCollection>> _collections = new ConcurrentHashMap<String, Map<String, CardCollection>>();
@@ -39,7 +41,7 @@ public class CollectionsManager {
final int[] cardCounts = new int[]{129, 365, 122, 122, 365, 128, 128, 365, 122, 52, 122, 266, 203, 203, 15, 207, 6, 157, 149, 40};
for (int i = 0; i <= 19; i++) {
System.out.println("Loading set " + i);
_logger.debug("Loading set " + i);
for (int j = 1; j <= cardCounts[i]; j++) {
String blueprintId = i + "_" + j;
try {

View File

@@ -1,7 +1,6 @@
package com.gempukku.lotro.server;
import com.gempukku.lotro.chat.ChatServer;
import com.gempukku.lotro.common.ApplicationRoot;
import com.gempukku.lotro.db.PlayerStatistic;
import com.gempukku.lotro.db.vo.GameHistoryEntry;
import com.gempukku.lotro.game.*;
@@ -20,7 +19,6 @@ import javax.ws.rs.core.StreamingOutput;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -50,13 +48,6 @@ public class ServerResource extends AbstractResource {
@Context
private GameRecorder _gameRecorder;
public ServerResource() {
if (!_test)
ApplicationRoot.setRoot(new File("/etc/gemp-lotr"));
else
ApplicationRoot.setRoot(new File("i:\\gemp-lotr"));
}
@Path("/login")
@POST
@Produces("text/html")

View File

@@ -7,13 +7,14 @@ import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.InjectableProvider;
import org.apache.log4j.Logger;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.Provider;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
@Provider
public class MapProvider implements InjectableProvider<Context, Type> {
private static final Logger _logger = Logger.getLogger(PacksStorageBuilder.class);
private Map<Type, Object> _objectMap = new HashMap<Type, Object>();
@@ -23,6 +24,7 @@ public class MapProvider implements InjectableProvider<Context, Type> {
_objectMap.put(PacksStorage.class, PacksStorageBuilder.createPacksStorage());
DaoBuilder.fillObjectMap(_objectMap);
ServerBuilder.fillObjectMap(_objectMap);
ServerBuilder.constructObjects(_objectMap);
} catch (Exception exp) {
_logger.error("Unable to startup the server", exp);
}
@@ -33,11 +35,6 @@ public class MapProvider implements InjectableProvider<Context, Type> {
return ComponentScope.Singleton;
}
@PostConstruct
public void constructObjects() {
ServerBuilder.constructObjects(_objectMap);
}
@PreDestroy
public void destroyObjects() {
ServerBuilder.destroyObjects(_objectMap);
@@ -45,10 +42,13 @@ public class MapProvider implements InjectableProvider<Context, Type> {
@Override
public Injectable getInjectable(ComponentContext ic, Context context, final Type type) {
final Object value = _objectMap.get(type);
if (value == null)
return null;
return new Injectable() {
@Override
public Object getValue() {
return _objectMap.get(type);
return value;
}
};
}

View File

@@ -8,7 +8,7 @@
</layout>
</appender>
<appender name="R" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="logs/gemp-lotr.log"/>
<param name="file" value="${catalina.base}/logs/gemp-lotr.log"/>
<param name="MaxFileSize" value="10MB"/>
<param name="MaxBackupIndex" value="20"/>
<layout class="org.apache.log4j.PatternLayout">