Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

External interface extended by Remote Interface  RSS feed

 
Rajesh Agarwal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to know what could be the benefits by doing the following

Having an interface define some business methods. Then this interface is extended by the Remote Interface. Then in the Enterprise Bean implementing the external interface. I read that this provides a compile time check for method signatures of remote & bean. I dont understand this. I see this architecture is used in many places. Would appreciate if anyone can let me know benefits of having an external interface in this scenario.
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, one problem with EJB is that the remote component interface isn't directly implemented by the bean implementation, right? So, if I have my interface ...

... and in my bean class ...

... the compiler isn't going to care. It won't blow up until the EJB compiler runs. If instead, you put the method declaration into a separate interface, and had your remote interface extend that and your bean class implement it, then the compiler would catch that you didn't implement a method from the interface. In fact, you could have your bean class implement the remote interface with the same effect.

Now for my opinion: don't do it that way. Use an IDE to help you make the link, or use XDoclet. Or just wait for the EJB Compiler to tell you when you've screwed something up.
 
Rajesh Agarwal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Is it good only for compilation. Or is there any other benefits of having such an architerture. Just for compiler shout at the signature mismatch, I dont think this would be a recommended architecture.
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no other benefit of doing it this way.
It's matter of personal style as some people can not digest the fact that the bean class is not implementing the declared interface. It seems anti-OO to them and doing it this way satisfied them and container both.
As far as compiler checking goes, the IDE tools are gettig smarter and do this checking for you during the development.
Conclusion:, Either way is fine.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!