com.objectwave.persist.invert
Class PersistenceBase

java.lang.Object
  |
  +--com.objectwave.persist.examples.DomainObject
        |
        +--com.objectwave.persist.invert.PersistenceBase
All Implemented Interfaces:
Persistence, java.io.Serializable, TransactionalObjectIF

public class PersistenceBase
extends DomainObject
implements Persistence

While this class is not directly used by any of the other code in this library, it is used as a template when auto-generating persistence support.

Version:
$Id: PersistenceBase.java,v 1.5 2002/08/24 16:34:00 dave_hoag Exp $
Author:
dave_hoag
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.objectwave.persist.examples.DomainObject
DomainObject.Test
 
Field Summary
protected static java.lang.reflect.Field _objectIdentifier
           
 RDBPersistentAdapter adapt
           
 ObjectEditingView editor
           
 java.lang.Integer objectIdentifier
           
protected  java.lang.String printString
           
protected  java.lang.String xmlInitString
           
 
Fields inherited from class com.objectwave.persist.examples.DomainObject
tableMap
 
Constructor Summary
PersistenceBase()
          Call the setup method.
 
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.
 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
protected  java.lang.String getTableName()
          Notice the use of instance methods to access static variables.
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.
 void initDescriptor(java.lang.String xmlTag, Persistence obj, RDBPersistentAdapter adapter)
          Read in the XML file and populate the persistent map information.
 ObjectEditingView initializeObjectEditor(java.lang.String xmlTag)
          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()
          Determines if this persistent object is to be considered as transient.
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.
 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.
protected  void setup()
          Override this method if you wish to setup your object differently.
 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 com.objectwave.persist.examples.DomainObject
getEntry, getSuperDescriptor, initDescription, initializeObjectEditor, initializeObjectEditor, setEntry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_objectIdentifier

protected static java.lang.reflect.Field _objectIdentifier

objectIdentifier

public java.lang.Integer objectIdentifier

editor

public transient ObjectEditingView editor

adapt

public transient RDBPersistentAdapter adapt

printString

protected java.lang.String printString

xmlInitString

protected java.lang.String xmlInitString
Constructor Detail

PersistenceBase

public PersistenceBase()
Call the setup method. The setup method could be overridden by subclasses if they don't want the default Xml file to be used.

See Also:
setup()
Method Detail

setup

protected void setup()
              throws java.lang.Exception
Override this method if you wish to setup your object differently. This should work if your Xml is found in the directory of the Persistent class and it has the same name as the persistent class.

Throws:
java.lang.Exception

setBrokerName

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

Specified by:
setBrokerName in interface Persistence
Overrides:
setBrokerName in class DomainObject
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
Overrides:
setAsTransient in class DomainObject
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
Overrides:
setObjectEditor in class DomainObject
Parameters:
e - The new ObjectEditor value

setObjectIdentifier

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

Overrides:
setObjectIdentifier in class DomainObject
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
Overrides:
setPrimaryKeyField in class DomainObject
Parameters:
obj - The new PrimaryKeyField value

setPrintString

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

Overrides:
setPrintString in class DomainObject
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
Overrides:
setRetrievedFromDatabase in class DomainObject
Parameters:
b - The new RetrievedFromDatabase value

setTableName

protected void setTableName(java.lang.String table)
Description copied from class: DomainObject
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.

Overrides:
setTableName in class DomainObject
Parameters:
table - The new tableName value

setClassDescriptor

protected void setClassDescriptor(java.util.Vector v)
Description copied from class: DomainObject
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.

Overrides:
setClassDescriptor in class DomainObject
Parameters:
v - The new classDescriptor value

getAdapter

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

Specified by:
getAdapter in interface Persistence
Overrides:
getAdapter in class DomainObject
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
Overrides:
getBrokerName in class DomainObject
Returns:
The BrokerName value

getObjectEditor

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

Specified by:
getObjectEditor in interface TransactionalObjectIF
Overrides:
getObjectEditor in class DomainObject
Returns:
The ObjectEditor value

getObjectIdentifier

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

Overrides:
getObjectIdentifier in class DomainObject
Returns:
The ObjectIdentifier value

getPrimaryKeyField

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

Specified by:
getPrimaryKeyField in interface Persistence
Overrides:
getPrimaryKeyField in class DomainObject
Returns:
The PrimaryKeyField value

getPrimaryKeyFields

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

Specified by:
getPrimaryKeyFields in interface Persistence
Overrides:
getPrimaryKeyFields in class DomainObject
Returns:
The PrimaryKeyField value

isDirty

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

Specified by:
isDirty in interface TransactionalObjectIF
Overrides:
isDirty in class DomainObject
Returns:
The Dirty value

isRetrievedFromDatabase

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

Specified by:
isRetrievedFromDatabase in interface Persistence
Overrides:
isRetrievedFromDatabase in class DomainObject
Returns:
The RetrievedFromDatabase value

isTransient

public boolean isTransient()
Determines if this persistent object is to be considered as transient. Tranisent objects will not be updated in the database.

Specified by:
isTransient in interface TransactionalObjectIF
Overrides:
isTransient in class DomainObject
Returns:
boolean Indicating the transient status

getTableName

protected java.lang.String getTableName()
Notice the use of instance methods to access static variables. This is intended so subclasses can keep their own static values and have them provided to methods in this class.

Overrides:
getTableName in class DomainObject
Returns:
The tableName value

getClassDescriptor

protected java.util.Vector getClassDescriptor()
Description copied from class: DomainObject
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.

Overrides:
getClassDescriptor in class DomainObject
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.

Overrides:
getXmlDefinition in class DomainObject
Parameters:
xmlTag -
obj -
Returns:
The XmlDefinition value
Throws:
java.io.FileNotFoundException
ConfigurationException

initializeObjectEditor

public ObjectEditingView initializeObjectEditor(java.lang.String xmlTag)
                                         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
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.

Overrides:
initDescriptor in class DomainObject
Parameters:
xmlTag -
obj -
adapter -
Throws:
java.io.FileNotFoundException
ConfigurationException

delete

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

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
Overrides:
insert in class DomainObject
Throws:
QueryException

lock

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

Specified by:
lock in interface Persistence
Overrides:
lock in class DomainObject
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.

Overrides:
markForDelete in class DomainObject
Throws:
QueryException

save

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

toString

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

unlock

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

Specified by:
unlock in interface Persistence
Overrides:
unlock in class DomainObject

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
Overrides:
update in class DomainObject
Parameters:
get -
data -
fields -

usesAdapter

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

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.

Overrides:
addDefaultPrimaryAttribute in class DomainObject
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.

Overrides:
createAdapter in class DomainObject
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.

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