User's Manual

108 Chapter 10. Kernel Tutorial
*/
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE; (4)
}
}
(1) The AuditedACSObject is imported from the auditing service package.
(2) Log4j is used as a uniform debugging tool across WAF. The convention for initializing the log4j
system is to initialize a category with the name of the current class, as shown here.
(3) By extending this baseclass, this Java class becomes a domain object. It inherits a data object
and methods for manipulating it. Calls to these methods are automatically observed and modifi-
cations are logged in the audit trail.
(4) The data object type for the domain object is declared as a member variable,
BASE_DATA_OBJECT_TYPE. It is final and static, so the compiler will replace it with a constant.
An inherited function, getBaseDataObjectType, is overridden to return this variable. This
method is used by the constructors on the superclasses to verify that the data object matches
this type or is a subtype. For more information on this topic, see Section 10.2.1.2 Constructors.
Example 10-1. Starting to Build the Domain Object
10.2.1.2. Constructors
Before any of the methods of a class can be used, an instance must be constructed in memory. There
are several different varieties of constructors for domain objects, all of which are illustrated in the
Notes domain object.
There are two different types of constructors for domain objects. One is used for constructing domain
objects by creating a new data object. The no-arg constructors the String typename and the
ObjectType type are this type of constructor. These constructors use the persistence system to
create a new data object that matches the type passed as an argument.
The other type of constructor relies on retrieval of an existing data object to construct the domain
object. The first of these takes an Object ID or OID as input, and then retrieves a data object corre-
sponding to that OID. An OID is comprised of two pieces: a BigDecimal numeric ID and an object
type identifier. The second constructor takes a data object as input and constructs a DomainObject
to wrap it. This constructor does not need to construct the underlying data object, so it is preferable to
use this constructor if the data object has already been loaded into memory.
These constructors exist in DomainObject, ObservableDomainObject, ACSObject, and Au-
ditedACSObject. Subclasses should replicate these constructors, unless there is a good reason to
restrict them. The comments following Example 10-2 explain the overall utility of each constructor,
and why each subclass should use them. Additional constructors can be added, and this is encouraged
if it makes the class more convenient to use.
Note
Be aware that none of the constructors will change the persistent state of the DomainObject or its
data object. To store a domain object’s properties in the database, the save method must be called.
To delete a DomainObject, the delete method must be called.