• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem with RMI factory stubs

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am using RMI factory to generate a Service object for each client (since each will have its own Data object for identification).

The problem is: I generated the stub for the factory (RemoteServiceFactoryImpl) and the remote implementation of Service (RemoteServiceImpl).

The client correctly gets the factory stub, instead of dynamically downloading it. Though I can't get the RemoteServiceImpl stub.

Here is what I do in the factory:


In the client, when I use this getService() from the factory stub, I get complaints that RemoteServiceImpl is not Serializable (and everything it has, such as the delegated LocalService and Data).

If I make RemoteServiceImpl implement UnicastRemoteObject, then only RemoteService is Serializable, not LocalService and the rest of the chain. But in this case, the stub is never fetched, and this goes against the specs.

Do I really need to make everything Serializable? Is there another way around?

Thanks in advance.
 
Jo�o Batista
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am I going into the right direction? Serializing everything?

I found an example explaining the RMI factory pattern at:
http://www.itec.uni-klu.ac.at/~harald/ds2001/rmi/factory/factory2.html

But the object the factory creates extends UnicastRemoteObject. But I can't use that, because the client would not bother with the stub and download the remote object dynamically, right?
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You don't have to serialize everything. Remember that RMI is a remote call, real object is still sitting on the server. Only object that put into or returned from that remote object must be serializeable.

Hope this help
 
Jo�o Batista
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I understand that I shouldn't need to serialize everything, but my fear is that the only way not to do it, is using UnicastRemoteObject, which is making the client download dynamically the stub. If I have:


I created the stub just for FactoryImpl.
Then client performs lookup and fetch a FactoryImpl_Stub instance.
Then calls getRemoteService() from it to get a remote instance of RemoteServiceImpl.

The above works, whether the stub for RemoteServiceImpl is created or not.
What you're saying is that I just need to create the stub for it and the client would use it instead of downloading it dynamically? How can I be sure of that?

Thanks in advance.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You are doing the right thing. But you must also manually create a stub for RemoteServiceImpl in addition to the factory. Then it won't be downloaded dynamically.
 
Jo�o Batista
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for confirming that. I was worried that the stub was ignored either way.

I tried without extending UnicastRemoteObject, and using UnicastRemoteObject.export(this) in the constructor.

That way the stub is really necessary and it won't work otherwise.
 
Replace the word "snake" with "danger noodle" in all tiny ads.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic