Vlada Matena wrote:
> I misunderstood your question. I still don't fully understand what you are trying to
>accomplish.
I think Mario may be bumping up against the Thou Shalt Not Inherit One
Entity Bean From Another stipulation, albeit indirectly.
Here's the kind of very simple thing that he probably wants to do, I'm
guessing, expressed this time in normal plain-old-Java code:
public abstract class Foo {
public abstract void bar();
}
public class SimpleFoo extends Foo {
public void bar() {
System.out.println("bar");
}
}
public class VerboseFoo extends Foo {
public void bar() {
System.out.println("I say, my good fellow, bar.");
}
}
public class FooFactory {
// sample implementation of a factory method
// that somewhat dynamically chooses what kind
// of Foo to return
public static Foo create() {
// figure out what kind of Foo to return
// could be SimpleFoo, could be VerboseFoo;
// we don't know yet
String fooType =
System.getProperties().getProperty("fooType", "SimpleFoo");
Class fooClass = null;
Foo returnMe = null;
try {
fooClass = Class.forName(fooType);
returnMe = fooClass.newInstance();
} catch (Exception anything) {
anything.printStackTrace();
}
return returnMe;
}
}
Now, in EJB when you're dealing with entity beans (probably not session
beans, but I dunno) you can't really do this, he's saying, because the
return type of an entity bean's EJBHome.create() method is a type
**which cannot be subclassed according to the specification**. The
example above works because SimpleFoo and VerboseFoo can both extend
Foo. But something like ShapeBeanHome.create(), which would presumably
return a Shape, cannot, according to the EJB spec if I'm reading it
right, return a TriangleBean in the guise of a ShapeBean.
Does that help? Or have I muddled the issue (which seems to be my
specialty)? :-)
Cheers,
Laird
===========================================================================
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".