[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&#26032;&#32048;&#26126;&#39636;></FONT></FONT><FONT=20
face=3D"Times New Roman" size=3D4>Hi Diego.</FONT></FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</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&nbsp;these policies, you must create your own, it works; =
for=20
examples</FONT></FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT size=3D4>{</FONT></DIV>
<DIV><FONT size=3D4>&nbsp; // code for init ORB&nbsp;is not =
here</FONT></DIV>
<DIV><FONT size=3D4>&nbsp; </FONT></DIV>
<DIV><FONT=20
size=3D4>&nbsp;&nbsp;PortableServer::POA_var&nbsp;&nbsp;rootPoa&nbsp;&nb=
sp;;</FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT size=3D4>&nbsp;&nbsp;// RootPOA, resolve_init is my&nbsp;own =
template,=20
you know&nbsp;what is means</FONT></DIV>
<DIV><FONT size=3D4>&nbsp; // I copied&nbsp;this template from=20
H&amp;V&nbsp;Advanced CORBA Programming with C++<BR>&nbsp;&nbsp;rootPoa =
=3D=20
resolve_init&lt;PortableServer::POA&gt;(orb.in(), =
"RootPOA");</FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT size=3D4>&nbsp;&nbsp;// POA=20
policies<BR>&nbsp;&nbsp;PortableServer::IdAssignmentPolicy_var&nbsp;idPo=
licy;<BR>&nbsp;&nbsp;idPolicy=20
=3D rootPoa-&gt;create_id_assignment_policy( PortableServer::USER_ID=20
);</FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT=20
size=3D4>&nbsp;&nbsp;PortableServer::LifespanPolicy_var&nbsp;&nbsp;lifeP=
olicy;<BR>&nbsp;&nbsp;lifePolicy=20
=3D rootPoa-&gt;create_lifespan_policy( PortableServer::PERSISTENT =
);</FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT=20
size=3D4>&nbsp;&nbsp;CORBA::PolicyList&nbsp;&nbsp;policyList;<BR>&nbsp;&=
nbsp;policyList.length(2);<BR>&nbsp;&nbsp;policyList[0]=20
=3D=20
PortableServer::IdAssignmentPolicy::_duplicate(idPolicy.in());<BR>&nbsp;=
&nbsp;policyList[1]=20
=3D =
PortableServer::LifespanPolicy::_duplicate(lifePolicy.in());</FONT></DIV=
>
<DIV><FONT size=3D4><BR>&nbsp;&nbsp;// Create my own=20
POA<BR>&nbsp;&nbsp;PortableServer::POA_var&nbsp;&nbsp;poa =3D=20
<BR>&nbsp;&nbsp;rootPoa-&gt;create_POA( "EchoPOA",=20
PortableServer::POAManager::_nil(), policyList );</FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT size=3D4>&nbsp;&nbsp;Echo_i*&nbsp;&nbsp;pServant =3D new=20
Echo_i;<BR>&nbsp;&nbsp;CORBA::Object_var&nbsp;theObjRef;</FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT size=3D4>&nbsp;&nbsp;PortableServer::ObjectId_var oid =3D=20
PortableServer::string_to_ObjectId( "Echo" );<BR>&nbsp;&nbsp;theObjRef =
=3D=20
poa-&gt;create_reference_with_id( oid, Echo::_PD_repoId=20
);<BR>&nbsp;&nbsp;poa-&gt;activate_object_with_id( oid, pServant =
);</FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT size=3D4>&nbsp; // other codes</FONT></DIV>
<DIV><FONT size=3D4>&nbsp; .......</FONT></DIV>
<DIV><FONT size=3D4>}</FONT></DIV>
<DIV><FONT size=3D4></FONT>&nbsp;</DIV>
<DIV><FONT size=3D4>Best Regards,</FONT></DIV>
<DIV><FONT size=3D4>Edward</FONT></DIV></BODY></HTML>

------=_NextPart_000_0018_01C27687.B6752BF0--