static Log log = LogFactory.getLog(object.class);
/**
- * unique id for all vamsas objects allows unambiguous referencing to any
- * object in the vamsas document
+ * true if object was stored in a vamsas Document or has been retrieved from it
*/
protected boolean __stored_in_document = false;
+ /**
+ * memory of the last doHash() value computed for the object
+ * @see doHash()
+ */
+ protected long __last_hash = 0;
+ /**
+ * set by testInstanceForIdField() if object should have a VorbaId
+ */
+ protected boolean registerable = false;
- protected long __last_hash = 0; // default is different so doHash always returns true initially.
-
- protected boolean registerable = false;
+ /**
+ * unique id for all vamsas objects allows unambiguous referencing to any
+ * object in the vamsas document
+ */
protected VorbaId vorbaId = null;
+ /**
+ * the source of unique VorbaIds.
+ */
protected IVorbaIdFactory __vorba = null;
/**
}
/**
- * set the isRegisterable flag based on the presence of a 'String id' field in
+ * set the isRegisterable flag based on the presence of a 'private String _id' field in
* the reflected class instance.
*/
private void testInstanceForIdField() {
}
/**
- * update the object instance's String id field, based on the contents of the
+ * update the object instance's _id field, based on the contents of the
* VorbaId. Only call this if you mean to do it!
*/
protected void setInstanceIdField() {
/**
* calculate a hash for the object with all housekeeping fields at standard
* values. (isRegisterable is an immutable attribute property)
+ * TODO: decide if __stored_in_document should be included in the hash or not.
* @return true if new hash different to last hash
*/
synchronized protected boolean doHash() {
/**
* for use by Vorba agent to reflect state of vamsas object to client
* application.
- *
- * @param __stored_in_document
- * The __stored_in_document to set.
+ * Setting stored_in_document on a registerable object without a
+ * vorbaId will mean is will *never* get a vorbaId and
+ * horrible things will happen.
+ * @param __stored_in_document true if object has been marshalled into current document.
*/
protected void set__stored_in_document(boolean __stored_in_document) {
this.__stored_in_document = __stored_in_document;
}
/**
- * @return Returns the registerable.
+ * @return true if object can have a vorbaId
*/
public boolean isRegisterable() {
return registerable;
}
/**
- * Called during unmarshalling - if object has an id string, it is
- * registerable.
- *
- * @param registerable
- * The registerable to set.
+ * Called by __testInstanceForidField and the post-unmarshalling handler
+ * to indicate if object will have a vorbaId.
+ * @param registerable
*/
protected void setRegisterable(boolean registerable) {
this.registerable = registerable;
* calling the same method on them.
* TODO: LATER: properly apply castors own field mechanisms to get at accessors
* TODO: FIX CYCLIC __ensure+instance_ids
+ * Implementation note for the todo:
+ * this works like a depth-first search over all vamsas objects in an vamsasDocument.
+ * The doHash() function is used as the 'visited' flag -
+ * this *is not* a valid heuristic, although it will work "most of the time".
*/
protected void __ensure_instance_ids() {
if (__vorba==null)