Phil Lewis wrote:

<snip>

The problem is that the MyClassEJBFactory creates an instance of the remote
interface using MyClassHome. When I try to fave the MyClassEJBFactory return
the remote interface, I get a compile time error saying that the factory
method
needs to return MyClassBusiness.

</snip>

This seems a bit strange to me, as I'm doing something very similar in some
benchmark code that I've written, where I have a number of beans that
implement the same interface with different implementations for
benchmarking.

Basically, I've implemented it as follows

//  Business interface holds all business methods (a la Monson-Haefel, et
al)
public interface MyClassBusiness {
  public method1()
  ...
}

//  Remote Interface
public interface MyClass extends MyClassBusiness, javax.ejb.EJBObject {}

//  Local version of same - could be an interface or a class
public interface MyClassLocal extends MyClassBusiness {}

public abstract class MyClassFactory {
  public MyClassFactory() {};
  public abstract MyClassBusiness create();
}

public MyClassEJBFactory extends MyClassFactory {
  ...

  public MyClassBusiness create() {
    return (myClassHome.create());
  }
}


While I haven't tested this construction, I see no reason why the compiler
would complain about this since myClassHome.create() returns a MyClass
interface which IS a MyClassBusiness.  Note that to make this work, you need
to put all your business methods in a separate interface which is inherited
by both MyClass and MyClassLocal a la Monson-Haefel.  If your MyClass
interface extends MyClassBusiness, then your MyClassEJBFactory should be
able to cast MyClass interfaces to MyClassBusiness interfaces with impunity.

Note that this *does* mean that you lose the stuff in javax.ejb.EJBObject.
If this is a problem, then your local object needs to implement
javax.ejb.EJBObject as well, in which case MyClassFactory can return MyClass
interfaces instead of MyClassBusiness interfaces.  Alternatively, you could
use run-time casting (yuck!), or implement a third interface which extends
MyClassBusiness with the methods from javax.ejb.EJBObject() that you
require...


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".

Reply via email to