Why Application Servers require stubs to exist in order to do remote calls?
It is not a question but a discussion... I don't know if it is the right place, or not..
As you know, we can write our own java classloaders that can load classes over the network
So, Why application servers don't just do that? why when we are doing a remote call to a remote method exists inside another application server why we have to have stubs to return types and parameters?
I think application servers can load these return types and parameters remoting using something like Networ开发者_开发百科kedClassLoader
.
The whole idea of the proxy pattern is:
- to shield clients from the fact that the object they're talking to is not in their address space, it's on a remote server somewhere else on the network.
- to offload work from the client to server.
- to centralize an operation into a single service that can be shared by any client that can access the network.
I don't intend to make it a discussion, just to present my view.
The whole point of application server is that work is done on the server. If you load a class EJBImplementation
on client side and call some of its methods, then work will be done on the client side. Moreover, to do the work properly EJBImplementation
will have to pull a big chain of dependencies, make some calls to local database and God knows what else. So, in most cases such processing can't be done on the client side realistically.
Thus, we create a stub (proxy is the term) for EJBImplementation
, which instead passes method invokations over the network to the server.
精彩评论