Phil Lewis wrote:
> The idea is that whenever we want to create an instance at runtime we
> determine whether there is an appserver present, and if there is we create
> an instance of (eg) MyClassNormalFactory, otherwise we create an instance
of
> MyClassEJBFactory. We then call the create method on the factory. The
Normal
> factory simply returns a new instance of NormalImpl, whereas the EJB
factory
> does the JNDI lookup to get the Home interface, then calls create on the
> home interface.
>
> However, because for EJB we need to always deal with the remote interface,
> and for non-ejb we don't want to deal with the remote interface, this
makes
> the factory difficult to define and however I try to declare the create
> method, and cast or cajole the return values, I get type mismatches.
Perhaps I have misunderstood, but it should be possible to have both factory
create methods return the bean's Business interface. Since both the ejb and
non-ejb versions implement this interface, this should be possible, should
it not?
For instance, both MyClassNormal and MyClassEJB implement the interface
MyClassBusiness. Hence both MyClassNormalFactory.create() and
MyClassEJBFactory.create() should return a MyClassBusiness. Since
MyClassBusiness does not inherit from EJBObject, all is well from the client
point of view. Should you need access to finder methods, you could export
those from your class factories as well, by returning collections or
enumerations of MyClassBusiness interfaces. Actually, come to think of it,
a clean way doing it would be to create a ClassFactoryFactory to generate
either EJB or Normal ClassFactories on demand...
Jeff 8-)
===========================================================================
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".