Class DAORegister

java.lang.Object
marauroa.server.game.db.DAORegister

public class DAORegister extends Object

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 Details

    • get

      public static DAORegister get()
      gets the singleton DAORegister instance
      Returns:
      DAORegister
    • register

      public <T> void register(Class<T> clazz, T object)
      registers a DAO
      Type Parameters:
      T - type of DOA
      Parameters:
      clazz - class of DOA
      object - instance of DOA
    • get

      public <T> T get(Class<T> clazz)
      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

      public RPObjectFactory getRPObjectFactory()
      gets the RPObjectFactory
      Returns:
      RPObjectFactory