【发布时间】:2012-10-24 13:20:37
【问题描述】:
我现在正在研究分布式系统,所以...我必须学习 IDL 的东西。 :D 我有这个要求:
在 IDL 中定义 - 作为结构的帐户 - 帐户作为帐户的序列 - 具有一些帐户操作的客户界面: payIn (amount, accountId), - 如果成功则返回 true,否则返回 false getAccounts (name), - 返回一个账户序列(属于这个人) - 具有帐户操作的界面管理员: 创建一个新帐户 删除帐户
这是我的 .idl 文件:
module AccountNaming
{
struct Account
{
long id;
double balance;
string name;
};
typedef sequence<Account> accounts;
interface Customer
{
boolean payIn(in double amount, in long accountId);
accounts getAccounts(in string name);
string helloCust();
};
interface Administrator
{
void createAcc();
void deleteAcc();
string helloAdmin();
};
};
我已经为 IDL 生成了所有的 POA、Helper、Holder 类。
在我的 Java 代码中,我有一个使用 IDL 代码的类:
import AccountNaming.*;
public class CustomerImpl extends CustomerPOA
{
public String helloCust()
{
return "Hello, dear Customer! :) ";
}
@Override
public boolean payIn(double amount, int accountId)
{
// how to get to the Customer's local variables ?
super.Customer.setAmount... // or something like that, because this doesn't work... etc.
return false;
}
@Override
public Account[] getAccounts(String name)
{
// TODO Auto-generated method stub
return null;
}
}
我知道 .idl 文件是正确的。 “helloCust/admin”方法有效。我的问题是如何访问客户/管理员的变量,以便我可以将它们设置为 payIn 、 getAccounts 方法中的参数...
【问题讨论】:
-
Customer是一个没有任何变量的接口,对吧? -
我认为您的“工作流程”还不清楚。谁创造了客户?识别客户的关键是什么...管理员应如何管理客户?
标签: java variables arguments corba idl