Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / CORBA / June 2005

Tip: Looking for answers? Try searching our database.

implement IDL-struct as return value of method in java

Thread view: 
Tina - 19 Jun 2005 14:50 GMT
Hi,

how could I implement IDL-struct as return value of method in java,
please:

///IDL

struct info{
long ID
string notice
}

interface XX{
Info delete(in DD, out KK);
}

thanks
Br,
Tina
Piet van Oostrum - 19 Jun 2005 20:58 GMT
>>>>> "Tina" <nahal_ir@yahoo.de> (T) wrote:

>T> Hi,
>T> how could I implement IDL-struct as return value of method in java,
>T> please:

>T> ///IDL

>T> struct info{
>T>  long ID
>T>  string notice
>T> }

>T> interface XX{
>T> Info delete(in DD, out KK);
>T> }

(By the way, use either info or Info, but not both.)

This kind of thing is described in the Java language binding document,
http://www.omg.org/technology/documents/formal/omg_idl_to_java_language_mapping.htm

   An IDL struct is mapped to a final Java class with the same name and
   which provides instance variables for the fields in IDL member
   ordering, a constructor for all values, and which implements IDLEntity.
   A null constructor is also provided so that the fields can be filled in
   later. All string fields in the struct are initialized to "".

So in your example:

final public class info
   implements org.omg.CORBA.portable.IDLEntity {
   // instance variables
   public int ID; /* long maps to int */
   public String notice = "";
   // constructors
   public info() {}
   public StructType(int f1, String f2) {...}
}

For the out parameter you get a class infoHolder
Signature

Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: piet@vanoostrum.org

Tina - 20 Jun 2005 10:22 GMT
Hi,
thank you very much for your answer.
I try to implement this in server- and client-sided. That would be
great, if you ckeck that code, whether that is correct.

in server sided :

public info delete(int DD, KKHolder obj) {

     obj.value = this.KK;
     return new info(0, "successfully.");
}

------------------
in client-sided:
KKHolder obj = new KKHolder();
Info inf = acc.delete(11,obj);

thanks
Br,
tina
Piet van Oostrum - 20 Jun 2005 11:46 GMT
>>>>> "Tina" <nahal_ir@yahoo.de> (T) wrote:

>T> Hi,
>T> thank you very much for your answer.
>T> I try to implement this in server- and client-sided. That would be
>T> great, if you ckeck that code, whether that is correct.

>T> in server sided :

>T> public info delete(int DD, KKHolder obj) {

I suppose you are going to use DD here also.

>T>       obj.value = this.KK;
>T>       return new info(0, "successfully.");
>T> }

>T> ------------------
>T> in client-sided:
>T> KKHolder obj = new KKHolder();
>T> Info inf = acc.delete(11,obj);

That should be info instead of Info. And I suppose you want to use
obj.value also later on.
For the rest it looks Ok to me.
Signature

Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: piet@vanoostrum.org

Tina - 20 Jun 2005 13:33 GMT


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.