2
votes

I am developing the distributed application in CORBA Using the Java IDL provided by default in JDK , and of course , both client and server developed in Java.

I am maintaining the some object state on server.

Now, on client side I want to bring whole state (snapshot) of that object from server side. and this is object is of some Java type . As I cannot pass the whole object of any Java type from server to client, because of IDL definition and of course CORBA feature as it is language neutral.

One way I found, is using JSON

I will flatten the whole Java Object of any type into string and pass same to client using string data type, later on client I can deflatten the object from string. also I can define the string type in idl.

but this adds the some processing for flattening/ deflattening on both sides

is there any other way to pass object from client? or may be I missed something?

Update:

Objects of Following types are transferred

class MyObject{ Map<String,String> object; }

3
could you please show an example definition of the object you want to transfer?tuergeist
@tuergeist provided type definition of object.ajduke

3 Answers

1
votes

CORBA already has the concept of Objects-By-Value, so you could use that if your ORB supports it. Put your state variables in a valuetype and go from there.

Keep in mind that CORBA is not Java. CORBA can be used with many languages so if you find yourself trying to figure out how to send Java-only things across a CORBA system, you're going to find that very difficult. To transmit anything in CORBA it's got to be representable in IDL first and foremost. If valuetype doesn't meet your needs then use the struct approach that the other answer suggested.

0
votes

That sounds as if you want to have the object state become part of the interface (because if you actually transfer the state, being able to recreate the object depends on the receiver to understand the transmitted state, hence it becomes an interface).

Thus, define a struct containing the data fields in the IDL, and add a method to the object interface to return the state in this form. The transfer is then handled by the regular CORBA marshaller.

0
votes

You just have to define your MyObjects as CORBA objects. For that you'll use the IDL. Your Map is a simple name,value list.

module Foo { 
  struct MapEntry { 
    string name;
    string value;
  }; 

  sequence<MapEntry> MyMap; 
  }; 
}; 

This will create an Array of MapEntry Objects in Java. If you want to remap them into a Java Map, feel free. This is the CORBA way of transferring a map of something. Create a struct, put it into a sequence, done. This also works properly for other languages supported by CORBA (e.g., C++)