Results 1 to 6 of 6
Thread: passing objects w/RMI
- 02-03-2011, 08:29 PM #1
Member
- Join Date
- Dec 2010
- Location
- New Engaland
- Posts
- 11
- Rep Power
- 0
passing objects w/RMI
I am wondering if objects passed as parameters in RMI methods need to exist within the context of classes that implement interfaces? I have created a client class that implements an interface:
Java Code:public class Client extends java.rmi.server.UnicastRemoteObject implements ATMListener {
Java Code:public interface ATMListener extends java.rmi.Remote {
- 02-03-2011, 08:34 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
- 02-03-2011, 09:04 PM #3
Member
- Join Date
- Dec 2010
- Location
- New Engaland
- Posts
- 11
- Rep Power
- 0
The objects I am trying to pass both extend java.rmi.server.UnicastRemoteObject (which implements Serializable). These classes are defined as:
Java Code:package class.project; import java.rmi.RemoteException; public class AccountInfo extends java.rmi.server.UnicastRemoteObject { /** * */ private static final long serialVersionUID = 1L; private int account_number; private int pin_number; public AccountInfo(int account_number, int pin_number) throws RemoteException { super(); this.account_number = account_number; this.pin_number = pin_number; } public int getAccountNumber() { return this.account_number; } public void setAccountNumber(int account_number) { this.account_number = account_number; } public int getPinNumber() { return this.pin_number; } public void setPinNumber(int pin_number) { this.pin_number = pin_number; } }
Java Code:package class.project; import java.rmi.RemoteException; public class TransactionNotification extends java.rmi.server.UnicastRemoteObject { /** * */ private static final long serialVersionUID = 1L; private String notification; public TransactionNotification (String msg) throws RemoteException { super(); notification = msg; } public String toString() { return notification; } }
Java Code:public Float getBalance(AccountInfo account_info) throws java.rmi.RemoteException, ATMException, SecurityException, Exception {
Java Code:public void receiveTransactionNotification(TransactionNotification tn)
Please let me know if the calls to these methods need to be provided for clarification. Thanks!
- 02-04-2011, 09:08 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Build a wall around Donald Trump; I'll pay for it.
- 02-06-2011, 12:09 AM #5
Member
- Join Date
- Dec 2010
- Location
- New Engaland
- Posts
- 11
- Rep Power
- 0
Thanks! I later realized that the object only needed to be passed by value, so the suggestion was appropriate. However, I am still curious as to how the stub equivalent would have been implemented.
- 02-06-2011, 09:59 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
I don't understand your question; stubs live on the client side calling into a naming service (rmi registry) that supplies a skeleton that serves as a proxy for the real thing living on the server side. In the old day you had to generate those stubs and skeletons yourself with the rmic tool; nowadays it is done just before running the server object(s) and running the stub object(s).
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
Similar Threads
-
Passing Objects
By Java_Developer in forum New To JavaReplies: 6Last Post: 10-29-2009, 02:32 PM -
MVC passing objects
By simo_mon in forum New To JavaReplies: 1Last Post: 07-17-2009, 07:57 AM -
Passing objects into constructors
By aaronfsimons in forum New To JavaReplies: 8Last Post: 04-14-2009, 01:08 PM -
Passing objects in Java
By jbostjr in forum New To JavaReplies: 1Last Post: 10-30-2007, 11:15 PM -
Passing objects in Java
By jbostjr in forum Advanced JavaReplies: 1Last Post: 10-30-2007, 06:57 PM
Bookmarks