CORBA中典型的的一个问题多种实现方法

1         直接获取对象引用

1.1       通过 IOR

orb.string_to_object(IOR )

1.2       通过 Corbaoc URL

orb.string_to_object(Corbaoc URL)

1.3       通过 Initial References

orb.resolve_initial_references( 某个 Initial References 的键 )

Initial References 是一堆键 - 值对,在 orb 初始化的时候设置,不同厂商的 orb 有不同的设置方式

2         从名服务获取对象引用

假设 nc 是已经获取的 NamingContextExt 类型的对象,“ XXX ”是某对象在名服务上注册的名字。

2.1       两步走

nc.resolve(nc.to_name("XXX"))

 

to_name

String to_string (NameComponent [] n)

                 throws InvalidName

This operation creates a stringified name from the array of Name components.

Parameters:

n - Name of the object

Throws:

org.omg.CosNaming.NamingContextExtPackage.InvalidName - Indicates the name does not identify a binding.

InvalidName

 

resolve

Object resolve (NameComponent [] n)

                throws NotFound ,

                      CannotProceed ,

                      InvalidName

The resolve operation is the process of retrieving an object bound to a name in a given context. The given name must exactly match the bound name. The naming service does not return the type of the object. Clients are responsible for "narrowing" the object to the appropriate type. That is, clients typically cast the returned object from Object to a more specialized interface.

Parameters:

n - Name of the object

Throws:

NotFound - Indicates the name does not identify a binding.

CannotProceed - Indicates that the implementation has given up for some reason. The client, however, may be able to continue the operation at the returned naming context.

InvalidName - Indicates that the name is invalid.

2.2       一步到位

nc.resolve_str("XXX")

 

resolve_str

Object resolve_str (String  sn)

                   throws NotFound ,

                           CannotProceed ,

                          InvalidName

This operation resolves the Stringified name into the object reference.

Parameters:

sn - Stringified Name of the object

Throws:

NotFound - Indicates there is no object reference for the given name.

CannotProceed - Indicates that the given compound name is incorrect

org.omg.CosNaming.NamingContextExtPackage.InvalidName - Indicates the name does not identify a binding.

InvalidName

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值