• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Implementing Interfaces in Bean - Required?

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic