Class RPObjectFactory

java.lang.Object
marauroa.server.game.rp.RPObjectFactory
Direct Known Subclasses:
StendhalRPObjectFactory

public class RPObjectFactory extends Object
This class is a factory to convert RPObjects into real objects for your game. This class is invoked by whatever that load an object into the server: - JDBCDatabase. To make it work on your game you need to subclass and implement: static RPObjectFactory getFactory() The method will be called through refletions.
Author:
miguel
  • Constructor Details

    • RPObjectFactory

      public RPObjectFactory()
  • Method Details

    • get

      public static RPObjectFactory get() throws NoFactoryConfException
      This method returns an instance of RPObjectFactory choosen using the Configuration file.
      Returns:
      A shared instance of RPObjectFactory
      Throws:
      NoFactoryConfException - if the factory is not configured correctly
    • get

      public static RPObjectFactory get(String factoryName) throws NoFactoryConfException
      This method returns an instance of RPObjectFactory chosen using the param.
      Parameters:
      factoryName - A String containing the type of factory. It should be the complete class name. ie: marauroa.server.game.rp.RPObjectFactory
      Returns:
      A shared instance of RPObjectFactory
      Throws:
      NoFactoryConfException - if the factory is not configured correctly
    • getFactory

      public static RPObjectFactory getFactory()
      gets the ObjectFactory, creating a default one in case it does not exist already
      Returns:
      RPObjectFactory
    • transform

      public RPObject transform(RPObject object)
      This method is called when object is serialized back from database to zone, so you can define which subclass of RPObject we are going to use. This implements a factory pattern. If you are not interested in this feature, just return the object
      Parameters:
      object - the original object
      Returns:
      the new instance of the object