Anatomy of a MeshObject
MeshObjects are the core structure holding information in InfoGrid. They have the following characteristics.
- Each MeshObject has a unique identifier, called the MeshObjectIdentifier. If two MeshObjects have the same MeshObjectIdentifier, they represent the same semantic concept. Any MeshBase cannot hold more than one MeshObject with the same MeshObjectIdentifier at a time. However, different NetMeshBases may hold Replicas of the same NetMeshObject.
- Any MeshObject can only migrate to a different MeshBase by means of XPRISO. This requires the MeshBase to be a NetMeshBase, and the MeshObject to be a NetMeshObject.
- Any MeshObject carries attributes indicating when the MeshObject was semantically created, when it was updated, and when it was last read. For performance reasons, the "last read" attribute only provides a best-effort value.
- Any MeshObject may carry an expiration time, after which it will not be valid any more. What happens when that time arrives is up to the enclosing MeshBase.
- When a MeshObject has been deleted, is it marked as "dead". Subsequent invocations of any of its methods throw an IsDeadException.
Types and Properties
- A MeshObject may or may not be blessed. If it is blessed, it may be blessed with an arbitrary number of EntityTypes. It may become blessed with all EntityTypes at the same time, or gradually. Analogously, it may be unblessed.
- A MeshObject can only be blessed with an EntityType that is not abstract. However, a NetMeshObject may be blessed with an EntityType that is both abstract and marked as being usable as a ForwardReference (this typically only occurs in Probes).
- A MeshObject carries all Properties defined by all EntityTypes that it is blessed with, and recursively all of their supertypes. As soon as the MeshObject is unblessed from an EntityType, the Properties defined by it and its supertypes disappear.
- A MeshObject can be queried for all meta-data, including which EntityTypes and PropertyTypes it currently supports.
- All operations on a MeshObject are being checked, by InfoGrid, for whether they are allowed by the Model or Models? applicable to the MeshObject. If they are not allowed, an exception is thrown and the operation is not performed.
- A MeshObject may be related to any number of neighbor MeshObjects. Any MeshObject may become the neighbor of any other MeshObject in the same MeshBase. To make a MeshObject the neighbor of a MeshObject in a different MeshBase, the MeshObjects must be NetMeshObjects, the MeshBases must be NetMeshBases, and XPRISO must be used to create a Replica of one of the NetMeshObjects first. That Replica then becomes the neighbor, thereby meeting the constraint that only MeshObjects in the same MeshBase may become neighbors.
- A MeshObject cannot be its own neighbor.
- A relationship between a MeshObject and its neighbor is undirected; only when blessed with a directed RelationshipType is a direction assigned.
- Each relationship between two MeshObjects may be blessed with one or more RelationshipTypes. Each RelationshipType must not be abstract. The source and destination MeshObject must already be blessed with any EntityTypes that the RelationshipType requires. If blessed with more than one RelationshipType, the relationship may be blessed in different directions from each RelationshipType.
- Analogously, it may be unblessed.
- Any MeshObject provides methods to traverse from it to its neighbor MeshObjects, possibly qualified by which RelationshipTypes any relationship must be blessed.
If a MeshObject is blessed with an EntityType X, a facade object can be obtained that implements interface X, as generated by the InfoGrid CodeGenerator. interface X is a subtype of org.infogrid.mesh.TypedMeshObjectFacade.
For example, if a MeshObject is blessed with EntityType org.infogrid.model.Tagging/TagLibrary, the InfoGrid CodeGenerator, during the build process, generated interface org.infogrid.model.Tagging.TagLibrary as well as an implementation class (whose name and behavior is not relevant as it is not exposed in the API). This interface will have getter and setter methods for all PropertyTypes declared in the EntityType according to JavaBeans conventions. It is a facade object in that it delegates all operations to the underlying MeshObject.
All changes to a MeshObject raise Events to which listeners can subscribe. To keep the API simple and stay with the JavaBeans event specification, these Events are raised as subclasses of PropertyChangeEvent.
For MeshObjects, they are:
- MeshObjectPropertyChangeEvent: a Property of the MeshObject has changed its value
- MeshObjectNeighborAddedEvent: the MeshObject has gained one neighbor MeshObject
- MeshObjectNeighborRemovedEvent: the MeshObject has lost a neighbor MeshObject
- MeshObjectTypeAddedEvent: the MeshObject was blessed with an EntityType
- MeshObjectTypeRemovedEvent: the MeshObject was unblessed from an EntityType
- MeshObjectRoleAddedEvent: one of the Relationships in which the MeshObject participates was blessed with a RelationshipType
- MeshObjectRoleRemovedEvent: one of the Relationships in which the MeshObject participates was unblessed from a RelationshipType
- MeshObjectBecameDeadStateEvent: the MeshObject was deleted
NetMeshObjects subclass some of those events, additionally raise the following events:
- LockChangedEvent.GainedLock: this Replica successfully acquired update rights from another Replica
- LockChangedEvent.LostLock: this Replica had update rights but lost it to another Replica
- HomeReplicaChangedEvent.GainedHomeReplica: this Replica acquired HomeReplica status from another Replica
- HomeReplicaChangedEvent.LostHomeReplica: this Replica lost HomeReplica status to another Replica
- NetMeshObjectBecamePurgedStateEvent: this Replica was purged but not semantically deleted
- NetMeshObjectPropertyChangeEvent: adds information to MeshObjectPropertyChangeEvent
- NetMeshObjectNeighborAddedEvent: adds information to MeshObjectNeighborAddedEvent
- NetMeshObjectNeighborRemovedEvent: adds information to MeshObjectNeighborRemovedEvent
- NetMeshObjectTypeAddedEvent: adds information to MeshObjectTypeAddedEvent
- NetMeshObjectTypeRemovedEvent: adds information to MeshObjectTypeRemovedEvent
- NetMeshObjectRoleAddedEvent: adds information to MeshObjectTypeAddedEvent
- NetMeshObjectRoleRemovedEvent: adds information to MeshObjectRoleRemovedEvent
- NetMeshObjectBecameDeadStateEvent: adds information to MeshObjectBecameDeadStateEvent