Restructuring Providers to have one starting point.

This commit is contained in:
marcins78@gmail.com
2012-08-23 10:37:20 +00:00
parent 00b33eb85d
commit 9fac3e5e10
11 changed files with 241 additions and 557 deletions

View File

@@ -9,9 +9,14 @@ public abstract class AbstractServer {
if (!_started) {
_cleaningTask.addServer(this);
_started = true;
doAfterStartup();
}
}
protected void doAfterStartup() {
}
public void stopServer() {
if (_started) {
_cleaningTask.removeServer(this);

View File

@@ -66,13 +66,16 @@ public class HallServer extends AbstractServer {
_collectionsManager = collectionsManager;
_hallChat = _chatServer.createChatRoom("Game Hall", 10);
_runningTournaments.addAll(tournamentService.getLiveTournaments());
_tournamentQueues.put("fotr_queue", new SingleEliminationRecurringQueue(0, "fotr_block",
new CollectionType("default", "All cards"), "fotrQueue-", "Test Fellowship Block 4-man", 4,
tournamentService));
}
@Override
protected void doAfterStartup() {
_runningTournaments.addAll(_tournamentService.getLiveTournaments());
}
public void setShutdown(boolean shutdown) {
_hallDataAccessLock.writeLock().lock();
try {

View File

@@ -33,6 +33,12 @@
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>gemp-lotr-server</finalName>

View File

@@ -0,0 +1,32 @@
package com.gempukku.lotro.server.provider;
import com.gempukku.lotro.collection.CollectionSerializer;
import com.gempukku.lotro.db.*;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.tournament.TournamentDAO;
import com.gempukku.lotro.tournament.TournamentMatchDAO;
import com.gempukku.lotro.tournament.TournamentPlayerDAO;
import java.lang.reflect.Type;
import java.util.Map;
public class DaoBuilder {
public static void fillObjectMap(Map<Type, Object> objectMap) {
DbAccess dbAccess = new DbAccess();
CollectionSerializer collectionSerializer = new CollectionSerializer();
LotroCardBlueprintLibrary library = new LotroCardBlueprintLibrary();
objectMap.put(LotroCardBlueprintLibrary.class, library);
objectMap.put(LeagueParticipationDAO.class, new DbLeagueParticipationDAO(dbAccess));
objectMap.put(LeagueMatchDAO.class, new DbLeagueMatchDAO(dbAccess));
objectMap.put(TournamentDAO.class, new DbTournamentDAO(dbAccess));
objectMap.put(TournamentPlayerDAO.class, new DbTournamentPlayerDAO(dbAccess));
objectMap.put(TournamentMatchDAO.class, new DbTournamentMatchDAO(dbAccess));
objectMap.put(MerchantDAO.class, new DbMerchantDAO(dbAccess));
objectMap.put(LeagueDAO.class, new LeagueDAO(dbAccess));
objectMap.put(GameHistoryDAO.class, new GameHistoryDAO(dbAccess));
objectMap.put(DeckDAO.class, new DeckDAO(dbAccess, library));
objectMap.put(CollectionDAO.class, new CollectionDAO(dbAccess, collectionSerializer));
objectMap.put(PlayerDAO.class, new PlayerDAO(dbAccess));
}
}

View File

@@ -1,232 +0,0 @@
package com.gempukku.lotro.server.provider;
import com.gempukku.lotro.collection.CollectionSerializer;
import com.gempukku.lotro.db.*;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.tournament.TournamentDAO;
import com.gempukku.lotro.tournament.TournamentMatchDAO;
import com.gempukku.lotro.tournament.TournamentPlayerDAO;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.core.spi.component.ComponentScope;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.InjectableProvider;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.Provider;
import java.lang.reflect.Type;
@Provider
public class DaoProvider implements InjectableProvider<Context, Type> {
private Injectable<PlayerDAO> _playerDaoInjectable;
private Injectable<CollectionDAO> _collectionDaoInjectable;
private Injectable<MerchantDAO> _merchantDaoInjectable;
private Injectable<DeckDAO> _deckDaoInjectable;
private Injectable<GameHistoryDAO> _gameHistoryDAOInjectable;
private Injectable<LeagueDAO> _leagueDaoInjectable;
private Injectable<LeagueMatchDAO> _leagueMatchDAOInjectable;
private Injectable<LeagueParticipationDAO> _leagueParticipationDAOInjectable;
private Injectable<TournamentDAO> _tournamentDAOInjectable;
private Injectable<TournamentPlayerDAO> _tournamentPlayerDAOInjectable;
private Injectable<TournamentMatchDAO> _tournamentMatchDAOInjectable;
private Injectable<LotroCardBlueprintLibrary> _lotroCardBlueprintLibraryInjectable;
private DbAccess _dbAccess;
private CollectionSerializer _collectionSerializer;
public DaoProvider() {
_dbAccess = new DbAccess();
_collectionSerializer = new CollectionSerializer();
}
@Override
public Injectable getInjectable(ComponentContext ic, Context context, Type type) {
if (type.equals(PlayerDAO.class))
return getPlayerDaoSafely();
else if (type.equals(CollectionDAO.class))
return getCollectionDaoSafely();
else if (type.equals(DeckDAO.class))
return getDeckDaoSafely();
else if (type.equals(GameHistoryDAO.class))
return getGameHistoryDaoSafely();
else if (type.equals(LeagueDAO.class))
return getLeagueDaoSafely();
else if (type.equals(LeagueMatchDAO.class))
return getLeagueMatchDaoSafely();
else if (type.equals(LeagueParticipationDAO.class))
return getLeagueParticipationDaoSafely();
else if (type.equals(MerchantDAO.class))
return getMerchantDaoSafely();
else if (type.equals(TournamentDAO.class))
return getTournamentDaoSafely();
else if (type.equals(TournamentPlayerDAO.class))
return getTournamentPlayerDaoSafely();
else if (type.equals(TournamentMatchDAO.class))
return getTournamentMatchDaoSafely();
else if (type.equals(LotroCardBlueprintLibrary.class))
return getLotroCardBlueprintLibrarySafely();
return null;
}
private synchronized Injectable<LeagueParticipationDAO> getLeagueParticipationDaoSafely() {
if (_leagueParticipationDAOInjectable == null) {
final LeagueParticipationDAO leagueParticipationDAO = new DbLeagueParticipationDAO(_dbAccess);
_leagueParticipationDAOInjectable = new Injectable<LeagueParticipationDAO>() {
@Override
public LeagueParticipationDAO getValue() {
return leagueParticipationDAO;
}
};
}
return _leagueParticipationDAOInjectable;
}
private synchronized Injectable<LotroCardBlueprintLibrary> getLotroCardBlueprintLibrarySafely() {
if (_lotroCardBlueprintLibraryInjectable == null) {
final LotroCardBlueprintLibrary library = new LotroCardBlueprintLibrary();
_lotroCardBlueprintLibraryInjectable = new Injectable<LotroCardBlueprintLibrary>() {
@Override
public LotroCardBlueprintLibrary getValue() {
return library;
}
};
}
return _lotroCardBlueprintLibraryInjectable;
}
private synchronized Injectable<LeagueMatchDAO> getLeagueMatchDaoSafely() {
if (_leagueMatchDAOInjectable == null) {
final LeagueMatchDAO leagueMatchDao = new DbLeagueMatchDAO(_dbAccess);
_leagueMatchDAOInjectable = new Injectable<LeagueMatchDAO>() {
@Override
public LeagueMatchDAO getValue() {
return leagueMatchDao;
}
};
}
return _leagueMatchDAOInjectable;
}
private synchronized Injectable<TournamentDAO> getTournamentDaoSafely() {
if (_tournamentDAOInjectable == null) {
final DbTournamentDAO tournamentDAO = new DbTournamentDAO(_dbAccess);
_tournamentDAOInjectable = new Injectable<TournamentDAO>() {
@Override
public TournamentDAO getValue() {
return tournamentDAO;
}
};
}
return _tournamentDAOInjectable;
}
private synchronized Injectable<TournamentPlayerDAO> getTournamentPlayerDaoSafely() {
if (_tournamentPlayerDAOInjectable == null) {
final DbTournamentPlayerDAO tournamentPlayerDAO = new DbTournamentPlayerDAO(_dbAccess);
_tournamentPlayerDAOInjectable = new Injectable<TournamentPlayerDAO>() {
@Override
public TournamentPlayerDAO getValue() {
return tournamentPlayerDAO;
}
};
}
return _tournamentPlayerDAOInjectable;
}
private synchronized Injectable<TournamentMatchDAO> getTournamentMatchDaoSafely() {
if (_tournamentMatchDAOInjectable == null) {
final DbTournamentMatchDAO tournamentMatchDAO = new DbTournamentMatchDAO(_dbAccess);
_tournamentMatchDAOInjectable = new Injectable<TournamentMatchDAO>() {
@Override
public TournamentMatchDAO getValue() {
return tournamentMatchDAO;
}
};
}
return _tournamentMatchDAOInjectable;
}
private synchronized Injectable<MerchantDAO> getMerchantDaoSafely() {
if (_merchantDaoInjectable == null) {
final MerchantDAO merchantDAO = new DbMerchantDAO(_dbAccess);
_merchantDaoInjectable = new Injectable<MerchantDAO>() {
@Override
public MerchantDAO getValue() {
return merchantDAO;
}
};
}
return _merchantDaoInjectable;
}
private synchronized Injectable<LeagueDAO> getLeagueDaoSafely() {
if (_leagueDaoInjectable == null) {
final LeagueDAO leagueDao = new LeagueDAO(_dbAccess);
_leagueDaoInjectable = new Injectable<LeagueDAO>() {
@Override
public LeagueDAO getValue() {
return leagueDao;
}
};
}
return _leagueDaoInjectable;
}
private synchronized Injectable<GameHistoryDAO> getGameHistoryDaoSafely() {
if (_gameHistoryDAOInjectable == null) {
final GameHistoryDAO gameHistoryDAO = new GameHistoryDAO(_dbAccess);
_gameHistoryDAOInjectable = new Injectable<GameHistoryDAO>() {
@Override
public GameHistoryDAO getValue() {
return gameHistoryDAO;
}
};
}
return _gameHistoryDAOInjectable;
}
private synchronized Injectable<DeckDAO> getDeckDaoSafely() {
if (_deckDaoInjectable == null) {
final DeckDAO deckDao = new DeckDAO(_dbAccess, getLotroCardBlueprintLibrarySafely().getValue());
_deckDaoInjectable = new Injectable<DeckDAO>() {
@Override
public DeckDAO getValue() {
return deckDao;
}
};
}
return _deckDaoInjectable;
}
private synchronized Injectable<CollectionDAO> getCollectionDaoSafely() {
if (_collectionDaoInjectable == null) {
final CollectionDAO collectionDao = new CollectionDAO(_dbAccess, _collectionSerializer);
_collectionDaoInjectable = new Injectable<CollectionDAO>() {
@Override
public CollectionDAO getValue() {
return collectionDao;
}
};
}
return _collectionDaoInjectable;
}
private synchronized Injectable<PlayerDAO> getPlayerDaoSafely() {
if (_playerDaoInjectable == null) {
final PlayerDAO playerDao = new PlayerDAO(_dbAccess);
_playerDaoInjectable = new Injectable<PlayerDAO>() {
@Override
public PlayerDAO getValue() {
return playerDao;
}
};
}
return _playerDaoInjectable;
}
@Override
public ComponentScope getScope() {
return ComponentScope.Singleton;
}
}

View File

@@ -0,0 +1,55 @@
package com.gempukku.lotro.server.provider;
import com.gempukku.lotro.packs.PacksStorage;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.core.spi.component.ComponentScope;
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 java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
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>();
public MapProvider() {
try {
_objectMap.put(PacksStorage.class, PacksStorageBuilder.createPacksStorage());
DaoBuilder.fillObjectMap(_objectMap);
ServerBuilder.fillObjectMap(_objectMap);
} catch (Exception exp) {
_logger.error("Unable to startup the server", exp);
}
}
@Override
public ComponentScope getScope() {
return ComponentScope.Singleton;
}
@PostConstruct
public void constructObjects() {
ServerBuilder.constructObjects(_objectMap);
}
@PreDestroy
public void destroyObjects() {
ServerBuilder.destroyObjects(_objectMap);
}
@Override
public Injectable getInjectable(ComponentContext ic, Context context, final Type type) {
return new Injectable() {
@Override
public Object getValue() {
return _objectMap.get(type);
}
};
}
}

View File

@@ -1,35 +1,14 @@
package com.gempukku.lotro.server.provider;
import com.gempukku.lotro.packs.*;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.core.spi.component.ComponentScope;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.InjectableProvider;
import org.apache.log4j.Logger;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
import java.lang.reflect.Type;
@Provider
public class PacksStorageProvider implements Injectable<PacksStorage>, InjectableProvider<Context, Type> {
private static final Logger _logger = Logger.getLogger(PacksStorageProvider.class);
private PacksStorage _packsStorage;
public class PacksStorageBuilder {
private static final Logger _logger = Logger.getLogger(PacksStorageBuilder.class);
@Override
public Injectable getInjectable(ComponentContext ic, Context context, Type type) {
if (type.equals(PacksStorage.class))
return this;
return null;
}
@Override
public ComponentScope getScope() {
return ComponentScope.Singleton;
}
private PacksStorage createPacksStorage() {
public static PacksStorage createPacksStorage() {
try {
PacksStorage packStorage = new PacksStorage();
packStorage.addPackBox("FotR - League Starter", new LeagueStarterBox());
@@ -130,11 +109,4 @@ public class PacksStorageProvider implements Injectable<PacksStorage>, Injectabl
}
return null;
}
@Override
public synchronized PacksStorage getValue() {
if (_packsStorage == null)
_packsStorage = createPacksStorage();
return _packsStorage;
}
}

View File

@@ -0,0 +1,124 @@
package com.gempukku.lotro.server.provider;
import com.gempukku.lotro.chat.ChatServer;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.collection.DeliveryService;
import com.gempukku.lotro.db.*;
import com.gempukku.lotro.draft.DraftServer;
import com.gempukku.lotro.game.GameHistoryService;
import com.gempukku.lotro.game.GameRecorder;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.game.LotroServer;
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
import com.gempukku.lotro.hall.HallServer;
import com.gempukku.lotro.league.LeagueService;
import com.gempukku.lotro.merchant.MerchantService;
import com.gempukku.lotro.tournament.TournamentDAO;
import com.gempukku.lotro.tournament.TournamentMatchDAO;
import com.gempukku.lotro.tournament.TournamentPlayerDAO;
import com.gempukku.lotro.tournament.TournamentService;
import com.sun.jersey.spi.inject.Injectable;
import java.lang.reflect.Type;
import java.util.Map;
public class ServerBuilder {
private Injectable<ChatServer> _chatServerInjectable;
private Injectable<LeagueService> _leagueServiceInjectable;
private Injectable<GameHistoryService> _gameHistoryServiceInjectable;
private Injectable<MerchantService> _merchantServiceInjectable;
private Injectable<TournamentService> _tournamentServiceInjectable;
private Injectable<HallServer> _hallServerInjectable;
private Injectable<LotroServer> _lotroServerInjectable;
private Injectable<DraftServer> _draftServerInjectable;
private Injectable<CollectionsManager> _collectionsManagerInjectable;
private Injectable<DeliveryService> _deliveryServiceInjectable;
private Injectable<LotroFormatLibrary> _lotroFormatLibraryInjectable;
private Injectable<GameRecorder> _gameRecorderInjectable;
public static void fillObjectMap(Map<Type, Object> objectMap) {
objectMap.put(LotroFormatLibrary.class,
new LotroFormatLibrary(
extract(objectMap, LotroCardBlueprintLibrary.class)));
objectMap.put(GameHistoryService.class,
new GameHistoryService(
extract(objectMap, GameHistoryDAO.class)));
objectMap.put(GameRecorder.class,
new GameRecorder(
extract(objectMap, GameHistoryService.class)));
objectMap.put(DeliveryService.class,
new DeliveryService());
objectMap.put(CollectionsManager.class,
new CollectionsManager(
extract(objectMap, PlayerDAO.class),
extract(objectMap, CollectionDAO.class),
extract(objectMap, DeliveryService.class),
extract(objectMap, LotroCardBlueprintLibrary.class)));
objectMap.put(LeagueService.class,
new LeagueService(
extract(objectMap, LeagueDAO.class),
extract(objectMap, LeagueMatchDAO.class),
extract(objectMap, LeagueParticipationDAO.class),
extract(objectMap, CollectionsManager.class)));
objectMap.put(TournamentService.class,
new TournamentService(
extract(objectMap, TournamentDAO.class),
extract(objectMap, TournamentPlayerDAO.class),
extract(objectMap, TournamentMatchDAO.class)));
objectMap.put(MerchantService.class,
new MerchantService(
extract(objectMap, LotroCardBlueprintLibrary.class),
extract(objectMap, CollectionsManager.class),
extract(objectMap, MerchantDAO.class)));
objectMap.put(ChatServer.class, new ChatServer());
objectMap.put(LotroServer.class,
new LotroServer(
extract(objectMap, DeckDAO.class),
extract(objectMap, LotroCardBlueprintLibrary.class),
extract(objectMap, ChatServer.class),
extract(objectMap, GameRecorder.class)));
objectMap.put(DraftServer.class,
new DraftServer());
objectMap.put(HallServer.class,
new HallServer(
extract(objectMap, LotroServer.class),
extract(objectMap, DraftServer.class),
extract(objectMap, ChatServer.class),
extract(objectMap, LeagueService.class),
extract(objectMap, TournamentService.class),
extract(objectMap, LotroCardBlueprintLibrary.class),
extract(objectMap, LotroFormatLibrary.class),
extract(objectMap, CollectionsManager.class),
false));
}
private static <T> T extract(Map<Type, Object> objectMap, Class<T> clazz) {
T result = (T) objectMap.get(clazz);
if (result == null)
throw new RuntimeException("Unable to find class " + clazz.getName());
return result;
}
public static void constructObjects(Map<Type, Object> objectMap) {
extract(objectMap, HallServer.class).startServer();
extract(objectMap, DraftServer.class).startServer();
extract(objectMap, LotroServer.class).startServer();
extract(objectMap, ChatServer.class).startServer();
}
public static void destroyObjects(Map<Type, Object> objectMap) {
extract(objectMap, HallServer.class).stopServer();
extract(objectMap, DraftServer.class).stopServer();
extract(objectMap, LotroServer.class).stopServer();
extract(objectMap, ChatServer.class).stopServer();
}
}

View File

@@ -1,292 +0,0 @@
package com.gempukku.lotro.server.provider;
import com.gempukku.lotro.chat.ChatServer;
import com.gempukku.lotro.collection.CollectionsManager;
import com.gempukku.lotro.collection.DeliveryService;
import com.gempukku.lotro.db.*;
import com.gempukku.lotro.draft.DraftServer;
import com.gempukku.lotro.game.GameHistoryService;
import com.gempukku.lotro.game.GameRecorder;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.game.LotroServer;
import com.gempukku.lotro.game.formats.LotroFormatLibrary;
import com.gempukku.lotro.hall.HallServer;
import com.gempukku.lotro.league.LeagueService;
import com.gempukku.lotro.merchant.MerchantService;
import com.gempukku.lotro.tournament.TournamentDAO;
import com.gempukku.lotro.tournament.TournamentMatchDAO;
import com.gempukku.lotro.tournament.TournamentPlayerDAO;
import com.gempukku.lotro.tournament.TournamentService;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.core.spi.component.ComponentScope;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.InjectableProvider;
import javax.annotation.PreDestroy;
import javax.ws.rs.core.Context;
import javax.ws.rs.ext.Provider;
import java.lang.reflect.Type;
@Provider
public class ServerProvider implements InjectableProvider<Context, Type> {
private Injectable<ChatServer> _chatServerInjectable;
private Injectable<LeagueService> _leagueServiceInjectable;
private Injectable<GameHistoryService> _gameHistoryServiceInjectable;
private Injectable<MerchantService> _merchantServiceInjectable;
private Injectable<TournamentService> _tournamentServiceInjectable;
private Injectable<HallServer> _hallServerInjectable;
private Injectable<LotroServer> _lotroServerInjectable;
private Injectable<DraftServer> _draftServerInjectable;
private Injectable<CollectionsManager> _collectionsManagerInjectable;
private Injectable<DeliveryService> _deliveryServiceInjectable;
private Injectable<LotroFormatLibrary> _lotroFormatLibraryInjectable;
private Injectable<GameRecorder> _gameRecorderInjectable;
@Context
private PlayerDAO _playerDao;
@Context
private DeckDAO _deckDao;
@Context
private CollectionDAO _collectionDao;
@Context
private MerchantDAO _merchantDao;
@Context
private LeagueDAO _leagueDao;
@Context
private LeagueMatchDAO _leagueMatchDao;
@Context
private LeagueParticipationDAO _leagueParticipationDao;
@Context
private GameHistoryDAO _gameHistoryDao;
@Context
private TournamentDAO _tournamentDao;
@Context
private TournamentPlayerDAO _tournamentPlayerDao;
@Context
private TournamentMatchDAO _tournamentMatchDao;
@Context
private LotroCardBlueprintLibrary _library;
@Override
public Injectable getInjectable(ComponentContext ic, Context context, Type type) {
if (type.equals(ChatServer.class))
return getChatServerInjectable();
if (type.equals(LotroServer.class))
return getLotroServerInjectable();
if (type.equals(DraftServer.class))
return getDraftServerInjectable();
if (type.equals(HallServer.class))
return getHallServerInjectable();
if (type.equals(LeagueService.class))
return getLeagueServiceInjectable();
if (type.equals(GameHistoryService.class))
return getGameHistoryServiceInjectable();
if (type.equals(CollectionsManager.class))
return getCollectionsManagerInjectable();
if (type.equals(DeliveryService.class))
return getDeliveryServiceInjectable();
if (type.equals(LotroFormatLibrary.class))
return getLotroFormatLibraryInjectable();
if (type.equals(MerchantService.class))
return getMerchantServiceInjectable();
if (type.equals(TournamentService.class))
return getTournamentServiceInjectable();
if (type.equals(GameRecorder.class))
return getGameRecorderInjectable();
return null;
}
@PreDestroy
public void destroyResources() {
getHallServerInjectable().getValue().stopServer();
// getTradeServerInjectable().getValue().stopServer();
getLotroServerInjectable().getValue().stopServer();
getChatServerInjectable().getValue().stopServer();
}
private synchronized Injectable<LotroFormatLibrary> getLotroFormatLibraryInjectable() {
if (_lotroFormatLibraryInjectable == null) {
final LotroFormatLibrary lotroFormatLibrary = new LotroFormatLibrary(_library);
_lotroFormatLibraryInjectable = new Injectable<LotroFormatLibrary>() {
@Override
public LotroFormatLibrary getValue() {
return lotroFormatLibrary;
}
};
}
return _lotroFormatLibraryInjectable;
}
private synchronized Injectable<LeagueService> getLeagueServiceInjectable() {
if (_leagueServiceInjectable == null) {
final LeagueService leagueService = new LeagueService(_leagueDao, _leagueMatchDao, _leagueParticipationDao, getCollectionsManagerInjectable().getValue());
_leagueServiceInjectable = new Injectable<LeagueService>() {
@Override
public LeagueService getValue() {
return leagueService;
}
};
}
return _leagueServiceInjectable;
}
private synchronized Injectable<GameHistoryService> getGameHistoryServiceInjectable() {
if (_gameHistoryServiceInjectable == null) {
final GameHistoryService gameHistoryServiceleagueService = new GameHistoryService(_gameHistoryDao);
_gameHistoryServiceInjectable = new Injectable<GameHistoryService>() {
@Override
public GameHistoryService getValue() {
return gameHistoryServiceleagueService;
}
};
}
return _gameHistoryServiceInjectable;
}
private synchronized Injectable<GameRecorder> getGameRecorderInjectable() {
if (_gameRecorderInjectable == null) {
final GameRecorder gameRecorder = new GameRecorder(getGameHistoryServiceInjectable().getValue());
_gameRecorderInjectable = new Injectable<GameRecorder>() {
@Override
public GameRecorder getValue() {
return gameRecorder;
}
};
}
return _gameRecorderInjectable;
}
private synchronized Injectable<MerchantService> getMerchantServiceInjectable() {
if (_merchantServiceInjectable == null) {
final MerchantService merchantService = new MerchantService(_library, getCollectionsManagerInjectable().getValue(), _merchantDao);
_merchantServiceInjectable = new Injectable<MerchantService>() {
@Override
public MerchantService getValue() {
return merchantService;
}
};
}
return _merchantServiceInjectable;
}
private synchronized Injectable<TournamentService> getTournamentServiceInjectable() {
if (_tournamentServiceInjectable == null) {
final TournamentService tournamentService = new TournamentService(_tournamentDao, _tournamentPlayerDao, _tournamentMatchDao);
_tournamentServiceInjectable = new Injectable<TournamentService>() {
@Override
public TournamentService getValue() {
return tournamentService;
}
};
}
return _tournamentServiceInjectable;
}
private synchronized Injectable<DeliveryService> getDeliveryServiceInjectable() {
if (_deliveryServiceInjectable == null) {
final DeliveryService deliveryService = new DeliveryService();
_deliveryServiceInjectable = new Injectable<DeliveryService>() {
@Override
public DeliveryService getValue() {
return deliveryService;
}
};
}
return _deliveryServiceInjectable;
}
private synchronized Injectable<HallServer> getHallServerInjectable() {
if (_hallServerInjectable == null) {
final HallServer hallServer = new HallServer(
getLotroServerInjectable().getValue(),
getDraftServerInjectable().getValue(),
getChatServerInjectable().getValue(), getLeagueServiceInjectable().getValue(),
getTournamentServiceInjectable().getValue(), _library,
getLotroFormatLibraryInjectable().getValue(), getCollectionsManagerInjectable().getValue(), false);
hallServer.startServer();
_hallServerInjectable = new Injectable<HallServer>() {
@Override
public HallServer getValue() {
return hallServer;
}
};
}
return _hallServerInjectable;
}
// private synchronized Injectable<TradeServer> getTradeServerInjectable() {
// if (_tradeServerInjectable == null) {
// final TradeServer tradeServer = new TradeServer(getChatServerInjectable().getValue());
// tradeServer.startServer();
// _tradeServerInjectable = new Injectable<TradeServer>() {
// @Override
// public TradeServer getValue() {
// return tradeServer;
// }
// };
// }
// return _tradeServerInjectable;
// }
//
private synchronized Injectable<LotroServer> getLotroServerInjectable() {
if (_lotroServerInjectable == null) {
final LotroServer lotroServer = new LotroServer(_deckDao, _library, getChatServerInjectable().getValue(), getGameRecorderInjectable().getValue());
lotroServer.startServer();
_lotroServerInjectable = new Injectable<LotroServer>() {
@Override
public LotroServer getValue() {
return lotroServer;
}
};
}
return _lotroServerInjectable;
}
private synchronized Injectable<DraftServer> getDraftServerInjectable() {
if (_draftServerInjectable == null) {
final DraftServer draftServer = new DraftServer();
draftServer.startServer();
_draftServerInjectable = new Injectable<DraftServer>() {
@Override
public DraftServer getValue() {
return draftServer;
}
};
}
return _draftServerInjectable;
}
private synchronized Injectable<ChatServer> getChatServerInjectable() {
if (_chatServerInjectable == null) {
final ChatServer chatServer = new ChatServer();
chatServer.startServer();
_chatServerInjectable = new Injectable<ChatServer>() {
@Override
public ChatServer getValue() {
return chatServer;
}
};
}
return _chatServerInjectable;
}
private synchronized Injectable<CollectionsManager> getCollectionsManagerInjectable() {
if (_collectionsManagerInjectable == null) {
final CollectionsManager collectionsManager = new CollectionsManager(_playerDao, _collectionDao, getDeliveryServiceInjectable().getValue(), _library);
_collectionsManagerInjectable = new Injectable<CollectionsManager>() {
@Override
public CollectionsManager getValue() {
return collectionsManager;
}
};
}
return _collectionsManagerInjectable;
}
@Override
public ComponentScope getScope() {
return ComponentScope.Singleton;
}
}

View File

@@ -22,5 +22,6 @@
<root>
<level value="error"/>
<appender-ref ref="R"/>
<appender-ref ref="stdout"/>
</root>
</log4j:configuration>

View File

@@ -0,0 +1,10 @@
package com.gempukku.lotro.server.provider;
import org.junit.Test;
public class MapProviderTest {
@Test
public void testCreate() {
MapProvider provider = new MapProvider();
}
}