org.bluesock.bluemud.driver
Class ObjectFactory

java.lang.Object
  |
  +--org.bluesock.bluemud.driver.ObjectFactory

public class ObjectFactory
extends java.lang.Object

The ObjectFactory is responsible for the creation of all in-game objects. Both shared and non-shared objects are supported (by default, created objects are not shared). If an object is shared, only one instance of that object will be created; that instance will always be returned. Note that all objects loaded through this factory MUST ultimately be derived from org.bluesock.bluemud.lib.MudObject. The factory also supports the concept of aliased objects. These objects are given a special "alias" by which they can be referred, independent of their actual Python names. Aliased objects are normally used as bridges between standard and project-specific code (for example, when referring to the initial room that a player should be moved to upon login). Finally, the factory supports the notion of grouped object instances. Through the addGroupedInstance method, MudObject instances can be classified under named groups. Instances within the group can later be retrieved with the getGroupedInstances method. Instances can be removed from a named group with the removeGroupedInstance method.


Constructor Summary
ObjectFactory()
           
 
Method Summary
(package private)  void addGroupedInstance(java.lang.String groupName, MudObject instance)
          Classify a named MudObject under the given group.
(package private)  MudObject getAliasedObject(java.lang.String alias, boolean shared)
          Get an instance of an aliased world class.
(package private)  MudObject[] getGroupedInstances(java.lang.String groupName)
          Returns an array of MudObjects that were previously classified under the given group through a call to addGroupedInstance.
(package private)  MudObject getObject(OID objectIdentifier)
          Get a reference to a world class by way of it's object identifier.
(package private)  MudObject getObject(java.lang.String dottedPath)
          Get an instance of a world class.
(package private)  MudObject getObject(java.lang.String dottedPath, boolean shared)
          Get an instance of a world class.
(package private)  MudObject getObject(java.lang.String dottedPath, boolean shared, boolean reload)
          Get an instance of a world class.
(package private)  boolean hasSharedInstance(java.lang.String dottedPath)
          Determines if a loaded instance of the given path is currently being shared.
(package private)  void registerAlias(java.lang.String alias, java.lang.String dottedPath)
          Registers an alias with this factory, associating it with the given dottedPath.
(package private)  void removeGroupedInstance(java.lang.String groupName, MudObject instance)
          Removes the given MudObject from indicated group.
(package private)  void removeObject(MudObject o)
          Removes the given object from the map of all loaded objects and from the map of shared objects, if necessary.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectFactory

public ObjectFactory()
Method Detail

getObject

MudObject getObject(java.lang.String dottedPath)
Get an instance of a world class. This version of the method only supports non-shared objects.
Parameters:
dottedPath - - The dotted path of the class. For example: mudlib.core.Object
Returns:
A new instance of the Python class denoted by the dottedPath, or null if an instance could not be created.

getObject

MudObject getObject(java.lang.String dottedPath,
                    boolean shared)
Get an instance of a world class. If shared, the same instance will be returned for all invocations of this method. If not shared, a new instance will be created for each invocation.
Parameters:
dottedPath - - The dotted path of the class. For example: mudlib.core.Room
shared - - true if this object should be shared, false otherwise
Returns:
A new instance of the Python class denoted by the dottedPath, or null if an instance could not be created.

getObject

MudObject getObject(java.lang.String dottedPath,
                    boolean shared,
                    boolean reload)
Get an instance of a world class. If shared, the same instance will be returned for all invocations of this method. If not shared, a new instance will be created for each invocation.
Parameters:
dottedPath - - The dotted path of the class. For example: mudlib.core.Room
shared - - true if this object should be shared, false otherwise
reload - - true if the Python module housing the given class should first be reloaded prior to construction of an instance. If the class is shared, a new instance will be constructed that will replace the old shared instance. False otherwise.
Returns:
A new instance of the Python class denoted by the dottedPath, or null if an instance could not be created.

getObject

MudObject getObject(OID objectIdentifier)
Get a reference to a world class by way of it's object identifier.
Parameters:
objectIdentifier - - the OID of the world object in question

hasSharedInstance

boolean hasSharedInstance(java.lang.String dottedPath)
Determines if a loaded instance of the given path is currently being shared.
Parameters:
dottedPath - - The dotted path of the class. For example, mudlib.core.Room

getAliasedObject

MudObject getAliasedObject(java.lang.String alias,
                           boolean shared)
Get an instance of an aliased world class. If shared, the same instance will be returned for all invocations of this method. If not shared, a new instance will be created for each invocation.
Parameters:
alias - - The alias name of the object.
shared - - true if this object should be shared, false otherwise
Returns:
A new instance of the Python class aliased by the alias, or null if an instance could not be created.

addGroupedInstance

void addGroupedInstance(java.lang.String groupName,
                        MudObject instance)
Classify a named MudObject under the given group. MudObjects in the gruop can later be retrieved through the getGroupedInstances method, or removed from control through the removeNamedInstance method.
Parameters:
groupName - - Group name under which the MudObject should be classified.
instance - - The instance of the MudObject to group.

getGroupedInstances

MudObject[] getGroupedInstances(java.lang.String groupName)
Returns an array of MudObjects that were previously classified under the given group through a call to addGroupedInstance.
Parameters:
groupName - - The name of the group under which the desired MudObjects are classified. This must match a group name previously passed to addGroupedInstance.

removeGroupedInstance

void removeGroupedInstance(java.lang.String groupName,
                           MudObject instance)
Removes the given MudObject from indicated group.
Parameters:
groupName - - The name of the group from which the given MudObject should be removed. This must match a name previously passed to addGroupedInstance.
instance - - The MudObject to remove from the group.

registerAlias

void registerAlias(java.lang.String alias,
                   java.lang.String dottedPath)
Registers an alias with this factory, associating it with the given dottedPath. Objects pointed to by the dottedPath can be loaded by the alias through the getAliasedObject() method.
Parameters:
alias - - The alias to register
dottedPath - - The dotted path to the object being aliased. Example: world.sample.StartRoom

removeObject

void removeObject(MudObject o)
Removes the given object from the map of all loaded objects and from the map of shared objects, if necessary. This method does NOT remove the object from any instance groupings--that must be done explicitly through the removeGroupedInstance method.


docs generated on Thu Jan 24 08:57:26 CST 2002