inherit xdoclet ejb.relation methods from superclasses?

F

fworsley

Hi,

I'm trying to find out if it is possible to inhert EJB relations
defined by xdoclet from a superclass. What I mean is, imagine I have a
class AbstractPersonBean. The class defines an ejb.relation to an
AddressBean since every person has an address. Now I want to create
several concrete implementations of AbstractPersonBean, such as
StudentBean, TeacherBean, etc. Each of these classes may define
additional ejb.relations but I want them all to "inherit" the relation
defined in the abstract super class.

With xdoclet I cannot get this to work. It always generates a
deployment descriptor where it assumes AbstractPersonBean is a real
bean and it has the relation to AddressBean. Of course it isn't a real
bean, so the app server barfs during the deploy.

Anyone have an idea of how I can make this work, if at all? I really
don't want to duplicate the ejb.relation in every concrete subclass. I
am unfortunately limited to using EJBs here, Hibernate et al is not an
option.

- Frank
 
R

R.F. Pels

class AbstractPersonBean. The class defines an ejb.relation to an
AddressBean since every person has an address. Now I want to create
several concrete implementations of AbstractPersonBean, such as
StudentBean, TeacherBean, etc. Each of these classes may define
additional ejb.relations but I want them all to "inherit" the relation
defined in the abstract super class.

Hold on! Design error! Using derivation to model roles is a classical error.

What happens if the person represented by StudentBean gets in a car and
starts to drive? And how are you all of a sudden make this StudentBean into
a DriverBean??? See? Or, what happens if a person is a Student in one class
but teaches another class an hour later?

You want to model roles by derivation, and you cannot do that. You can use
the State pattern to model roles. In that case, a Person HAS_A Role.
 
F

fworsley

Yes, I am aware of that. I am not actually dealing with Person,
Student, etc. beans and am just using this as an example of a class
hierarchy. Although your point is well taken.

- Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top