0

Is calling a remote @remote interface from within the same EJB-JAR or EAR would make the app server use RMI/RMI-IIOP?

Or the App Servers would be much intelligent and doing this call locally as if it calls a @local interface???

Muhammad Hewedy
  • 29,102
  • 44
  • 127
  • 219

1 Answers1

1

The container should not do a truly @local call because @local call pass by reference and @remote calls pass by value. However the container can optimise the @remote call so that the full RMI/IIOP network stack is not hit. As I recall WebSphere does such "local" optimisations, I can't speak to other vendors.

[History: Way back in early pre EJB3 versions of WebSphere there was an option to enable the moral equivalent of the "make @remote look like @local" but I don't think later version do offer this.]

djna
  • 54,992
  • 14
  • 74
  • 117
  • What if I annotate my session bean with both `@remote` and `@local` and call it from inside the same EAR using `@EJB` DI, what is the behavior of the App Server in this case? – Muhammad Hewedy Aug 10 '11 at 11:26
  • This will depend on how the client chooses to access it. You have simply created two paths into the EJB, for local and remote clients. If client uses the local then they get local behaviour. I'm not sure how injection on client side will look in the two cases - never tried this myself. – djna Aug 10 '11 at 11:33
  • It depends on the type of field being injected with @EJB; you should be able to inject either flavor. Of course, you need to carefully ensure that the caller and callee do not modify pass-by-reference data. – Brett Kail Aug 10 '11 at 21:17
  • The ORB in current versions of WebSphere Application Server still support the "no local copies" switch, though its use is usually strongly discouraged. – Brett Kail Aug 10 '11 at 21:18