Atavism Version 2018.1AGIS API

atavism.server.plugins
Class ObjectManagerClient

java.lang.Object
  extended by atavism.server.plugins.ObjectManagerClient

public class ObjectManagerClient
extends java.lang.Object

Interface to the object manager plugin. The object manager can create, load, unload, and delete distributed objects. Objects can be persistent or non-persistent.

The object manager also provides a mechanism for saving non-distributed object data.


Nested Class Summary
static class ObjectManagerClient.DeleteObjectMessage
          Delete object based on OID.
static class ObjectManagerClient.DeleteSubObjectMessage
           
static class ObjectManagerClient.FixWorldNodeMessage
           
static class ObjectManagerClient.GenerateObjectMessage
           
static class ObjectManagerClient.GenerateSubObjectMessage
           
static class ObjectManagerClient.GetMatchingObjectsMessage
           
static class ObjectManagerClient.GetNamedObjectMessage
           
static class ObjectManagerClient.GetTemplateMessage
           
static class ObjectManagerClient.LoadObjectDataMessage
           
static class ObjectManagerClient.LoadObjectMessage
          can be either based on oid (which is stored in data) or key which is stored in a data member one and only one must be non-null.
static class ObjectManagerClient.LoadSubObjectMessage
           
static class ObjectManagerClient.ModifyNamespaceMessage
           
static class ObjectManagerClient.ObjectStatus
          Object status information.
static class ObjectManagerClient.RegisterTemplateMessage
           
static class ObjectManagerClient.SaveObjectDataMessage
           
static class ObjectManagerClient.SaveObjectMessage
           
static class ObjectManagerClient.SetPersistenceMessage
           
static class ObjectManagerClient.SetSubPersistenceMessage
           
static class ObjectManagerClient.SubObjectDepsReadyMessage
          the object manager plugin is saying that the plugin registered for 'namespace' has all its dependencies satisfied for the given object
static class ObjectManagerClient.UnloadObjectMessage
          Unload object based on OID.
static class ObjectManagerClient.UnloadSubObjectMessage
           
 
Field Summary
static java.lang.String BASE_TEMPLATE
          Name of an empty template.
static int BASE_TEMPLATE_ID
           
static MessageType MSG_TYPE_DELETE_OBJECT
           
static MessageType MSG_TYPE_DELETE_SUBOBJECT
           
static MessageType MSG_TYPE_FIX_WNODE_REQ
           
static MessageType MSG_TYPE_GENERATE_OBJECT
           
static MessageType MSG_TYPE_GENERATE_SUB_OBJECT
           
static MessageType MSG_TYPE_GET_MATCHING_OBJECTS
           
static MessageType MSG_TYPE_GET_NAMED_OBJECT
           
static MessageType MSG_TYPE_GET_OBJECT_STATUS
           
static MessageType MSG_TYPE_GET_TEMPLATE
           
static MessageType MSG_TYPE_GET_TEMPLATE_NAMES
           
static MessageType MSG_TYPE_LOAD_OBJECT
           
static MessageType MSG_TYPE_LOAD_OBJECT_DATA
           
static MessageType MSG_TYPE_LOAD_SUBOBJECT
           
static MessageType MSG_TYPE_MODIFY_NAMESPACE
           
static MessageType MSG_TYPE_REGISTER_TEMPLATE
           
static MessageType MSG_TYPE_SAVE_OBJECT
           
static MessageType MSG_TYPE_SAVE_OBJECT_DATA
           
static MessageType MSG_TYPE_SAVE_SUBOBJECT
           
static MessageType MSG_TYPE_SET_PERSISTENCE
           
static MessageType MSG_TYPE_SET_SUBPERSISTENCE
           
static MessageType MSG_TYPE_SUB_OBJECT_DEPS_READY
           
static MessageType MSG_TYPE_UNLOAD_OBJECT
           
static MessageType MSG_TYPE_UNLOAD_SUBOBJECT
           
static java.lang.String TEMPL_CURRENT_INSTANCE_NAME
           
static java.lang.String TEMPL_INSTANCE_RESTORE_STACK
           
static java.lang.String TEMPL_PERSISTENT
           
 
Constructor Summary
ObjectManagerClient()
           
 
Method Summary
static java.lang.Boolean addSubObjectNamespace(OID oid, java.util.Collection<Namespace> namespaces)
           
static java.lang.Boolean deleteObject(OID oid)
          Delete an object.
static boolean fixWorldNode(OID oid, BasicWorldNode worldNode)
          Modify location of persistent object.
static OID generateLight(OID instanceOid, LightData lightData)
          Create a point light object.
static OID generateObject(int templateID, java.lang.String templateType, OID instanceOid, Point loc)
          Create an object.
static OID generateObject(int templateID, java.lang.String templateType, Point loc)
          Create an object.
static OID generateObject(int templateID, java.lang.String templateType, Template overrideTemplate)
          Create an object.
static java.util.List<OID> getMatchingObjects(OID instanceOid, java.lang.String name, ObjectType objectType, java.util.Map<Namespace,java.util.Map<java.lang.String,java.io.Serializable>> filters)
          Get a list of object ids based on various filters.
static OID getNamedObject(OID instanceOid, java.lang.String name, ObjectType objectType)
          Get object id by name.
static ObjectManagerClient.ObjectStatus getObjectStatus(OID oid)
          Get object status.
static Template getTemplate(int templateID, java.lang.String templateType)
          Get object property template.
static java.util.List<java.lang.String> getTemplateNames(java.lang.String templateType)
          Get registered template names.
static OID loadObject(OID oid)
          Load a persistent object.
static OID loadObject(java.lang.String key)
          Load a persistent object by persistence key.
static Entity loadObjectData(OID oid, Namespace namespace)
          Load persistent sub-object.
static Entity loadObjectData(java.lang.String persistenceKey)
          Load persistent entity from the database by persistence key.
static OID loadSubObject(OID oid, java.util.Collection<Namespace> namespaces)
           
static boolean registerTemplate(Template template)
          Register object property template.
static boolean saveObject(OID oid)
          Save persistent object.
static boolean saveObject(OID oid, java.lang.String persistenceKey)
          Save persistent object with persistence key.
static boolean saveObjectData(java.lang.String persistenceKey, Entity entity, Namespace namespace)
          Save a sub-object.
static void setPersistenceFlag(OID oid, boolean flag)
          Set object persistence flag.
static java.lang.Boolean unloadObject(OID oid)
          Unload an object.
static java.lang.Boolean unloadSubObject(OID oid, java.util.Collection<Namespace> namespaces)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSG_TYPE_SET_PERSISTENCE

public static final MessageType MSG_TYPE_SET_PERSISTENCE

MSG_TYPE_SET_SUBPERSISTENCE

public static final MessageType MSG_TYPE_SET_SUBPERSISTENCE

MSG_TYPE_MODIFY_NAMESPACE

public static final MessageType MSG_TYPE_MODIFY_NAMESPACE

MSG_TYPE_LOAD_OBJECT

public static final MessageType MSG_TYPE_LOAD_OBJECT

MSG_TYPE_LOAD_SUBOBJECT

public static final MessageType MSG_TYPE_LOAD_SUBOBJECT

MSG_TYPE_UNLOAD_OBJECT

public static final MessageType MSG_TYPE_UNLOAD_OBJECT

MSG_TYPE_UNLOAD_SUBOBJECT

public static final MessageType MSG_TYPE_UNLOAD_SUBOBJECT

MSG_TYPE_DELETE_OBJECT

public static final MessageType MSG_TYPE_DELETE_OBJECT

MSG_TYPE_DELETE_SUBOBJECT

public static final MessageType MSG_TYPE_DELETE_SUBOBJECT

MSG_TYPE_LOAD_OBJECT_DATA

public static final MessageType MSG_TYPE_LOAD_OBJECT_DATA

MSG_TYPE_SAVE_OBJECT_DATA

public static final MessageType MSG_TYPE_SAVE_OBJECT_DATA

MSG_TYPE_SAVE_OBJECT

public static final MessageType MSG_TYPE_SAVE_OBJECT

MSG_TYPE_SAVE_SUBOBJECT

public static final MessageType MSG_TYPE_SAVE_SUBOBJECT

MSG_TYPE_GENERATE_OBJECT

public static final MessageType MSG_TYPE_GENERATE_OBJECT

MSG_TYPE_GENERATE_SUB_OBJECT

public static final MessageType MSG_TYPE_GENERATE_SUB_OBJECT

MSG_TYPE_SUB_OBJECT_DEPS_READY

public static final MessageType MSG_TYPE_SUB_OBJECT_DEPS_READY

MSG_TYPE_REGISTER_TEMPLATE

public static final MessageType MSG_TYPE_REGISTER_TEMPLATE

MSG_TYPE_GET_TEMPLATE

public static final MessageType MSG_TYPE_GET_TEMPLATE

MSG_TYPE_GET_TEMPLATE_NAMES

public static final MessageType MSG_TYPE_GET_TEMPLATE_NAMES

MSG_TYPE_FIX_WNODE_REQ

public static final MessageType MSG_TYPE_FIX_WNODE_REQ

MSG_TYPE_GET_NAMED_OBJECT

public static final MessageType MSG_TYPE_GET_NAMED_OBJECT

MSG_TYPE_GET_MATCHING_OBJECTS

public static final MessageType MSG_TYPE_GET_MATCHING_OBJECTS

MSG_TYPE_GET_OBJECT_STATUS

public static final MessageType MSG_TYPE_GET_OBJECT_STATUS

BASE_TEMPLATE

public static final java.lang.String BASE_TEMPLATE
Name of an empty template. The base template is always registered.

See Also:
#generateObject(String,Template), Constant Field Values

BASE_TEMPLATE_ID

public static final int BASE_TEMPLATE_ID
See Also:
Constant Field Values

TEMPL_PERSISTENT

public static final java.lang.String TEMPL_PERSISTENT
See Also:
Constant Field Values

TEMPL_INSTANCE_RESTORE_STACK

public static final java.lang.String TEMPL_INSTANCE_RESTORE_STACK
See Also:
Constant Field Values

TEMPL_CURRENT_INSTANCE_NAME

public static final java.lang.String TEMPL_CURRENT_INSTANCE_NAME
See Also:
Constant Field Values
Constructor Detail

ObjectManagerClient

public ObjectManagerClient()
Method Detail

generateObject

public static OID generateObject(int templateID,
                                 java.lang.String templateType,
                                 Template overrideTemplate)
Create an object. The object properties are initialized from the registered templateName merged with the overrideTemplate. Properties in the override template take precedence over those in the registered template.

To create a persistent object, set the persistent property to true.

            Java:
            template.put(Namespace.OBJECT_MANAGER,
                ObjectManagerClient.TEMPL_PERSISTENT, true)
            Python:
            template.put(Namespace.OBJECT_MANAGER,
                ObjectManagerClient.TEMPL_PERSISTENT, Boolean(True))
        

Perceivable objects (those with a location) must have an instance oid property (Namespace.WORLD_MANAGER, WorldManagerClient.TEMPL_INSTANCE, type OID).

Parameters:
templateName - Registered template. If you don't want to use a registered template, then pass ObjectManagerClient.BASE_TEMPLATE.
overrideTemplate - Override template, may be null.
Returns:
Object oid on success, null on failure.

generateObject

public static OID generateObject(int templateID,
                                 java.lang.String templateType,
                                 Point loc)
Create an object. The object properties are initialized from the registered templateName. The object location is set via loc. To make the object perceivable, the caller must spawn the object in the world manager.

Parameters:
templateName - Registered template.
loc - Object location.
Returns:
Object oid on success, null on failure.
See Also:
#generateObject(String,Template)

generateObject

public static OID generateObject(int templateID,
                                 java.lang.String templateType,
                                 OID instanceOid,
                                 Point loc)
Create an object. The object properties are initialized from the registered templateName. The object location is set via instanceOid and loc. To make the object perceivable, the caller must spawn the object in the world manager.

Parameters:
templateName - Registered template.
instanceOid - Object instance.
loc - Object location.
Returns:
Object oid on success, null on failure.
See Also:
#generateObject(String,Template)

generateLight

public static OID generateLight(OID instanceOid,
                                LightData lightData)
Create a point light object.

Parameters:
instanceOid - Instance oid.
lightData - Point light data.
Returns:
Light object oid, or null on failure

loadObject

public static OID loadObject(OID oid)
Load a persistent object. The master object is loaded from the database, then each of the sub-objects. If the object is already loaded, then nothing is done and the call returns success. If the object is partially loaded, then the missing sub-objects are loaded. If the object is in an instance, the instance is automatically loaded prior to loading sub-objects.

Returns:
Oid of object on success, null on failure

loadObject

public static OID loadObject(java.lang.String key)
Load a persistent object by persistence key. The object is selected by persistence key instead of OID. Otherwise behaves the same as loadObject(OID).

Returns:
Oid of object on success, null on failure.

unloadObject

public static java.lang.Boolean unloadObject(OID oid)
Unload an object. The sub-objects are unloaded, then the master object is unloaded. All memory used by the object should be released by this call. If the object is persistent, it will be saved before unloading.

If the object is an instance, contained objects (excluding players) will be unloaded. However, the correct way to unload an instance is InstanceClient.unloadInstance(atavism.server.engine.OID).

Returns:
True on success, false on failure.

addSubObjectNamespace

public static java.lang.Boolean addSubObjectNamespace(OID oid,
                                                      java.util.Collection<Namespace> namespaces)

loadSubObject

public static OID loadSubObject(OID oid,
                                java.util.Collection<Namespace> namespaces)

unloadSubObject

public static java.lang.Boolean unloadSubObject(OID oid,
                                                java.util.Collection<Namespace> namespaces)

deleteObject

public static java.lang.Boolean deleteObject(OID oid)
Delete an object. The sub-objects are deleted, then the master object is deleted. Persistent objects are deleted from the database (master object and all sub-objects). Does not delete instance contents. To delete an instance use InstanceClient.deleteInstance(atavism.server.engine.OID).

Returns:
True on success, false on failure.

saveObject

public static boolean saveObject(OID oid,
                                 java.lang.String persistenceKey)
Save persistent object with persistence key. The sub-objects are saved, then the master object is saved. The call returns when the save is complete. The call does nothing for non-persistent objects.

Parameters:
oid - Object identifier
persistenceKey - Unique object identifier. Replaces previous persistence key.
Returns:
True on success, false on failure.

saveObject

public static boolean saveObject(OID oid)
Save persistent object. The sub-objects are saved, then the master object is saved. The call returns when the save is complete. The call does nothing for non-persistent objects.

Returns:
True on success, false on failure.

saveObjectData

public static boolean saveObjectData(java.lang.String persistenceKey,
                                     Entity entity,
                                     Namespace namespace)
Save a sub-object. The supplied Entity is saved in the database under the given namespace (which identifies the sub-object). The entity must have an oid. Only the Beans Serializable portions of the Entity are saved. The Entity persistence flag is ignored; this call always saves the Entity.

Parameters:
persistenceKey - Object persistence key, null for no key
entity - Entity to save
namespace - Entity's namespace
Returns:
True on success, false on failure.

loadObjectData

public static Entity loadObjectData(java.lang.String persistenceKey)
Load persistent entity from the database by persistence key.

Parameters:
persistenceKey - Object persistence key.
Returns:
The loaded Entity, or null on failure

loadObjectData

public static Entity loadObjectData(OID oid,
                                    Namespace namespace)
Load persistent sub-object. Loads the sub-object from the database, but does not register the master or sub-objects.

Parameters:
oid - The object oid.
namespace - The sub-object namespace.
Returns:
The loaded Entity, or null on failure

registerTemplate

public static boolean registerTemplate(Template template)
Register object property template. The template name is taken from Template.getName(). Replaces an existing template with the same name. Registered templates are used to create objects.

Returns:
True on success, false on failure
See Also:
#generateObject(String,Template)

getTemplate

public static Template getTemplate(int templateID,
                                   java.lang.String templateType)
Get object property template.

Returns:
Template or null if it does not exist.

setPersistenceFlag

public static void setPersistenceFlag(OID oid,
                                      boolean flag)
Set object persistence flag. Objects that are persistent will be saved by the persistence manager. This will set the persistence flag on the master object (in the object manager plugin) and the object's sub-objects.


fixWorldNode

public static boolean fixWorldNode(OID oid,
                                   BasicWorldNode worldNode)
Modify location of persistent object. The object's world manager sub-object is directly modified in the database. The object location, orientation, and direction can be independently modified. Null values in the @p worldNode are ignored.

This call should only be used when the object's world manager sub-object is NOT loaded. The ProxyPlugin uses fixWorldNode() during player login when their logout instance no longer exists.

Returns:
True on success, false on failure.

getTemplateNames

public static java.util.List<java.lang.String> getTemplateNames(java.lang.String templateType)
Get registered template names.

Returns:
List of template names.

getNamedObject

public static OID getNamedObject(OID instanceOid,
                                 java.lang.String name,
                                 ObjectType objectType)
Get object id by name. If instanceOid is non-null, the lookup is confined to the instance content. Only works on loaded instances and loaded objects. If instanceOid is null, lookup considers all loaded objects.

If objectType is non-null, both the name and object type must match.

Object names are set at creation time from the WorldManager object name (WorldManagerClient.TEMPL_NAME) or the Template name.

NOTE: Object lookup is currently an O(N) operation.

Parameters:
instanceOid - Instance oid, may be null.
name - Object name.
objectType - Object type, may be null.
Returns:
Object oid or null if instance or named object are not found.

getMatchingObjects

public static java.util.List<OID> getMatchingObjects(OID instanceOid,
                                                     java.lang.String name,
                                                     ObjectType objectType,
                                                     java.util.Map<Namespace,java.util.Map<java.lang.String,java.io.Serializable>> filters)
Get a list of object ids based on various filters. If instanceOid is non-null, the lookup is confined to the instance content. Only works on loaded instances and loaded objects. If instanceOid is null, lookup considers all loaded objects.

If objectType is non-null, both the name and object type must match.

Object names are set at creation time from the WorldManager object name (WorldManagerClient.TEMPL_NAME) or the Template name.

NOTE: Object lookup is currently an O(N) operation.

Parameters:
instanceOid - Instance oid, may be null.
name - Object name.
objectType - Object type, may be null.
filters - mapping of property name to required value
Returns:
Object oid or null if instance or named object are not found.

getObjectStatus

public static ObjectManagerClient.ObjectStatus getObjectStatus(OID oid)
Get object status. Returns information about the object including name, type, and sub-object namespaces. See ObjectManagerClient.ObjectStatus for a complete list. If the object is loaded, then ObjectStatus.namespaces will be non-null and ObjectStatus.loadedNamespaces will contain the currently loaded namespaces. If the object is not loaded, then ObjectStatus.namespaces will be null, but ObjectStatus.name will contain the object name (if it has one), if the object exists.



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