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

Vikas Kedia picture Vikas Kedia · Sep 6, 2009 · Viewed 24.1k times · Source

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

Answer

rodrigoap picture rodrigoap · Sep 6, 2009

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.