Max, could you provide the example you were talking about? Puh! This subject got me nervous! :-)
Sure. A word of explanation. There are three important classes here: the rest are interfaces, and self explanatory.
A FactorypImpl that creates a generic factory, used by all clients, to get a remoteData object.
RemoteDataIampl that provides the functionality of a remote object. It offers two methods, doStuff and undoStuff, that might look familiar.
ClientDriver that creates 20 separate threads. Each thread creates gets a remoteData object by using the Factory. The then doStuff, wait a bit, then undoStuff.
to run the example, type in the following
One of the important things to notice here is that this design, the RemoteDataImpl classes uses the client itself as a key. Thus, you get free releasing of locks if a client dies. If you want more on this, read about weakHashMaps, which are a great little gem. FactoryImpl
Ok, thanks I will have a look. But at first glance your locking is done in your RemoteDataImp.My RemoteDataImp has Data as a member and I must implement locking in Data and Data doesnt know "bindingName". I have done almost as you except that i have modev my locking to a lockmanager class that is a member of RemoteDataImp. What I am trying to understand is how can i do what you do in RemoteDataImp in Data. How can I get "bindingName" into data? Or maybe I shouldnt? That is the thing i dont get. Are you confused, or am I ? :-)
Max, Can you tell me what is different between 1.Registry.rebind(StringName, RemoteObj) 2.Naming.rebind(StringName, RemoteObj). I am testing my rmi and locking part. I checked some past posts, people had the same problem as I had: getting ConnectionException, port already in use,connection refused. So I have to restart my computer, because I think I started several servers at same time and all of them using port 1099. Anyway, changing Naming to Registry is a solution, but I just don't know why. Maybe the cause is different, please clarify. BTW, Max and Mark, if you guys think this question need to be in a new thread, I will do so. Thanks Kevin
town drunk ( and author)
posted 17 years ago
Hi Kevin, I'll follow up on your question later today: I'm swamped right now. But yes, it might be a good idea to start a new thread, so people can take advantage of the question. Thanks, M