Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why all classes are interfaces in EJB?  RSS feed

 
rajareddy dodda
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

why sun had given all interfaces in EJB? is there any specific reson?


Thanks in advance

RajaReddy
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because they tried it the other way and it proved to be a major amount of pain. The standards for a lot of technologies have moved from class inheritance towards interfaces.

The reason is simple. Java doesn't support multiple inheritance. Once you've determined the basic nature of a class, you're stuck with it. On the other hand, the most reusable components are simple JavaBeans. They're not tied to a given framework or system. It's easy to subclass a JavaBean, add an interface to it, implement the necesary additional methods and go. It's impossible to remove components from a superclass, however.

That's one of the primary reasons why the Data Transfer Object design pattern existed. Essentially, it recreated the same structure as its corresponding EJB, but without the EJB freight and limitations on use. By making EJB3 objects not require an EJB base class, the need for a separate DTO class is reduced or eliminated.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!