Example
The Java server:
Interface : InnerClasses\Greetings.java
Implementation: InnerClasses\GreetingsImpl.java
public class GreetingsImpl extends PortableRemoteObject implements Greetings{
public Info hello( Info oInfo) throws RemoteException {
// ...
Info oRet = new Info();
// ...
return oRet;
}
}
Serializable with inner class: InnerClasses\Info.java
public class Info implements Serializable {
// ...
private Notes m_oNotes;
public Info()
{
m_oNotes = new Notes();
}
public class Notes implements Serializable
{
public String m_strPrivateNote;
public String m_strBusinessNote;
}
// ...
}
The .Net client:
Implementation: ClientImpl.cs
IDL-File : InnerClasses.idl
Generated : InnerClasses.cs
In .Net the Java Serializable is mapped in two separate classes: Info and Info__Notes.
Like for every serializable an implementation has to be provided (see also the
Objects by value example for the mapping of Java Serializables).
Implementations of Serializables: InfoImpl.cs
Info__NotesImpl.cs
Usage:
// ...
InnerClasses.InfoImpl oInfo = new InnerClasses.InfoImpl();
oInfo.name = "Ted";
oInfo.message = "just a sample";
oInfo.businessNote = "Inner class demo";
oInfo.privateNote = "this value is from an inner class";
InnerClasses.Info oRetInfo = oGreetings.hello( oInfo);
a_oFrmClt.writeLog("\nInfo returned:\n");
a_oFrmClt.writeLog(oRetInfo.name);
a_oFrmClt.writeLog(oRetInfo.message);
a_oFrmClt.writeLog(oRetInfo.businessNote);
a_oFrmClt.writeLog(oRetInfo.privateNote);
// ...
Note, that we have to add several items to the list of assemblies to be searched for
by the .Net Reflection. This list is set using the "-AddAssembly" parameter during ORB
initialization:
private static string[] m_strORBInit = {"-ORBEndpoint iiop://localhost:8545/portspan=100",
"-ORBInitRef NameService=corbaloc:iiop:1.2@localhost:1050/NameService",
"-ORBDebug",
"-AddAssembly DotNetClient.exe,JavaBuiltinTypesCF.dll,MinCorCF.dll" };