I am a beginer of the corba,and met some
problem.
FAQ has memtioned that
PortableServer_PERSISTENT
policy can be used to generate a persistent object reference. but there are no example or specification to explain the
usage.
I write the flowing code,but it doesnt work.
The following warning output:
none-default policies aren't implimented yet.
Could anyone tell me how to
realize the persisten object refernce? Thanks alot.
PortableServer_ObjectId objid = {0,
sizeof("myEchoString"), "myEchoString"};
PortableServer_POA poa; PortableServer_POA root_poa; CORBA_Environment ev;
char *retval; CORBA_ORB orb; FILE * ofp; CORBA_PolicyList policies; PortableServer_POAManager root_poa_manager; signal(SIGINT, exit);
signal(SIGTERM, exit); CORBA_exception_init(&ev); orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev); POA_Echo__init(&poa_echo_servant, &ev); root_poa =
(PortableServer_POA)CORBA_ORB_resolve_initial_references(orb, "RootPOA",
&ev);
root_poa_manager = PortableServer_POA__get_the_POAManager(root_poa,&ev); root_poa_manager =
PortableServer_POA__get_the_POAManager(root_poa,&ev);
PortableServer_POAManager_activate(root_poa_manager, &ev); policies._length = 1; policies._buffer = g_new0(CORBA_Policy, 1); policies._buffer[0]=(CORBA_Policy)PortableServer_POA_create_lifespan_policy( root_poa,PortableServer_PERSISTENT,&ev); PortableServer_POA_create_POA (root_poa, "new poa", root_poa_manager, &policies, &ev); poa=PortableServer_POA_find_POA(root_poa,"new poa",0,&ev); PortableServer_POA_activate_object_with_id(poa, &objid, &poa_echo_servant, &ev); echo_client = PortableServer_POA_servant_to_reference(poa, &poa_echo_servant, &ev); if (!echo_client) { printf("Cannot get objref\n"); return 1; } retval = CORBA_ORB_object_to_string(orb,
echo_client, &ev);
ofp = fopen("echo.ior","w");
fprintf(ofp,"%s",
retval);
fclose(ofp); ...... |