Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing value in constructor

 
Neel Chow
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a rmi server whose implemetation is like this.
public class query extends UnicastRemoteObject implements QueryInf
{
..................;
public query(String schema,String[] select,String from, String where)
{
..............;
}
...........;
...........;

}
My question is from the client program how can I pass the value to the query constructor?
thanks
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but you can't call a constructor from a remote client - the server is created on the server machine and already running, it doesn't get created by the client. And besides, only remote methods can be called from the client, and the constructor can't be a remote method.

There are a couple of ways around this though. One way is that you could make a remote method to "set up" the parameters that the user is supposed to call before other methods get called. Another (and better) choice is make your server a "query factory" that the client calls methods on and passes parameters to in order to get a reference to a "query" back. The "query" could be serializable and be sent to the client, or it could be another Remote class, in which case the stub gets sent to the client as a reference.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic