IT Community - Software Programming, Web Development and Technical Support

How to invoke a method on a remote object?

This is a discussion on How to invoke a method on a remote object? within the Java Programming forums, part of the Software Development category; How to invoke a method on a remote object?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Java Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-17-2007, 11:17 PM
mobilegeek mobilegeek is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 205
mobilegeek is on a distinguished road
Default How to invoke a method on a remote object?

How to invoke a method on a remote object?

Last edited by mobilegeek : 07-30-2007 at 03:42 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-30-2007, 03:43 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Thumbs up Re: How to invoke a method on a remote object?

Hi MobileGeek,

You may first check for the availability of the remote object and then in case remote object exist, its method is invoked.
try {

// Look up a remote object
RObject robj = (RObject) Naming.lookup("//localhost/RObjectServer");

// Invoke method on remote object
robj.aMethod();

} catch (MalformedURLException e) {

} catch (UnknownHostException e) {

} catch (NotBoundException e) {

} catch (RemoteException e) {

}

Hope usefull
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-10-2007, 04:54 AM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 194
leoraja8 is on a distinguished road
Post Re: How to invoke a method on a remote object?

For a caller (client, peer, or applet) to be able to invoke a method on a remote object, that caller must first obtain a reference to the remote object. Most of the time, the reference will be obtained as a parameter to, or a return value from, another remote method call.
For bootstrapping, the RMI system also provides a URL-based registry that
allows you to bind a URL of the form //host/objectname to the remote
object, where objectname is a simple string name. Once a remote object is
registered on the server, callers can look up the object by name, obtain a remote object reference, and then remotely invoke methods on the object.

For example, the following code binds the URL of the remote object named
HelloServer to a reference for the remote object:
Naming.rebind("//myhost/HelloServer", obj);

Note the following about the arguments to the call:
• The host defaults to the current host if omitted from the URL, and no
protocol needs to be specified in the URL.
• The RMI runtime substitutes a reference to the remote object’s stub for the
actual remote object reference specified by the obj argument. Remote
implementation objects like instances of HelloImpl never leave the virtual
machine where they are created, so when a client performs a lookup in a
server’s remote object registry, a reference to the stub is returned.
• Optionally, a port number can be supplied in the URL: for example
//myhost:1234/HelloServer. The port defaults to 1099. It is necessary to
specify the port number only if a server creates a registry on a port other
than the default 1099.

Note – For security reasons, an application can bind or unbind only in the registry running on the same host. This prevents a client from removing or
overwriting any of the entries in a server’s remote registry. A lookup, however, can be done from any host.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you log in to a remote Unix box? sundarraja Operating Systems 1 01-22-2008 03:51 AM
Object reference not set to an instance of an object for crystal reports in .net KiruthikaSambandam Database Support 1 08-03-2007 03:26 AM
Remote control of Windows PCs simpler through PsExec than Remote Desktop oxygen Server Management 1 07-26-2007 03:27 AM
How can I invoke another program from C? Sabari C and C++ Programming 1 07-17-2007 04:05 AM
How can I invoke another program or command and trap its output in C? Sabari C and C++ Programming 1 07-17-2007 04:01 AM


All times are GMT -7. The time now is 11:37 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0