com.objectwave.persist.examples
Class DomainObject

java.lang.Object
  |
  +--com.objectwave.persist.examples.DomainObject
All Implemented Interfaces:
Persistence, java.io.Serializable, TransactionalObjectIF
Direct Known Subclasses:
ExampleCompany, ExampleEmployee, ExamplePerson, JoinObject, ManySideOne, ManySideTwo, PersistenceBase, Person, PersonPhone, Phone, TestCompany, TestEntity, TestPerson, TestSampleXML, TestXMLCompany, TestXMLPerson

public class DomainObject
extends java.lang.Object
implements Persistence

A possible root Business object for an application.

Version:
$Id: DomainObject.java,v 2.5 2002/03/09 17:13:47 dave_hoag Exp $
Author:
dhoag
See Also:
Serialized Form

Nested Class Summary
static class DomainObject.Test
           
 
Field Summary
 RDBPersistentAdapter adapt
           
 ObjectEditingView editor
           
 java.lang.Integer objectIdentifier
           
protected static java.util.HashMap tableMap
           
 
Constructor Summary
DomainObject()
           
 
Method Summary
protected  void addDefaultPrimaryAttribute(java.util.ArrayList list)
          Add primary attribute type with a column name of databaseIdentifer.
protected  RDBPersistentAdapter createAdapter(Persistence persistentObject)
          Create the new ObjectEditingView instance that is to be our 'adapter' to the persistent object.
 void delete()
           
 Persistence getAdapter()
          Gets the Adapter attribute of the DomainObject object
 java.lang.String getBrokerName()
          Support for individual instances residing in their own brokers.
protected  java.util.Vector getClassDescriptor()
          Use an instance method to access a static variable.
protected static com.objectwave.persist.examples.DomainObject.TableValueHolder getEntry(java.lang.Class currentClass)
          While this simplifies the development of Persistent objects, this approach will not peform optimally.
 ObjectEditingView getObjectEditor()
          Gets the ObjectEditor attribute of the DomainObject object
 java.lang.Integer getObjectIdentifier()
          Gets the ObjectIdentifier attribute of the DomainObject object
 java.lang.Object getPrimaryKeyField()
          Gets the PrimaryKeyField attribute of the DomainObject object
 java.lang.Object[] getPrimaryKeyFields()
          Gets the PrimaryKeyField attributes of the DomainObject object
static java.util.Vector getSuperDescriptor()
          A conveince method to get a copy of this static class descriptor.
protected  java.lang.String getTableName()
          Use an instance method to access a static variable.
protected  XMLDecoder getXmlDefinition(java.lang.String xmlTag, java.lang.Object obj)
          Create the XMLDecoder object that will allow the creation of all of the map information.
static java.util.Vector initDescription()
           
 void initDescriptor(java.lang.String xmlTag, Persistence obj, RDBPersistentAdapter adapter)
          Read in the XML file and populate the persistent map information.
 ObjectEditingView initializeObjectEditor()
          Subclasses will override this method to return an appropriate instance of a RDBPersistentAdapter; This method will always instantiate the inner adapter found in DomainObject's class definition.
 ObjectEditingView initializeObjectEditor(java.lang.String xmlTag, Persistence obj)
          Called to initialize object editor It will use an XML file for the field match.
 void insert()
          Force this object to be a part of the changedObjects list.
 boolean isDirty()
          Gets the Dirty attribute of the DomainObject object
 boolean isRetrievedFromDatabase()
          Gets the RetrievedFromDatabase attribute of the DomainObject object
 boolean isTransient()
          Gets the Transient attribute of the DomainObject object
protected  java.lang.String locateXmlMap(java.lang.String xmlTag, java.lang.Object persistentObject)
          Find the XML document that contains the persitent map information.
 boolean lock(boolean wait)
          This method was created in VisualAge.
 void markForDelete()
          Mark this object to be deleted in this transaction.
 void save()
           
 void setAsTransient(boolean value)
          Sets the AsTransient attribute of the DomainObject object
 void setBrokerName(java.lang.String aValue)
          Support for individual instances residing in their own brokers.
protected  void setClassDescriptor(java.util.Vector v)
          Use an instance method to access a static variable.
protected static void setEntry(java.lang.Class currentClass, com.objectwave.persist.examples.DomainObject.TableValueHolder entry)
          While this simplifies the development of Persistent objects, this approach will not peform optimally.
 void setObjectEditor(ObjectEditingView e)
          For an RDBPersistent system, this will be an RDBPersistentAdapter.
 void setObjectIdentifier(java.lang.Integer aValue)
          Sets the ObjectIdentifier attribute of the DomainObject object
 void setPrimaryKeyField(java.lang.Object obj)
          Sets the PrimaryKeyField attribute of the DomainObject object
 void setPrintString(java.lang.String value)
          A user friendly description.
 void setRetrievedFromDatabase(boolean b)
          Sets the RetrievedFromDatabase attribute of the DomainObject object
protected  void setTableName(java.lang.String table)
          Use an instance method to access a static variable.
 java.lang.String toString()
           
 void unlock()
          This method was created in VisualAge.
 void update(boolean get, java.lang.Object[] data, java.lang.reflect.Field[] fields)
          Method no longer does anything since setAccessible solves our need for this behavior.
 boolean usesAdapter()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tableMap

protected static java.util.HashMap tableMap

objectIdentifier

public java.lang.Integer objectIdentifier

editor

public transient ObjectEditingView editor

adapt

public transient RDBPersistentAdapter adapt
Constructor Detail

DomainObject

public DomainObject()
Method Detail

getSuperDescriptor

public static java.util.Vector getSuperDescriptor()
A conveince method to get a copy of this static class descriptor.

Returns:
The SuperDescriptor value

initDescription

public static java.util.Vector initDescription()
Returns:

setEntry

protected static void setEntry(java.lang.Class currentClass,
                               com.objectwave.persist.examples.DomainObject.TableValueHolder entry)
While this simplifies the development of Persistent objects, this approach will not peform optimally. Please add a classDescriptor static variable and the appropriate instance methods.

Parameters:
currentClass - The new Entry value
entry - The new Entry value

getEntry

protected static com.objectwave.persist.examples.DomainObject.TableValueHolder getEntry(java.lang.Class currentClass)
While this simplifies the development of Persistent objects, this approach will not peform optimally. Please add a classDescriptor static variable and the appropriate instance methods.

Parameters:
currentClass -
Returns:
The Entry value

setBrokerName

public void setBrokerName(java.lang.String aValue)
Support for individual instances residing in their own brokers.

Specified by:
setBrokerName in interface Persistence
Parameters:
aValue - The new BrokerName value

setAsTransient

public void setAsTransient(boolean value)
Sets the AsTransient attribute of the DomainObject object

Specified by:
setAsTransient in interface TransactionalObjectIF
Parameters:
value - The new AsTransient value

setObjectEditor

public void setObjectEditor(ObjectEditingView e)
For an RDBPersistent system, this will be an RDBPersistentAdapter.

Specified by:
setObjectEditor in interface TransactionalObjectIF
Parameters:
e - The new ObjectEditor value

setObjectIdentifier

public void setObjectIdentifier(java.lang.Integer aValue)
Sets the ObjectIdentifier attribute of the DomainObject object

Parameters:
aValue - The new ObjectIdentifier value

setPrimaryKeyField

public void setPrimaryKeyField(java.lang.Object obj)
Sets the PrimaryKeyField attribute of the DomainObject object

Specified by:
setPrimaryKeyField in interface Persistence
Parameters:
obj - The new PrimaryKeyField value

setPrintString

public void setPrintString(java.lang.String value)
A user friendly description.

Parameters:
value - The new PrintString value

setRetrievedFromDatabase

public void setRetrievedFromDatabase(boolean b)
Sets the RetrievedFromDatabase attribute of the DomainObject object

Specified by:
setRetrievedFromDatabase in interface Persistence
Parameters:
b - The new RetrievedFromDatabase value

getAdapter

public Persistence getAdapter()
Gets the Adapter attribute of the DomainObject object

Specified by:
getAdapter in interface Persistence
Returns:
The Adapter value

getBrokerName

public java.lang.String getBrokerName()
Support for individual instances residing in their own brokers.

Specified by:
getBrokerName in interface Persistence
Returns:
The BrokerName value

getObjectEditor

public ObjectEditingView getObjectEditor()
Gets the ObjectEditor attribute of the DomainObject object

Specified by:
getObjectEditor in interface TransactionalObjectIF
Returns:
The ObjectEditor value

getObjectIdentifier

public java.lang.Integer getObjectIdentifier()
Gets the ObjectIdentifier attribute of the DomainObject object

Returns:
The ObjectIdentifier value

getPrimaryKeyField

public java.lang.Object getPrimaryKeyField()
Gets the PrimaryKeyField attribute of the DomainObject object

Specified by:
getPrimaryKeyField in interface Persistence
Returns:
The PrimaryKeyField value

getPrimaryKeyFields

public java.lang.Object[] getPrimaryKeyFields()
Gets the PrimaryKeyField attributes of the DomainObject object

Specified by:
getPrimaryKeyFields in interface Persistence
Returns:
The PrimaryKeyField value

isDirty

public boolean isDirty()
Gets the Dirty attribute of the DomainObject object

Specified by:
isDirty in interface TransactionalObjectIF
Returns:
The Dirty value

isRetrievedFromDatabase

public boolean isRetrievedFromDatabase()
Gets the RetrievedFromDatabase attribute of the DomainObject object

Specified by:
isRetrievedFromDatabase in interface Persistence
Returns:
The RetrievedFromDatabase value

isTransient

public boolean isTransient()
Gets the Transient attribute of the DomainObject object

Specified by:
isTransient in interface TransactionalObjectIF
Returns:
The Transient value

initializeObjectEditor

public ObjectEditingView initializeObjectEditor(java.lang.String xmlTag,
                                                Persistence obj)
                                         throws java.io.FileNotFoundException,
                                                ConfigurationException
