Atavism Version 2018.1AGIS API

atavism.server.engine
Class Namespace

java.lang.Object
  extended by atavism.server.engine.Namespace
All Implemented Interfaces:
Marshallable, java.io.Serializable

public class Namespace
extends java.lang.Object
implements Marshallable, java.io.Serializable

For each conceptual object stored in the database, every plugin has the option of creating and maintaining one or more "sub-objects" containing just those members that are meaningful to that plugin. When it comes time to store them in the database, the plugin needs some unique token in addition to the objects oid to identify the each of the plugin's sub-objects. Namespace objects provide that unique token, and each plugin stores it's persistent objects in one or more namespaces that only that kind of plugin uses. Namespace objects are identified by a string, which is interned to produce a small integer, and the mappings between namespace strings and the small integers used to represent them is stored in the database. When the server starts up, each plugin reads the mapping into memory, creating Namespace objects for each entry in the mapping.

Namespace objects can be created on the fly, by calling the static method Namespace.intern(String name), which looks up the string in the in-memory map of Namespace strings. If the string is found, it returns the associated namespace object; otherwise, it stores the new namespace in the database, and creates and returns the newly-interned Namespace object.

At this point, the number of unique namespaces is limited to 31, because a set of namespaces must be compressed to fit integer with 1 bit per namespace.

An Entity, which represents a particular plugin's sub-object, "knows" what Namespace it belongs to.

See Also:
Serialized Form

Field Summary
static Namespace AGISITEM
          The second of two Inventory Plugin namespaces, used for inventory items
static Namespace BAG
          The first of two Inventory Plugin namespaces, used for inventory bags
static Namespace BILLING
          The Billing Plugin's namespace
static Namespace CLASSABILITY
          The ClassAbility Plugin's namespace
static Namespace COMBAT
          The Combat Plugin's namespace
static Namespace FACTION
           
static Namespace INSTANCE
          InstancePlugin namespace.
static Namespace MOB
          The Mob Manager Plugin's namespace
static Namespace OBJECT_MANAGER
          The Object Manager Plugin's namespace
static Namespace QUEST
          The first of two Quest Plugin namespaces, used for quests
static long serialVersionUID
           
static Namespace TRAINER
          The Trainer Plugin's namespace
static Namespace TRANSIENT
          The transient namespace, used when the plugin's subobject should not be stored persistently
static int transientNamespaceNumber
          The number of the transient namespace is hard-wired to 1
static Namespace VOICE
          A namespace for the voice plugin
static Namespace WM_INSTANCE
          World manager instance namespace.
static Namespace WORLD_MANAGER
          The World Manager Plugin's namespace
 
Constructor Summary
Namespace()
          Marshalling requires that there be a public no-args constructor, but nothing but marshalling should call this constructor
Namespace(java.lang.String name, int number)
          This constructor is private, since all Namespace objects should be created by Namespace.intern(String name)
 
Method Summary
static Namespace addDBNamespace(java.lang.String name, int number)
          This method is called by the database code to create interned Namespace objects as a result of a call to encacheNamespaceMapping.
static java.lang.Integer compressNamespaceList(java.util.Set<Namespace> namespaces)
          Given a set of Namespace objects, compress the set into an Integer, with 1 bit whose bit number is the number of the Namespace, or return null if the namespace set is null or has no elements.
static java.util.List<Namespace> decompressNamespaceList(java.lang.Integer namespacesInteger)
          Given an Integer with 1 bit whose bit number is the number of the Namespace, decompress into a Set
static void encacheNamespaceMapping()
          This method is called by Engine to encache database-resident Namespace objects.
 java.lang.String getName()
          Getter for the Namespace string name.
static Namespace getNamespace(java.lang.String nsString)
          Return the namespace associated with the string argument, or throw an error if no such namespace exists
static Namespace getNamespaceFromInt(java.lang.Integer nsInt)
          Return the namespace whose number is the Integer argument, or null if no such namespace exists
protected static Namespace getNamespaceFromIntOrError(java.lang.Integer nsInt)
           
static Namespace getNamespaceIfExists(java.lang.String nsString)
          Return the namespace associated with the string argument, or null if it does not exist.
 int getNumber()
          Getter for the Namespace number.
static Namespace intern(java.lang.String name)
          This is the external entrypoint used to create a namespace.
 void marshalObject(AOByteBuffer buf)
          When marshalled, a Namespace object is represented by a byte containing it's number.
 java.lang.String toString()
           
 java.lang.Object unmarshalObject(AOByteBuffer buf)
          The unmarshalling operation looks up the number read from the input stream in the mapping from number to Namespace object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRANSIENT

