通过引用RMI不返回的ArrayList中传递 [英] Pass by reference not returning in RMI for ArrayList
问题描述
我有定义为一个RMI调用:
I've got an RMI call defined as:
public void remoteGetCustomerNameNumbers(ArrayList<String> customerNumberList, ArrayList<String> customerNameList) throws java.rmi.RemoteException;
该函数做数据库查找并填充两个的ArrayList。调用函数将一无所获。我相信这适用于矢量类型。
The function does a database lookup and populates the two ArrayLists. The calling function gets nothing. I believe this works with Vector types.
我是否需要使用Vector,或者是有没有办法得到这个未做两个呼叫工作。我已经得到了我可能会使用一样,返回键/值对一些其他的想法,但我想知道如果我能得到这个工作。
Do I need to use the Vector, or is there a way to get this to work without making two calls. I've got some other ideas that I'd probably use, like returning a key/value pair, but I'd like to know if I can get this to work.
更新:
我会接受所有到目前为止,如果我能给出的答案。我不知道网络的成本,所以这是有道理的返工函数返回LinkedHashMap中,而不是两个的ArrayList的。
Update:
I would accept all of the answers given so far if I could. I hadn't known the network cost, so It makes sense to rework the function to return a LinkedHashMap instead of the two ArrayLists.
推荐答案
随着汤姆提到,您可以通过远程对象。你必须创建一个类来保存列表实现远程。任何时候你传递的东西,远程实现作为参数,只要接收方使用它,它转身,使远程调用的回的调用者与该对象的工作。
As Tom mentions, you can pass remote objects. You'd have to create a class to hold your list that implements Remote. Anytime you pass something that implements Remote as an argument, whenever the receiving side uses it, it turns around and makes a remote call back to the caller to work with that object.
这篇关于通过引用RMI不返回的ArrayList中传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!