Ok, I've built JPOX and have looked at the enhancer code base.
I looked on the JPOX site for a suitable wiki page to discuss the
design and couldn't see where to put it.
So if you could put the following on the wiki and send me a link, we
can discuss the design there.
An abstract class has two purposes in JDO:
1. It can be a base class for user-written persistent classes, and
declare its own persistent fields (and properties). This use requires
that the class be enhanced. The property methods are not abstract in
this case, but are implemented in the class to use internal (non-
persistent) fields to store the property values.
2. It can be a base class for implementation-generated persistent
classes. In this case, the class behaves very much like a persistent
interface. Abstract persistent properties are declared using
metadata; the class is not directly usable by an application; the
abstract properties must be implemented by the implementation-
generated subclass.
As a sub-case of purpose 2, an abstract persistent class can be a
base class for other abstract classes that define their own
persistent fields, persistent properties, and abstract persistent
properties. The implementation is responsible for implementing all
the persistent abstract properties of all the abstract classes.
A concrete persistent class can extend an abstract persistent class
and provide a concrete implementation for all of the abstract
properties.
An abstract persistent class can extend an abstract persistent class
and provide a concrete implementation for some of the abstract
properties.
Purpose 1 is already handled by JDO 1 and no further design
discussion is needed. The rest of this discussion is for purpose 2.
A persistent abstract class might also inherit a persistent abstract
or concrete class that itself defines persistent fields and
properties. The implementation-generated subclass is responsible for
generating implementations for the persistent properties defined by
the abstract classes that are either directly or indirectly inherited.
During enhancement, an abstract class needs to have the "regular" jdo
fields and methods added to it for implementing its concrete
persistent fields and properties. None of the abstract persistent
members need to be included in the enhanced class, as the
implementation of these are only in the concrete implementation-
generated class.
During runtime, an implementation class for the parameter of
pm.newInstance(Class PAClass) is generated. The generated class
(PAImpl) is identical to the generated class for a persistent
interface except for the following:
A. The PAImpl is not a "least-derived (topmost) persistence-capable
class", so it doesn't implement the basic jdo methods.
B. The PAImpl extends PAClass.
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
|