Are jone RMI remote objects (server side) singleton?

I've been using java RMI for a while, but I couldn't figure out if remote RMI (server side) remote RMIs are single? The reason I am asking:

suggests that one of the RMI implementation methods below in the call chain has a synchronized method. If for some reason the logic of a synchronized method gets messed up (or hangs), future RMI calls (from the client) will hang trying to access that synchronized method. This will only be true if the RMI stubs are single. If every remote call from the client creates a new server-side object, this won't be a problem, because methods called from another object and a synchronized method will no longer be a problem.

Shortly speaking. I am trying to understand how the JVM internally supports rmi server side remote objects and if they are solid color. I've tried many different javadocs, but they don't mention it in any way.

Any help is appreciated!

EDIT Based on some questions and comments, I clarify the question: to my real question, is there some sort of object pool on the server side in RMI, based on which one object are you exporting and registering? Can you link multiple objects of the same type with the same name (somewhat mimicking an object pool in which RMI can provide me with any of the objects I have registered) or in order to have multiple instances of the same object I will have to register them with different names

+3


source to share


4 answers


First of all, "stub" is a client side concept, there are no stubs on the server.

As with the remote objects themselves, RMI does not create objects for you, it is up to you to instantiate and export them. You create one instance of an object, export that object, and bind it in the registry under a specific name. All calls to client stubs received from the same name in the registry will end up on the same object on the server.



Is it possible to link multiple objects of the same type with the same name (somewhat mimicking an object pool where RMI can provide me with any of the objects I have registered)

No, you can only bind one object in the registry with a given name. But the object you are linking can itself be a proxy for your own object pool, for example using the Spring AOP CommonsPoolTargetSource mechanism .

+4


source


Pins are not singles, but your question is really about server objects. They are also not solitary unless you implement them yourself. RMI does nothing about it.

EDIT. Based on some questions and comments, I clarify the question: my real question is that RMI on the server side keeps some sort of pool of objects based on which one object you export and register?

Not.

Is it possible to link multiple objects of the same type with the same name



Not.

I will need to register them with different names

You don't need to register them at all. You need one remote singleton object associated with the registry: consider it as a factory method for further remote objects that are returned as results from its remote methods. For example, a remote login object is associated in the registry and has a single method login()

that returns a remote session object new to login with its own API.

+2


source


RMI is based on the proxy design pattern.

See what says here

An RMI server is an application that creates multiple remote objects. The RMI server is responsible for:

  • Create an instance of a remote object (for example, CarImpl instance = new CarImpl ());
  • Export of a deleted object;
  • Linking a remote object instance to the RMI registry.
+1


source


From Java docs:

http://docs.oracle.com/javase/7/docs/platform/rmi/spec/rmi-arch3.html

The method sent by RMI for a remote implementation object may or may not run on a separate thread. RMI runtime makes no guarantees about the mapping of remote object calls to threads. Since a call to a remote method on the same remote object can be performed concurrently, the implementation of the remote object must ensure that its implementation is thread safe.

Yes, the server side method is synchronized. The implementation is platform specific. You can't do anything else about it about streams. And you certainly cannot guess if the remote object is single.

Also, it would be helpful to look at the activation of remote objects:

http://docstore.mik.ua/orelly/java-ent/jenut/ch03_06.htm

http://docs.oracle.com/javase/7/docs/api/java/rmi/activation/package-summary.html

0


source







All Articles