本文主要内容涉及:
- CORBA基本架构
- IDL文件编写
- POA示例实现
- POA+TIE示例实现
- ImplBase示例实现
- ImplBase+TIE示例实现
- Persistent示例实现
要写一个静态绑定的CORBA程序,首先要完成的就是定义接口。CORBA采用的接口描述方式为IDL(Interface Description Language),IDL的语法规则类似于CPP,所以Java的类型需要做类型映射。常见类型映射关系如下:
| IDL Type | Java Type |
| module | package |
| boolean | boolean |
| char, wchar | char |
| octet | byte |
| string, wstring | java.lang.String |
| short, unsigned short | short |
| long, unsigned long | int |
| long long, unsigned long long | long |
| float | float |
| double | double |
| fixed | java.math.BigDecimal |
| enum, struct, union | class |
| sequence, array | array |
| interface (non-abstract) | signature interface and an operations interface, helper class, holder class |
| interface (abstract) | signature interface, helper class, holder class |
| constant (not within an interface) | public interface |
| constant (within an interface) | fields in the Java signature interface for non-abstract, or the sole Java interface for abstract |
| exception | class |
| Any | org.omg.CORBA.Any |
| type declarations nested within interfaces | “scoped” package |
| typedef | helper classes |
| pseudo objects | pseudo interface |
| readonly attribute | accessor method |
| readwrite attribute | accessor and modifer methods |
| operation | method |
现在,写一个很简单的IDL文件:
hi.idl
module HiCorba
{
interface Hi
{
string sayHiTo(in string someone);
long add(in long numa, in long numb);
oneway void shutdown();
};
};