Called to initialize object editor It will use an XML file for the field match. This method is only used when using XML files to define your persistent map information. The xmlTag parameter can be either the name of an XML file or a key to System properties to a value of an XML file name.

Parameters:
xmlTag - String The tag name in the initial file
obj - Object The caller himself
Returns:
Throws:
java.io.FileNotFoundException
ConfigurationException
See Also:
locateXmlMap(java.lang.String, java.lang.Object)

initDescriptor

public void initDescriptor(java.lang.String xmlTag,
                           Persistence obj,
                           RDBPersistentAdapter adapter)
                    throws java.io.FileNotFoundException,
                           ConfigurationException
Read in the XML file and populate the persistent map information. Use initializeObjectEditor instead of this method.

Parameters:
xmlTag -
obj -
adapter -
Throws:
java.io.FileNotFoundException
ConfigurationException

delete

public void delete()
            throws QueryException
Specified by:
delete in interface Persistence
Throws:
QueryException

initializeObjectEditor

public ObjectEditingView initializeObjectEditor()
Subclasses will override this method to return an appropriate instance of a RDBPersistentAdapter; This method will always instantiate the inner adapter found in DomainObject's class definition. There are two approaches to this method the first of which is to create your own subclass of RDBPersistentAdapter and return it as a result from this method. The second, is to tweak the instance created by this method by setting table name and the description.

Returns:

insert

public void insert()
            throws QueryException
Description copied from interface: Persistence
Force this object to be a part of the changedObjects list.

Specified by:
insert in interface Persistence
Throws:
QueryException

lock

public boolean lock(boolean wait)
This method was created in VisualAge.

Specified by:
lock in interface Persistence
Parameters:
wait - boolean
Returns:
boolean

markForDelete

public void markForDelete()
                   throws QueryException
Mark this object to be deleted in this transaction. If a transaction is not in progress, this object will be deleted immediately.

Throws:
QueryException

save

public void save()
          throws QueryException
Specified by:
save in interface Persistence
Throws:
QueryException

toString

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

unlock

public void unlock()
This method was created in VisualAge.

Specified by:
unlock in interface Persistence

update

public void update(boolean get,
                   java.lang.Object[] data,
                   java.lang.reflect.Field[] fields)
Method no longer does anything since setAccessible solves our need for this behavior.

Specified by:
update in interface TransactionalObjectIF
Parameters:
get -
data -
fields -

usesAdapter

public boolean usesAdapter()
Specified by:
usesAdapter in interface Persistence
Returns:

setTableName

protected void setTableName(java.lang.String table)
Use an instance method to access a static variable. This method MUST be duplicated in each and every subclass. This allows our generic logic in this super class to modify static state in a subclass.

Parameters:
table - The new TableName value

setClassDescriptor

protected void setClassDescriptor(java.util.Vector v)
Use an instance method to access a static variable. This method MUST be duplicated in each and every subclass. This allows our generic logic in this super class to modify static state in a subclass.

Parameters:
v - The new ClassDescriptor value

getTableName

protected java.lang.String getTableName()
Use an instance method to access a static variable. This method MUST be duplicated in each and every subclass. This allows our generic logic in this super class to modify static state in a subclass.

Returns:
The TableName value

getClassDescriptor

protected java.util.Vector getClassDescriptor()
Use an instance method to access a static variable. This method MUST be duplicated in each and every subclass. This allows our generic logic in this super class to modify static state in a subclass.

Returns:
The ClassDescriptor value

getXmlDefinition

protected XMLDecoder getXmlDefinition(java.lang.String xmlTag,
                                      java.lang.Object obj)
                               throws java.io.FileNotFoundException,
                                      ConfigurationException
Create the XMLDecoder object that will allow the creation of all of the map information.

Parameters:
xmlTag -
obj -
Returns:
The XmlDefinition value
Throws:
java.io.FileNotFoundException
ConfigurationException

addDefaultPrimaryAttribute

protected void addDefaultPrimaryAttribute(java.util.ArrayList list)
Add primary attribute type with a column name of databaseIdentifer. This is the default primary key field. The map may define its own primary key field, in which case the default will not be added.

Parameters:
list - ArrayList The list that was found in the Xml map

createAdapter

protected RDBPersistentAdapter createAdapter(Persistence persistentObject)
Create the new ObjectEditingView instance that is to be our 'adapter' to the persistent object.

Parameters:
persistentObject -
Returns:

locateXmlMap

protected java.lang.String locateXmlMap(java.lang.String xmlTag,
                                        java.lang.Object persistentObject)
                                 throws ConfigurationException,
                                        java.io.FileNotFoundException
Find the XML document that contains the persitent map information. First decide if the xmlTag is really a key in system properties identifying the actual file name. If a key is not found, the xmlTag is assumed to be the xml file name. Once the name is determined, locate the XML file. First look in same directory as the persisent object class file.

Parameters:
xmlTag - String The tag name for the xml resource.
persistentObject -
Returns:
Throws:
ConfigurationException
java.io.FileNotFoundException