1

Is there any library out there that will allow developers to pass objects from one language to another and then manipulate/change the objects and pass them back?

This would be a great and simple alternative to Messaging and XML systems out there. I read about Colors which seemed to be what I was searching for but from what I understand it hasn't been released yet.

In my Java application (or any language, but java for this example) I'd like to use something like:

import beans.Person;

...

PythonObj pythonObj = new PythonObj("http://192.168.1.54/personGET/myusername/mypassword"); 
Person person = pythonObj.getPerson();

Which would consume an object published by Python via GET.

So I'm guessing there would need to be a library for each language. No need for any external boilerplate strings/files (xml, json, csv, proto, etc etc) for configurations, etc. Just the library import...

4

1 回答 1

2

如果您只需要投影现有对象信息并将其传递给系统,XMLJSON足够了(我也推荐使用 BSON 来提高性能并降低吞吐量)。

如果你想要一种不同的方法,我建议你看看Google ProtoBuffers,以获得更优雅和安全可维护的解决方案。

例如,您可以在Proto消息文件中将您的通信合同定义如下(例如:person.proto):

message Person {
  required int32 id = 1;
  required string name = 2;
  optional string email = 3;
}

然后您可以生成JavaC# 对象来处理此消息,从而使您可以轻松地在系统之间进行通信。

编辑:另外,看看Apache Thrift

于 2014-01-17T16:41:30.863 回答