Yes,I am interested. Please send me a piece of your sample code. Thanks.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 25, 2000 10:27 AM
To: [EMAIL PROTECTED]
Subject: Re: downcast / EJB-Inheritance
The problem is (as was pointed out) that when you have the remote interface
you know what class you are going to get. If you are not using reflection,
thst is.
There is a workaround for this by using a session bean as a factory. The
workaround is usually satisfing in most cases but not perhaps in yours.
Say that there are 3 different entity beans called, EmployeePerson,
ManagerPerson, CEOPerson. You want to get access to a person depending on
his/hers name.
Let all person EJBs RemoteInterfaces implement the interface IPerson. And
the bean classes may or may not subclass PersonBean (depending on if you
want to use inheritence).
Create a session bean with a method getPerson(String name):IPerson. The
method will lookup the persons position and create the proper entity bean.
And return it.
The caller may afterwards downcast the received person, depending on the
needs.
It is a bit messy because the factory will need a factory in itself (the
Home interface). There is however nothing in the way of having it as a
local class, apart from performance etc.
The factory pattern if you are not familiar with it, is described in most
sites dedicated to patterns.
I also have some code somewhere, mail me if you want it.
/erik
<open source promotion>
check out www.backsource.org for percolator a useful EJB generator to aid
your development.
</open source promotion>
===========================================================================
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".
===========================================================================
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".