Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock exam question

 
Shankar Ranganathan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True or false: an EJB cannot implement both local and remote business methods
POSSIBLE ANSWERS:
* True
* False
SOLUTION:
False, it can, allthough unusual
I don't understand this.
 
Darryl A. J. Staflund
Ranch Hand
Posts: 314
2
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I understand this to mean that an EJB can implement but the EJBHome and EJBLocalHome interfaces. The first can be used with remote clients) i.e. those originating outside the host JVM.) The latter can be used with local clients (i.e. those originating within the host JVM.)
Darryl
 
Shankar Ranganathan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Darryl,
I know what you are saying. But what I understood from that qn. is whether an ejb can implement both the local interface and as remote interface at the same time. That is why I was confused.
Thanks
Shankar
 
Darryl A. J. Staflund
Ranch Hand
Posts: 314
2
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
They can implement both EJBHome and EJBLocalHome at the same time. I can't think offhand of any reasons for doing this but I can think of reasons for not doing this. Such beans could not be CMP entity beans since CMP only supports local interfaces. Also, the performance optimizations you might want to implement for local interfaces might not be the same as performance optimizations for remote interfaces. Still, implementing a bean with local and remote home interfaces would allow you to support server-side web-based applications as well as remote applications, beans running in other containers, and Swing applications.
Darryl
 
Thomas Hofmann
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The business methods are defined in the component interface. Beside the EJBHome and EJBLocalHome the bean implementing "local and remote business methods" has to provide also both local and remote component interfaces, which extends EJBLocalObject and EJBObject, respectively. Thus, the business methods has to be defined in both component interfaces, but only implemented once in the bean class.
Thomas
 
Thomas Hofmann
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The business methods are defined in the component interface.

Sorry, I meant: The busines methods are declared in the component interface.
 
Rama Raghavan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When beans are to be accessed from within the application (that the EJB is part of) local interfaces improve performance.
When beans are to be accessed from applications deployed on other JVMs (or different classloader hierarchy), then remote interfaces are your only choice.
If the same bean is accessed from within the application, as well as other applications, then I'd provide both local and remote interfaces to the same bean.
Rama
 
Shankar Ranganathan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic