Why do we need separate Remote and Local interfaces for EJB 3.0 session beans

后端 未结 6 511
忘了有多久
忘了有多久 2020-12-23 13:59

I was wondering why do we need separate Remote and Local intefaces for EJB 3.0 Session beans. I guess most of the time they would both be defining the same contract. Why can

6条回答
  •  一个人的身影
    2020-12-23 14:42

    The notion of "location transparency" is a dangerous anti-pattern. Your design absolutely needs to know if it's making a local call or a remote call, for many reasons (error handling and performance being the most obvious).

    Remote EJB interfaces are distinct from their local counterparts because the exception signature needs to be different to accomodate the networking-related errors that can only occur on a remote call. Saddling the remote-handling baggage to the Local interface (as was the case in EJB 1) makes the code horrible. EJB 2 introduced separate Local interfaces to simplify programming for EJBs that were always local.

提交回复
热议问题