),
null)
}
);
DynStruct dyn_struct =
(DynStruct)dynFactory.create_dyn_any_from_type_code(
struct_tc );
// Create a list of name value pairs that holds the struct members.
// This struct has two members, so we have 2 array elements
// the first struct member is a string,
// the member name is "first"
NameValuePair[] nvp_seq = new NameValuePair[2];
Any first_member_any = orb.create_any();
first_member_any.insert_string("first");
nvp_seq[0] = new NameValuePair("first", first_member_any );
/*
the second member is a recursive sequence, ie. the element
type of the sequence is that of the enclosing struct, the
member name is "second". We'll leave that sequence empty,
but we have to provide an initialized any for the empty
sequence, so we create a DynAny that initializes an any
as an empty sequence
*/
DynSequence second_member =
(DynSequence)dynFactory.create_dyn_any_from_type_code(
struct_tc.member_type(1) );
nvp_seq[1] =
new NameValuePair("second", second_member.to_any() );
// insert the nvp list into the DynStruct
dyn_struct.set_members( nvp_seq );
System.out.println("[Client]: Passing a struct..." +
s.generic( dyn_struct.to_any() ) );
// test the primitive get/set operations for DynStruct
dyn_struct.seek(0);
dyn_struct.insert_string( "newly inserted" );
System.out.println("[Client]: Passing the struct again..." +
s.generic( dyn_struct.to_any() ) );
dyn_struct.destroy();
second_member.destroy();
/* union */
// setting up TypeCodes gets even more complicated,