[omniORB] Default servant and SYSTEM_ID

Ben Cullen Ben.Cullen at trema.com
Fri Jun 6 17:28:39 BST 2003


Many thanks Kendall for the reply and information.

I was trying to get the system generated OID as a string so that I could
easily print it, and also use it in a simple lookup dictionary key, all
using the convenient ObjectId_to_string().

I found an interesting NG article on the subject, which discusses the
fact that the CORBA spec is rather broken in this area:
http://groups.google.fr/groups?q=objectid+broken+group:comp.object.corba
+group:comp.object.corba&hl=fr&lr=&ie=UTF-8&group=comp.object.corba&selm
=P4HZ8.464676%24o66.1244715%40news-server.bigpond.net.au&rnum=2

Ben

-----Original Message-----
From: baileyk at schneider.com [mailto:baileyk at schneider.com] 
Sent: 05 June 2003 22:19
To: Ben Cullen
Cc: omniorb-list at omniorb-support.com
Subject: Re: [omniORB] Default servant and SYSTEM_ID



I haven't seen anyone answer this, so I'll take a guess.

Not every object ID can be represented as a string (a null terminated
sequence of chars), since the object ID is a sequence<octet>.  Embedded
zero bytes are allowed in an object ID, and I think omniORB is
complaining that this makes conversion to string impossible.  The reason
the system generated ID has zero bytes is likely because its probably
generated via a
numerical counter.   The first object reference generated has a four
byte
object ID with all bytes zero because the counter is starting at zero.
The next one will have three zero bytes and a one.

I think the only way to guarantee you can convert an ID to a string is
to supply the ID yourself, as you've already found.  Why do you want the
system generated IDs as strings?

Kendall




 

                      "Ben Cullen"

                      <Ben.Cullen at trema.com>               To:
<omniorb-list at omniorb-support.com>                                  
                      Sent by:                             cc:

                      omniorb-list-bounces at omniorb-        Fax to:

                      support.com                          Subject:
[omniORB] Default servant and SYSTEM_ID                             
 

 

                      06/04/2003 10:45 AM

 

 





Hello All

I am trying to implement a default servant, which relies on the POA to
generate the object IDs. I therefore create the default servant's POA
with the following policies:

CORBA::PolicyList policy_list;
policy_list.length(7);
policy_list[0] = poa ->
create_id_assignment_policy(PortableServer::SYSTEM_ID);
policy_list[1] = poa ->
create_lifespan_policy(PortableServer::TRANSIENT);
policy_list[2] = poa ->
create_servant_retention_policy(PortableServer::NON_RETAIN);
policy_list[3] = poa ->
create_id_uniqueness_policy(PortableServer::MULTIPLE_ID);
policy_list[4] = poa ->
create_request_processing_policy(PortableServer::USE_DEFAULT_SERVANT);
policy_list[5] = poa ->
create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION
);
policy_list[6] = poa ->
create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);

I then create my object reference:

CORBA::Object_var obj = _poa -> create_reference(RepositoryId_string);

And get the system generated OID from the reference:

PortableServer::ObjectId_var oid = _poa -> reference_to_id(obj);

The returned OID has length 4, however the 4 octets appear to be blank.
When I then call ObjectId_to_string(oid), I get the following exception
thrown "omniORB: throw BAD_PARAM from portableserver.cc:394
(NO,BAD_PARAM_InvalidObjectId)".

Am I doing something wrong? Are SYSTEM_ID together with
USE_DEFAULT_SERVANT policies permitted? Any help would be much
appreciated.

Note, I have managed to implement successfully using the policy:

policy_list[0] = poa ->
create_id_assignment_policy(PortableServer::SYSTEM_ID);

And generate my own OIDs by using:

PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId(my_oid_string);
CORBA::Object_var obj = _poa -> create_reference_with_id(oid,
RepositoryId_string);

Thanks in advance, Ben.

_______________________________________________
omniORB-list mailing list
omniORB-list at omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list








More information about the omniORB-list mailing list