[omniORB] Persistent Reference not working...
EDWARD_LIN
edward_lin@iwin.com.tw
Fri Oct 18 02:23:01 2002
This is a multi-part message in MIME format.
------=_NextPart_000_0018_01C27687.B6752BF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Diego.
=20
Except specifying ORB end point, I always use POA PERSISTENT Lifespan
policy and USER_ID IdAssignment policy to create persistent object
reference. Since default POA has not these policies, you must create
your own, it works; for examples
=20
{
// code for init ORB is not here
=20
PortableServer::POA_var rootPoa ;
=20
// RootPOA, resolve_init is my own template, you know what is means
// I copied this template from H&V Advanced CORBA Programming with =
C++
rootPoa =3D resolve_init<PortableServer::POA>(orb.in(), "RootPOA");
=20
// POA policies
PortableServer::IdAssignmentPolicy_var idPolicy;
idPolicy =3D rootPoa->create_id_assignment_policy(
PortableServer::USER_ID );
=20
PortableServer::LifespanPolicy_var lifePolicy;
lifePolicy =3D rootPoa->create_lifespan_policy(
PortableServer::PERSISTENT );
=20
CORBA::PolicyList policyList;
policyList.length(2);
policyList[0] =3D
PortableServer::IdAssignmentPolicy::_duplicate(idPolicy.in());
policyList[1] =3D
PortableServer::LifespanPolicy::_duplicate(lifePolicy.in());
// Create my own POA
PortableServer::POA_var poa =3D=20
rootPoa->create_POA( "EchoPOA", PortableServer::POAManager::_nil(),
policyList );
=20
Echo_i* pServant =3D new Echo_i;
CORBA::Object_var theObjRef;
=20
PortableServer::ObjectId_var oid =3D =
PortableServer::string_to_ObjectId(
"Echo" );
theObjRef =3D poa->create_reference_with_id( oid, Echo::_PD_repoId );
poa->activate_object_with_id( oid, pServant );
=20
// other codes
.......
}
=20
Best Regards,
Edward
------=_NextPart_000_0018_01C27687.B6752BF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"MSHTML 5.50.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2><FONT size=3D2><FONT =
face=3D新細明體></FONT></FONT><FONT=20
face=3D"Times New Roman" size=3D4>Hi Diego.</FONT></FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D4>Except=20
specifying ORB end point, I always use POA PERSISTENT Lifespan policy =
and=20
USER_ID IdAssignment policy to create persistent object reference. =
Since default=20
POA has not these policies, you must create your own, it works; =
for=20
examples</FONT></FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4>{</FONT></DIV>
<DIV><FONT size=3D4> // code for init ORB is not =
here</FONT></DIV>
<DIV><FONT size=3D4> </FONT></DIV>
<DIV><FONT=20
size=3D4> PortableServer::POA_var rootPoa &nb=
sp;;</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> // RootPOA, resolve_init is my own =
template,=20
you know what is means</FONT></DIV>
<DIV><FONT size=3D4> // I copied this template from=20
H&V Advanced CORBA Programming with C++<BR> rootPoa =
=3D=20
resolve_init<PortableServer::POA>(orb.in(), =
"RootPOA");</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> // POA=20
policies<BR> PortableServer::IdAssignmentPolicy_var idPo=
licy;<BR> idPolicy=20
=3D rootPoa->create_id_assignment_policy( PortableServer::USER_ID=20
);</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT=20
size=3D4> PortableServer::LifespanPolicy_var lifeP=
olicy;<BR> lifePolicy=20
=3D rootPoa->create_lifespan_policy( PortableServer::PERSISTENT =
);</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT=20
size=3D4> CORBA::PolicyList policyList;<BR> &=
nbsp;policyList.length(2);<BR> policyList[0]=20
=3D=20
PortableServer::IdAssignmentPolicy::_duplicate(idPolicy.in());<BR> =
policyList[1]=20
=3D =
PortableServer::LifespanPolicy::_duplicate(lifePolicy.in());</FONT></DIV=
>
<DIV><FONT size=3D4><BR> // Create my own=20
POA<BR> PortableServer::POA_var poa =3D=20
<BR> rootPoa->create_POA( "EchoPOA",=20
PortableServer::POAManager::_nil(), policyList );</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> Echo_i* pServant =3D new=20
Echo_i;<BR> CORBA::Object_var theObjRef;</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> PortableServer::ObjectId_var oid =3D=20
PortableServer::string_to_ObjectId( "Echo" );<BR> theObjRef =
=3D=20
poa->create_reference_with_id( oid, Echo::_PD_repoId=20
);<BR> poa->activate_object_with_id( oid, pServant =
);</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4> // other codes</FONT></DIV>
<DIV><FONT size=3D4> .......</FONT></DIV>
<DIV><FONT size=3D4>}</FONT></DIV>
<DIV><FONT size=3D4></FONT> </DIV>
<DIV><FONT size=3D4>Best Regards,</FONT></DIV>
<DIV><FONT size=3D4>Edward</FONT></DIV></BODY></HTML>
------=_NextPart_000_0018_01C27687.B6752BF0--