• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing Interfaces in Bean - Required?

 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In Manning's EJB3 in Action, P77, it says "each interface that the bean intends to support must be explicitly included in the bean implementaion classe's implements clause

However, I'm sure I remember reading somewhere (can't quite find where), that implementing the business interfaces was optional.

I've looked through the spec and have found in the simplified spec (3.2) - "The bean class may implement its business interface(s). While it is expected that the bean class will typically implement its business interface(s), if the bean class uses annotations on the
bean class or the deployment descriptor to designate its business interface(s), it is not required that the bean class also be specified
as implementing the interface(s).
"

This sounds like a mistake to me? I've checked the errate and it's not there.

Just checking whether it is a simple mistake, or whether I've misunderstood something.

Thanks,

MG
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not required to implement a bean interface. Instead of that, we can use @Remote/@Local annotation with the @Stateless/@Stateful annotation on the bean class. So that bean class can be used as a 'business interface' too.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would formulate it that way: The session bean class must implement its business interface(s) explicitly or implicitly.

// "explicit":
@Stateless
public class XBean implements X{...}

// "implicit"
@Stateless
@Remote(X.class)
public class XBean{...}

However, implementing it explitily has the advantage, that it is checked at deployment time if the interface is implemented properly.
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you both for your replies - just sounds like the sentence was worded badly in the book.

I tried it without implementing the interface explicitly in JBoss (implementing it implicitly) and it worked a treat.

Thanks once again,

MG
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic