You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Craig L Russell <Cr...@Sun.COM> on 2007/07/29 06:34:51 UTC
Abstract Class Persistence
I thought I'd describe my understanding of PAC so we have a common
basis for discussion.
The difference between Persistent Interface and Persistent Abstract
Class is:
1. interface PIXXX vs. abstract class PACXXX
2. PIXXXImpl implements PIXXX vs. PACXXXImpl extends PACXXX
3. All methods in PIXXX must be properties (corresponding get/set
methods) vs. all abstract methods in PACXXX must be properties.
4. PIXXXImpl implements all property methods vs. PACXXXImpl
implements all property methods.
That's it.
I think that JPOX has already done the hard part in getting PI to
work. The remaining work is "mapping" the concepts of PI to PAC.
If you point me in the right direction, I'll try to make a patch for
JPOX.
Craig
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!
Re: Abstract Class Persistence
Posted by Andy Jefferson <an...@jpox.org>.
Hi Craig,
> There is a small bit of design work to do. Should I post something to
> the JPOX wiki?
Good idea
--
Andy (Java Persistent Objects - http://www.jpox.org)
Re: Abstract Class Persistence
Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Andy,
Thanks for the pointer.
There is a small bit of design work to do. Should I post something to
the JPOX wiki?
Craig
On Jul 30, 2007, at 1:51 AM, Andy Jefferson wrote:
> Hi Craig,
>
>> The difference between Persistent Interface and Persistent Abstract
>> Class is:
>>
>> 1. interface PIXXX vs. abstract class PACXXX
>> 2. PIXXXImpl implements PIXXX vs. PACXXXImpl extends PACXXX
>> 3. All methods in PIXXX must be properties (corresponding get/set
>> methods) vs. all abstract methods in PACXXX must be properties.
>> 4. PIXXXImpl implements all property methods vs. PACXXXImpl
>> implements all property methods.
>>
>> I think that JPOX has already done the hard part in getting PI to
>> work. The remaining work is "mapping" the concepts of PI to PAC.
>>
>> If you point me in the right direction, I'll try to make a patch
>> for JPOX.
>
> Ok, if you have time try the following :-
>
> 1. Core/src/java/org/jpox/ObjectManagerImpl.java has the method
> newInstance().
> This hands off the creation to an "ImplementationCreator".
>
> 2. Enhancer/src/java/org/jpox/enhancer/ImplementationCreatorImpl.java
> It has a TODO at line 71. The processing of interfaces is at line
> 88 which
> utilises an "ImplementationGenerator".
>
> 3. Enhancer/src/java/org/jpox/enhancer/bcel/
> BCELImplementationGenerator.java
> This currently is only set up for interfaces (InterfaceMetaData),
> so would
> need extending to allow classes (ClassMetaData) - so a new constructor
> perhaps.
>
> ... and if you don't have time then we will get around to it at
> some point.
>
> Thx
> --
> Andy (Java Persistent Objects - http://www.jpox.org)
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!
Re: Abstract Class Persistence
Posted by Craig L Russell <Cr...@Sun.COM>.
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!
Re: Abstract Class Persistence
Posted by Craig L Russell <Cr...@Sun.COM>.
On Jul 30, 2007, at 11:29 PM, Andy Jefferson wrote:
>> jpox-thirdparty-1.2-SNAPSHOT.jar
>> ojdbc14.jar
>> org.eclipse.equinox.registry-3.2.0.jar (try downloading from http://
>> eclipse.org/equinox/)
>> org.eclipse.equinox.common-3.2.0.jar (try downloading from http://
>> eclipse.org/equinox/)
>> org.eclipse.core.runtime-3.2.0.jar (try downloading from http://
>> eclipse.org/equinox/)
>> org.eclipse.osgi-3.2.0.jar (try downloading from http://eclipse.org/
>> equinox/)
>
> So you need to
>
> 1. build "Plugins/ThirdParty"
Done.
> 2. put those other jars listed into your Maven repo in the
> respective places.
> You can find them under "JPOX/LibRepository" (see README.txt under
> "Core")
Tricky. All I had to do was to check out JPOX/LibRepository and maven
found them. Currently building Core.
The instructions could be a bit easier to find...
Thanks,
Craig
>
>
> -
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!
Re: Abstract Class Persistence
Posted by Andy Jefferson <an...@jpox.org>.
Hi Craig,
> >> Is there a "getting started" building JPOX from source? I downloaded
> >> Core, Enhancer, and Plugins but the maven goals don't seem to work.
> >
> > In general follow
> > http://www.jpox.org/docs/project/building_maven1.html
> >
> > You'll probably need the top level too (because I seem to remember
> > that
> > Plugins inherit from them - you could just remove the <extend> line
> > from
> > project.xml to get over that part).
>
> I don't see a "top level" in the cvs repo. I did check out maven.xml,
> project.xml, and project.properties.
"top-level" is
JPOX/
> Following the instructions at building_maven1.html, I get:
> [Bruiser:~/jpox/cvs] clr% cd JPOX/Core/
> [Bruiser:cvs/JPOX/Core] clr% maven clean jar:install
> __ __
>
> | \/ |__ _Apache__ ___
> |
> | |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
> |
> |_| |_\__,_|\_/\___|_||_| v. 1.0.2
>
> Attempting to download jdo2-api-SNAPSHOT.jar.
> Artifact /javax.jdo/jars/jdo2-api-SNAPSHOT.jar doesn't exists in
> remote repository, but it exists locally
> Attempting to download jpox-thirdparty-1.2-SNAPSHOT.jar.
> WARNING: Failed to download jpox-thirdparty-1.2-SNAPSHOT.jar.
> Attempting to download ojdbc14.jar.
> WARNING: Failed to download ojdbc14.jar.
> Attempting to download jpox-testframework-1.2-SNAPSHOT.jar.
> Artifact /jpox/jars/jpox-testframework-1.2-SNAPSHOT.jar doesn't
> exists in remote repository, but it exists locally
> Attempting to download org.eclipse.equinox.registry-3.2.0.jar.
> WARNING: Failed to download org.eclipse.equinox.registry-3.2.0.jar.
> Attempting to download org.eclipse.equinox.common-3.2.0.jar.
> WARNING: Failed to download org.eclipse.equinox.common-3.2.0.jar.
> Attempting to download org.eclipse.core.runtime-3.2.0.jar.
> WARNING: Failed to download org.eclipse.core.runtime-3.2.0.jar.
> Attempting to download org.eclipse.osgi-3.2.0.jar.
> WARNING: Failed to download org.eclipse.osgi-3.2.0.jar.
> The build cannot continue because of the following unsatisfied
> dependencies:
>
> jpox-thirdparty-1.2-SNAPSHOT.jar
> ojdbc14.jar
> org.eclipse.equinox.registry-3.2.0.jar (try downloading from http://
> eclipse.org/equinox/)
> org.eclipse.equinox.common-3.2.0.jar (try downloading from http://
> eclipse.org/equinox/)
> org.eclipse.core.runtime-3.2.0.jar (try downloading from http://
> eclipse.org/equinox/)
> org.eclipse.osgi-3.2.0.jar (try downloading from http://eclipse.org/
> equinox/)
So you need to
1. build "Plugins/ThirdParty"
2. put those other jars listed into your Maven repo in the respective places.
You can find them under "JPOX/LibRepository" (see README.txt under "Core")
--
Andy (Java Persistent Objects - http://www.jpox.org)
Re: Abstract Class Persistence
Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Andy,
On Jul 30, 2007, at 10:52 PM, Andy Jefferson wrote:
> Hi Craig,
>
>> Is there a "getting started" building JPOX from source? I downloaded
>> Core, Enhancer, and Plugins but the maven goals don't seem to work.
>
> In general follow
> http://www.jpox.org/docs/project/building_maven1.html
>
> You'll probably need the top level too (because I seem to remember
> that
> Plugins inherit from them - you could just remove the <extend> line
> from
> project.xml to get over that part).
I don't see a "top level" in the cvs repo. I did check out maven.xml,
project.xml, and project.properties.
>
> If you're using JDK1.4/1.5 then you will also need to download and
> build
> Plugins/ThirdParty before building Core (unless you're using JDK
> 1.6) -
> contains some stubs for the JDBC4 changes that we need to support
> for JPOX to
> run on JDK1.6.
>
> Any particular error?
Following the instructions at building_maven1.html, I get:
[Bruiser:~/jpox/cvs] clr% cd JPOX/Core/
[Bruiser:cvs/JPOX/Core] clr% maven clean jar:install
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0.2
Attempting to download jdo2-api-SNAPSHOT.jar.
Artifact /javax.jdo/jars/jdo2-api-SNAPSHOT.jar doesn't exists in
remote repository, but it exists locally
Attempting to download jpox-thirdparty-1.2-SNAPSHOT.jar.
WARNING: Failed to download jpox-thirdparty-1.2-SNAPSHOT.jar.
Attempting to download ojdbc14.jar.
WARNING: Failed to download ojdbc14.jar.
Attempting to download jpox-testframework-1.2-SNAPSHOT.jar.
Artifact /jpox/jars/jpox-testframework-1.2-SNAPSHOT.jar doesn't
exists in remote repository, but it exists locally
Attempting to download org.eclipse.equinox.registry-3.2.0.jar.
WARNING: Failed to download org.eclipse.equinox.registry-3.2.0.jar.
Attempting to download org.eclipse.equinox.common-3.2.0.jar.
WARNING: Failed to download org.eclipse.equinox.common-3.2.0.jar.
Attempting to download org.eclipse.core.runtime-3.2.0.jar.
WARNING: Failed to download org.eclipse.core.runtime-3.2.0.jar.
Attempting to download org.eclipse.osgi-3.2.0.jar.
WARNING: Failed to download org.eclipse.osgi-3.2.0.jar.
The build cannot continue because of the following unsatisfied
dependencies:
jpox-thirdparty-1.2-SNAPSHOT.jar
ojdbc14.jar
org.eclipse.equinox.registry-3.2.0.jar (try downloading from http://
eclipse.org/equinox/)
org.eclipse.equinox.common-3.2.0.jar (try downloading from http://
eclipse.org/equinox/)
org.eclipse.core.runtime-3.2.0.jar (try downloading from http://
eclipse.org/equinox/)
org.eclipse.osgi-3.2.0.jar (try downloading from http://eclipse.org/
equinox/)
Total time: 5 seconds
>
>
> --
> Andy (Java Persistent Objects - http://www.jpox.org)
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!
Re: Abstract Class Persistence
Posted by Andy Jefferson <an...@jpox.org>.
Hi Craig,
> Is there a "getting started" building JPOX from source? I downloaded
> Core, Enhancer, and Plugins but the maven goals don't seem to work.
In general follow
http://www.jpox.org/docs/project/building_maven1.html
You'll probably need the top level too (because I seem to remember that
Plugins inherit from them - you could just remove the <extend> line from
project.xml to get over that part).
If you're using JDK1.4/1.5 then you will also need to download and build
Plugins/ThirdParty before building Core (unless you're using JDK 1.6) -
contains some stubs for the JDBC4 changes that we need to support for JPOX to
run on JDK1.6.
Any particular error?
--
Andy (Java Persistent Objects - http://www.jpox.org)
Re: Abstract Class Persistence
Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Andy,
Is there a "getting started" building JPOX from source? I downloaded
Core, Enhancer, and Plugins but the maven goals don't seem to work.
Thanks,
Craig
On Jul 30, 2007, at 1:51 AM, Andy Jefferson wrote:
> Hi Craig,
>
>> The difference between Persistent Interface and Persistent Abstract
>> Class is:
>>
>> 1. interface PIXXX vs. abstract class PACXXX
>> 2. PIXXXImpl implements PIXXX vs. PACXXXImpl extends PACXXX
>> 3. All methods in PIXXX must be properties (corresponding get/set
>> methods) vs. all abstract methods in PACXXX must be properties.
>> 4. PIXXXImpl implements all property methods vs. PACXXXImpl
>> implements all property methods.
>>
>> I think that JPOX has already done the hard part in getting PI to
>> work. The remaining work is "mapping" the concepts of PI to PAC.
>>
>> If you point me in the right direction, I'll try to make a patch
>> for JPOX.
>
> Ok, if you have time try the following :-
>
> 1. Core/src/java/org/jpox/ObjectManagerImpl.java has the method
> newInstance().
> This hands off the creation to an "ImplementationCreator".
>
> 2. Enhancer/src/java/org/jpox/enhancer/ImplementationCreatorImpl.java
> It has a TODO at line 71. The processing of interfaces is at line
> 88 which
> utilises an "ImplementationGenerator".
>
> 3. Enhancer/src/java/org/jpox/enhancer/bcel/
> BCELImplementationGenerator.java
> This currently is only set up for interfaces (InterfaceMetaData),
> so would
> need extending to allow classes (ClassMetaData) - so a new constructor
> perhaps.
>
> ... and if you don't have time then we will get around to it at
> some point.
>
> Thx
> --
> Andy (Java Persistent Objects - http://www.jpox.org)
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!
Re: Abstract Class Persistence
Posted by Andy Jefferson <an...@jpox.org>.
Hi Craig,
> The difference between Persistent Interface and Persistent Abstract
> Class is:
>
> 1. interface PIXXX vs. abstract class PACXXX
> 2. PIXXXImpl implements PIXXX vs. PACXXXImpl extends PACXXX
> 3. All methods in PIXXX must be properties (corresponding get/set
> methods) vs. all abstract methods in PACXXX must be properties.
> 4. PIXXXImpl implements all property methods vs. PACXXXImpl
> implements all property methods.
>
> I think that JPOX has already done the hard part in getting PI to
> work. The remaining work is "mapping" the concepts of PI to PAC.
>
> If you point me in the right direction, I'll try to make a patch for JPOX.
Ok, if you have time try the following :-
1. Core/src/java/org/jpox/ObjectManagerImpl.java has the method newInstance().
This hands off the creation to an "ImplementationCreator".
2. Enhancer/src/java/org/jpox/enhancer/ImplementationCreatorImpl.java
It has a TODO at line 71. The processing of interfaces is at line 88 which
utilises an "ImplementationGenerator".
3. Enhancer/src/java/org/jpox/enhancer/bcel/BCELImplementationGenerator.java
This currently is only set up for interfaces (InterfaceMetaData), so would
need extending to allow classes (ClassMetaData) - so a new constructor
perhaps.
... and if you don't have time then we will get around to it at some point.
Thx
--
Andy (Java Persistent Objects - http://www.jpox.org)