CORBA 序列:我可以使用方法定义对象序列吗?

发布于 2024-09-19 11:38:30 字数 258 浏览 13 评论 0原文

我有一个接口,其中的方法应返回项目列表,并且每个项目都应具有与其关联的某些方法。例如,我想定义一个方法 listAllItems() ,它返回一堆“item”对象,这些对象附加了方法(这样我就可以让客户端进程选择其中一个项目并说 itemone.buy() 例如,这将在服务器上执行相应的方法)。

我可以在 CORBA 中执行此操作吗?看来我无法定义“界面项”,然后在其他界面中说“序列”。

如果有影响的话,我会将我的 idl 编译为 Java。

谢谢!

I have an interface with a method that should return a list of items, and each item should have certain methods associated with it. For example, I want to define a method listAllItems() that returns a bunch of "item" objects which have methods attached to them (so I can have the client process pick one of the items and say itemone.buy() for example, which would execute the corresponding method on the server).

Can I do this in CORBA? It seems I can't define "interface Item" and then in some other interface say "sequence".

I'll be compiling my idl to Java, if it makes a difference.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幸福%小乖 2024-09-26 11:38:30

Peyton 所需的信息(IDL 序列和 Java 集合类型之间的概念映射)可以在本手册的物理第 42 页、索引第 23 页上找到:

http://www.omg.org/spec/I2JAV/1.3/

并回答他的问题:显然,java实际上甚至没有指定序列对象如果你输入def。当然,欢迎您手动执行此操作。但是,如果您想依赖 idlj 自动为您完成的操作,则必须使用Helper.java 中的方法。它们使用[] 类型的简单数组,并包括 getter 和 setter。

简而言之: 如果您的 idl 包含

struct MyObject
{
  long my_int;
};
typedef sequence<MyObject> MyObjects;
interface HasArray
{
  attribute MyObjects some_stuff;
};

那么您的 java 实现将需要:

public class HasArrayImpl extends HasArrayPOA
{
  private List<MyObject> local_storage;

  /** getter */
  MyObject[] some_stuff()
  {
    /* ... */
  }

  /** setter */
  void some_stuff(MyObject[] newSome_stuff)
  {
    /* ... */
  }
}

在幕后,Java 将为您创建 MyObjectsHelper 和 MyObjectsHolder。

The information Peyton needed, the concept mapping between an IDL sequence and a Java set type, can be found on physical page 42, indexed page 23, of this manual:

http://www.omg.org/spec/I2JAV/1.3/

And to answer his question: apparently, java doesn't actually specify a sequence object even if you typedef. You are of course welcome to do so manually. But if you want to rely on what's done for you automatically by idlj, you're going to have to use the methods in <ObjectType>Helper.java. Those work with simple arrays of the type <ObjectType>[], and include getters and setters.

In brief: If your idl contained

struct MyObject
{
  long my_int;
};
typedef sequence<MyObject> MyObjects;
interface HasArray
{
  attribute MyObjects some_stuff;
};

Then your java implementation would need:

public class HasArrayImpl extends HasArrayPOA
{
  private List<MyObject> local_storage;

  /** getter */
  MyObject[] some_stuff()
  {
    /* ... */
  }

  /** setter */
  void some_stuff(MyObject[] newSome_stuff)
  {
    /* ... */
  }
}

And under the hood, Java would create MyObjectsHelper and MyObjectsHolder for you.

做个少女永远怀春 2024-09-26 11:38:30

当然可以。

您必须提供更多详细信息,说明为什么您说它不适合您。但我经常使用包含一系列接口的 IDL。

Sure you can.

You'll have to give more details on why you say it isn't working for you. But I regularly work with IDL that contains a sequence of interfaces.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文