net.javamud.run
Class Linker

java.lang.Object
  |
  +--net.javamud.run.Linker

public class Linker
extends Object

Provides the ablility to link to MudObjects.

This class badly needs some synchronized statements in it's methods. (To prevent unexpected duplicate identities due to multi threading).

Author:
Timothy Hinchcliffe
Created On:
10 May 2002

Field Summary
protected  MORegistry mudObjects
          The global set of MudObjects
 
Constructor Summary
Linker()
          Constructor for the Linker object
 
Method Summary
 void deRef(MudObject m)
          Used to dereference m from all MudObjects.
 MudObject find(String identity)
          Locate a MudObject with the given identity.
 MudObject link(MudObject req, MudObject to)
          Record that req refers to to .
 MudObject link(MudObject req, String identity)
          Get a MudObject associated with identity.
 void register(MudObject mo)
          Register mo with the Linker.
 void replace(MudObject o, MudObject n)
          Replaces o with n accross the whole MUD.
 MudObject require(String identity)
          Find MudObject with given Identity or create a NullMudObject with that Identity.
 void unlink(MudObject req, MudObject target)
          Record that req no longer referances target .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mudObjects

protected MORegistry mudObjects
The global set of MudObjects

Constructor Detail

Linker

public Linker()
Constructor for the Linker object

Method Detail

deRef

public void deRef(MudObject m)
Used to dereference m from all MudObjects. (Effectively deleting it).

Parameters:
m - MudObject to dereferance
See Also:
MudObject.deRef(MudObject)

find

public MudObject find(String identity)
Locate a MudObject with the given identity.

Parameters:
identity - Identity to find.
Returns:
MudObject or null (if no match).

link

public MudObject link(MudObject req,
                      MudObject to)
Record that req refers to to . Note that to is returned for consistancy with link(MudObject,String).

Parameters:
req - MudObject to link
to - MudObject to link to
Returns:
to MudObject
See Also:
unlink(MudObject,MudObject)

link

public MudObject link(MudObject req,
                      String identity)
Get a MudObject associated with identity. Also registers a link.

Parameters:
identity - Identity to require()
req - Requesting MudObject
Returns:
MudObject that matches identity. (Created if needed).
See Also:
link(MudObject,MudObject), require(String)

register

public void register(MudObject mo)
              throws DuplicateIdentityException
Register mo with the Linker. MORegistry.add(MudObject) will expire any old identity.

Parameters:
mo - MudObject to register
Throws:
DuplicateIdentityException - Thrown if the new identity already exists with another object. (Note: mo will already have been removed from the registry at this point.)
See Also:
MORegistry.add(MudObject object)

replace

public void replace(MudObject o,
                    MudObject n)
             throws IllegalArgumentException
Replaces o with n accross the whole MUD.

Parameters:
o - Old MudObject
n - New MudObject
Throws:
IllegalArgumentException - Thrown if identities do not match
See Also:
MudObject.replace(MudObject,MudObject)

require

public MudObject require(String identity)
Find MudObject with given Identity or create a NullMudObject with that Identity.

Parameters:
identity - Identity to find/create.
Returns:
A MudObject with the given identity.
See Also:
find(String)

unlink

public void unlink(MudObject req,
                   MudObject target)
Record that req no longer referances target . More precisely, remove the record that req refers to target .

Parameters:
req - Requestor
target - Target
See Also:
link(MudObject,MudObject)