IDL and array of objects

Hey all...

in my idl i have declared sth like :

interface Job

{

struct lineArrayServers{

string objServerRef;

string functionName;

};

};

interface Services{

typedef sequence <Job> arrayOfServers;

void addService(in TheCallbackInterface objRef, inlong data, in arrayOfServers arOfServers);

void multiplyService(in TheCallbackInterface objRef, inlong data, in arrayOfServers arOfServers);

void sendNextServer(in TheCallbackInterface objRef, inlong data, in arrayOfServers nextServer);

};

};

for the implementation of the addService function i have sth like the following

publicvoid addService(TheCallbackInterface objRef,int data, Job jobServers[]){

System.out.println("Add server : "+data);

int tempresult=0;

tempresult = data + data;

System.out.println("Add server : tempresult is "+tempresult);

sendNextServer(objRef, tempresult, jobServers);

};

publicvoid sendNextServer(TheCallbackInterface objRef,int data, Job jobServers[]){

System.out.println(me.toString());

[b]System.out.println("obj ref tou pinaka "+jobServers[0].objServerRef);[/b]

of course it fails to access the objServerRef from the array jobServers. As far as i can understand I want to access the objServerRef string of the object that is in the first record of jobServers[]....

semantically i should make some get and set functions right? the thing is that this class (Job) is made automatically from the IDL...

how can i access the string variable of an object class Job that is in an array ?

[2502 byte] By [panosjavaa] at [2007-10-3 11:29:45]
# 1

There is no 'string variable of an object class 'Job'. There is in the struct 'lineArrayServers', but that defines a type, not an object. If you have a look at the generated ineArrayServers.java you'll see that those public String members do exist in lineArrayServers, but you haven't defined any methods to set or get a member of type lineArrayServers in a Job object. So no object of type lineArrayServers exists. So you can't access its public String members.

ejpa at 2007-7-15 13:56:14 > top of Java-index,Core,Core APIs...
# 2

yes you are correct about that and i am thinking of making a class Jon and not declare it in the IDL file, because i do not want to modify the classes created automatically by the idlj.exe ..even if i declare some functions get and set in the idl i should extend and implement them...

i will think of sth!!!

thanks a lot;-)

panosjavaa at 2007-7-15 13:56:14 > top of Java-index,Core,Core APIs...
# 3
Just add getLineArrayServers() and setLineArrayServers() to the IDL interface, and implement them in your implementation class.
ejpa at 2007-7-15 13:56:14 > top of Java-index,Core,Core APIs...
# 4

the real issue is of where to put them?

probably you will say in the Job interface under the struct class... the problem that i will have is that

a) struct is "implemented" in Java as a class on each one ..and it would not have the set and get functions in it..

b)i am not extending the Job interface because i implement the service interface on the servant and a Callback interface on the client (servant)..

probably it is a good idea to extend class Job and implement there the functions.. but again the get and set will be in another class.. ohh i am confused and it seems to be very easy...

i searched and read so many pdfs and sites about idl...and i could found not even one which says how -semantically how- we split things in modules/interfaces/ attributes and so on..because if you try to mix sth thing you will have problem with the namespace...

panosjavaa at 2007-7-15 13:56:14 > top of Java-index,Core,Core APIs...
# 5
IDL is for defining inter-ORB methods and the types that are communicated over them. It's not the place to define data, and it's not the place to define datatypes that aren't used between the client and the server.
ejpa at 2007-7-15 13:56:14 > top of Java-index,Core,Core APIs...
# 6

hmm that was intresting!

what happens with the data, e.g. the interface Job for me, who has some data and functions for setting and getting them, but are not actually an interface that is going to be used by extension ..from the servant of the server or of the servant of the client... should we put it in a different class file or should we put it in the IDL... logically there is no reason of putting it in the IDL ...semantically these are data that are transferred from the client to the server...

panosjavaa at 2007-7-15 13:56:14 > top of Java-index,Core,Core APIs...