public static Namespace TRANSIENT
The transient namespace, used when the plugin's subobject should not be stored persistently


OBJECT_MANAGER

public static Namespace OBJECT_MANAGER
The Object Manager Plugin's namespace


WORLD_MANAGER

public static Namespace WORLD_MANAGER
The World Manager Plugin's namespace


COMBAT

public static Namespace COMBAT
The Combat Plugin's namespace


MOB

public static Namespace MOB
The Mob Manager Plugin's namespace


BAG

public static Namespace BAG
The first of two Inventory Plugin namespaces, used for inventory bags


AGISITEM

public static Namespace AGISITEM
The second of two Inventory Plugin namespaces, used for inventory items


QUEST

public static Namespace QUEST
The first of two Quest Plugin namespaces, used for quests


FACTION

public static Namespace FACTION

INSTANCE

public static Namespace INSTANCE
InstancePlugin namespace. See InstanceClient.


WM_INSTANCE

public static Namespace WM_INSTANCE
World manager instance namespace. See WorldManagerClient.


VOICE

public static Namespace VOICE
A namespace for the voice plugin


TRAINER

public static Namespace TRAINER
The Trainer Plugin's namespace


CLASSABILITY

public static Namespace CLASSABILITY
The ClassAbility Plugin's namespace


BILLING

public static Namespace BILLING
The Billing Plugin's namespace


transientNamespaceNumber

public static final int transientNamespaceNumber
The number of the transient namespace is hard-wired to 1

See Also:
Constant Field Values

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

Namespace

public Namespace()
Marshalling requires that there be a public no-args constructor, but nothing but marshalling should call this constructor


Namespace

public Namespace(java.lang.String name,
                 int number)
This constructor is private, since all Namespace objects should be created by Namespace.intern(String name)

Method Detail

getName

public java.lang.String getName()
Getter for the Namespace string name. There is no setter for the name. n


getNumber

public int getNumber()
Getter for the Namespace number. There is no setter for the number.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

marshalObject

public void marshalObject(AOByteBuffer buf)
When marshalled, a Namespace object is represented by a byte containing it's number.

Specified by:
marshalObject in interface Marshallable
Parameters:
buf - The byte buffer

unmarshalObject

public java.lang.Object unmarshalObject(AOByteBuffer buf)
The unmarshalling operation looks up the number read from the input stream in the mapping from number to Namespace object.

Specified by:
unmarshalObject in interface Marshallable

intern

public static Namespace intern(java.lang.String name)
This is the external entrypoint used to create a namespace. It looks up the string in the in-memory map of Namespace strings. If the string is found, it * returns the associated namespace object; otherwise, it stores the new namespace in the database, and creates and returns the newly-interned Namespace object.


addDBNamespace

public static Namespace addDBNamespace(java.lang.String name,
                                       int number)
This method is called by the database code to create interned Namespace objects as a result of a call to encacheNamespaceMapping. It should never be called by any other caller


encacheNamespaceMapping

public static void encacheNamespaceMapping()
This method is called by Engine to encache database-resident Namespace objects. It should never be called by any other caller.


getNamespace

public static Namespace getNamespace(java.lang.String nsString)
Return the namespace associated with the string argument, or throw an error if no such namespace exists


getNamespaceIfExists

public static Namespace getNamespaceIfExists(java.lang.String nsString)
Return the namespace associated with the string argument, or null if it does not exist.


getNamespaceFromInt

public static Namespace getNamespaceFromInt(java.lang.Integer nsInt)
Return the namespace whose number is the Integer argument, or null if no such namespace exists


getNamespaceFromIntOrError

protected static Namespace getNamespaceFromIntOrError(java.lang.Integer nsInt)

compressNamespaceList

public static java.lang.Integer compressNamespaceList(java.util.Set<Namespace> namespaces)
Given a set of Namespace objects, compress the set into an Integer, with 1 bit whose bit number is the number of the Namespace, or return null if the namespace set is null or has no elements.


decompressNamespaceList

public static java.util.List<Namespace> decompressNamespaceList(java.lang.Integer namespacesInteger)
Given an Integer with 1 bit whose bit number is the number of the Namespace, decompress into a Set



Copyright © 2018 Dragonsan Studios Sp. z o.o.