[snip -- inheritance in entity beans]

Pure polymorphic EJBs aren't possible at this time (appendix B of
the new spec, section B.2, addresses this specifically).

<spec_quote>
The current EJB specification does not specify the concept of component
inheritance. There are com-plex
issues that would have to be addressed in order to define component
inheritance (for example, the
issue of how the primary key of the derived class relates to the primary key
of the parent class, and how
component inheritance affects the parent component�s persistence).
However, the Bean Provider can take advantage of the Java language support
for inheritance as follows:

  Interface inheritance. It is possible to use the Java language interface
inheritance mechanism
for inheritance of the home and remote interfaces. A component may derive
its home and
remote interfaces from some �parent� home and remote interfaces; the
component then can be
used anywhere where a component with the parent interfaces is expected. This
is a Java lan-guage
feature, and its use is transparent to the EJB Container.

  Implementation class inheritance. It is possible to take advantage of the
Java class implemen-tation
inheritance mechanism for the enterprise bean class. For example, the class
Checkin-gAccountBean
class can extend the AccountBean class to inherit the implementation of
the business methods.

</spec_quote>

Implementation inheritance and remote interface inheritance are relatively
straightforward,
but I can't see how home interface inheritance could work non-trivially,
since the create()
and findXXX() methods are the source of the trouble in the first place. (I
confess that I still
haven't completely digested the 1.1 stuff, though -- I guess you could
declare a couple of
finders that return collections of supertypes from which all the remote
interfaces inherit).
(Man, if my old English teacher saw that sentence, she'd hit me with a ruler
for sure. :-) ).


(I know there's a _really_ good writeup on this subject somewhere
in the EJB-INTEREST archives, but I couldn't find it just now. Anyone
have the URL?)

>Are there any guidelines available yet on these sort of issues for
>relatively new EJB players such as myself? Does Tom's book address these
>sorts of "architectural/design pattern" issues.


Not really; I had a brief section on EJB inheritance, but I yanked it in the
editing process. Here it is:

<outtake>
Inheritance in EJB

Implementing inheritance relationships in EJBs is a bit tricky.  Basically,
the problem is that, in the Java language, it is illegal to have a method in
a child class that differs from the parent class implementation only in
return type. That is, if you have a parent class with a factory method with
the signature

Parent create(int parentID)

you can't implement a method in the child class with the signature

Child create(int parentID).

See where I'm heading with this? To create an inheritance relationship in a
bean, you'd like to inherit three things:
=The child bean's implementation class should inherit from the parent's
implementation class.
=The child's remote interface should inherit from the parent's remote
interface.
=The child's home interface should inherit from the parent's home interface.

There's no problem with inheriting the functionality of the implementation
class (which is a good thing; it means that you can implement a base class
and not have to cut and paste to generate the same functionality in child
classes). Inheriting the remote interface should present few problems as
well. But you can't inherit from the home interface without breaking the
rules of the Java language.

Two out of three is not bad, so you may well wish to use inheritance in your
programs; you must remember to create a brand-new home interface for your
inherited beans, though.

</outtake>

In the book,I don't really promulgate patterns
in the GoF sense. I felt that it was too early to write about EJB patterns
as such. (The
rule of thumb is that something should have been used in three successful
implementations before it's called a pattern).

You can check out the table of contents and the preface from
http://cseng.aw.com/bookdetail.qry?ISBN=0-201-60446-9&ptype=0
That should give you a good sense of what I cover.

Actually, a few months back, I put up a placeholder HTML page
to serve as a repository for EJB patterns as they are discovered. It's
still basically empty.
http://patriot.net/~tvalesky/ejbpatterns.html
If anyone's putting together their own EJB pattern site, let me know and
I'll
link to you. If you've written up some EJB patterns but don't have a
website,
I'll be glad to post 'em on mine for you. Whatever.

===========================================================================
  Tom Valesky   -- [EMAIL PROTECTED]
       http://www.patriot.net/users/tvalesky

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to