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

ejbejb-3.0jakarta-ee

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 cant I have a common interface and in my Bean I should just be able to say that I want this bean to be accessed remotely and/or locally.

thanks
Vikas

Best Answer

This is what the EJB spec says:

The choice between the local and the remote programming model is a design decision that the Bean Provider makes when developing the enterprise bean.
While it is possible to provide both a remote client view and a local client view for an enterprise bean, more typically only one or the other will be provided.

JSR220 Chapter 3

So when writing a bean think about who is the client, it's very unlikely that a local client will need the same methods or even the same bean that a remote one.

Related Topic