Hi Laird,
In version 3.2, the behavior has been extended/clarified especially when
the bean class implements more than one business interface.
But as far as I recall, nothing did change regarding business interface
inheritance which is the case here.
Unless explicitly specified in the @Local annotation of implementing both
directly, I would not expect a different behavior than Glassfish.
AFAIR, only ApplicationException has an inherited attribute allowing
exception hierarchies. But nothing for business interface hierarchies.
Opening a Jira so that we won't forget to discuss that point.
https://java.net/jira/browse/EJB_SPEC-119
Jean-Louis
2014-03-07 20:36 GMT+01:00 Laird Nelson <ljnelson_at_gmail.com>:
> Hello. For various reasons both good and bad, our codebase has lots of
> EJBs in it that are defined like this:
>
> @Local
> @Stateless(name = "Caturgiator")
> public class CaturgiatorBean implements Caturgiator {
> }
>
> As it turns out, Caturgiator extends a superinterface:
>
> public interface Frobnicator {
> }
>
> public interface Caturgiator extends Frobnicator {
> }
>
> In my SLSB above as I have it written, I certainly would not expect it to
> have any other business interface other than Caturgiator, and indeed it
> does not.
>
> If though I wanted to ensure that it *also* exposed the Frobnicatorbusiness interface, I thought I had two options. One option is obvious,
> and I'll mention it here just for completeness:
>
> @Local({ Caturgiator.class, Frobnicator.class }) // specify explicitly
> @Stateless(name = "Caturgiator")
> public class CaturgiatorBean implements Caturgiator {
> }
>
> ...and works just fine.
>
> But we have many, many, many (many!) EJBs that follow this pattern.
> Bulk changing all of their @Local annotations to explicitly specify all
> business interfaces is going to be tedious to say the least. I was hoping
> that I could do something else.
>
> Section 4.9.7 of the EJB 3.1 specification says (in part, on page 125):
>
> "A bean class is permitted to have more than one interface. If a bean
> class has more than one interface--excluding the interfaces listed below--any
> business interface of the bean class must be explicitly designated as a
> business interface of the bean by means of the Local or Remote annotation
> on the bean class *or interface* or in the deployment descriptor."
>
> I was hoping that the part that reads "by means of the Local or Remoteannotation on the bean class *or
> interface*..." would help me out here. So I amended my example as
> follows (note the addition per spec of @Local to Frobnicator):
>
> @Local // hope this will "flow downhill" into the
> // business interfaces exposed by
> // CaturgiatorBean....
> public interface Frobnicator {
> }
>
> public interface Caturgiator extends Frobnicator {
> }
>
> @Local // probably leaving this here is problematic
> @Stateless(name = "Caturgiator")
> public class CaturgiatorBean implements Caturgiator {
> }
>
> That didn't work; the only business interface exposed by Glassfish 3.1.2.2
> (the reference implementation) was Caturgiator.
>
> Removing the potentially problematic @Local annotation from
> CaturgiatorBean did nothing; the only exposed business interface was
> (again) Caturgiator. This surprised me.
>
> Is this a bug in Glassfish, or have I misunderstood this part of section
> 4.9.7 that says I can put @Local on the business interfaces I want to
> expose and therefore have any EJBs that indirectly implement them have them
> show up in their list of business interfaces?
>
> Thanks,
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>
--
Jean-Louis