Package marauroa.server.game.db
Class DAORegister
java.lang.Object
marauroa.server.game.db.DAORegister
Keeps track of the DAOs (data access objects) to use. They are registered
using their class name:
register(CharacterDAO.class, new CharacterDAO());
Games can add their own DAOs. They can even replace framework DAOs
with their own subclasses. Stendhal for example enhances the normal
CharacterDAO with its own subclass to update a redundant table used
by the Stendhal website:
DAORegister.get().register(CharacterDAO.class, new StendhalCharacterDAO());
Game should register their DAOs in the "initialize()" method of their DatabaseFactory,
as defined in the server.ini:
database_implementation=games.demo.server.DemoDatabaseFactory
- Author:
- hendrik
-
Method Summary
Modifier and TypeMethodDescriptionstatic DAORegister
get()
gets the singleton DAORegister instance<T> T
gets the instance for the requested DAOgets the RPObjectFactory<T> void
registers a DAO
-
Method Details
-
get
gets the singleton DAORegister instance- Returns:
- DAORegister
-
register
registers a DAO- Type Parameters:
T
- type of DOA- Parameters:
clazz
- class of DOAobject
- instance of DOA
-
get
gets the instance for the requested DAO- Type Parameters:
T
- type of DAO- Parameters:
clazz
- class of DAO- Returns:
- instance of DOA
- Throws:
IllegalArgumentException
- in case there is no instance registered for the specified class
-
getRPObjectFactory
gets the RPObjectFactory- Returns:
- RPObjectFactory
-