How to check if object already activated? - Object

This is a discussion on How to check if object already activated? - Object ; I have a factory that creates objects, but it gives an error if objects with the same id are created. Is there a way to check if an object with a particular id is already activated so I won't activate ...

+ Reply to Thread
Results 1 to 4 of 4

How to check if object already activated?

  1. Default How to check if object already activated?

    I have a factory that creates objects, but it gives an error if
    objects with the same id are created.

    Is there a way to check if an object with a particular id is
    already activated so I won't activate the same object twice?

    My current factory code :

    SessImpl *si = new SessImpl(poa_m, objectid, _this());
    PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId(objectid);
    // is there a way to check if the id above already is activated before
    // I call the code below??
    poa_m->activate_object_with_id(id,si);
    CORBA::Object_var obj = poa_m->id_to_reference(id);
    sessref = Mod::Sess::_narrow(obj);

  2. Default Re: How to check if object already activated?

    brightoceanlight@hotmail.com (Gil) writes:

    > I have a factory that creates objects, but it gives an error if
    > objects with the same id are created.
    >
    > Is there a way to check if an object with a particular id is
    > already activated so I won't activate the same object twice?
    >
    > My current factory code :
    >
    > SessImpl *si = new SessImpl(poa_m, objectid, _this());
    > PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId(objectid);
    > // is there a way to check if the id above already is activated before
    > // I call the code below??


    You could use
    poa_m->id_to_reference(id);
    or
    poa_m->id_to_servant(id);
    If it throws ObjectNotActive, it's not active.

    > poa_m->activate_object_with_id(id,si);
    > CORBA::Object_var obj = poa_m->id_to_reference(id);
    > sessref = Mod::Sess::_narrow(obj);


    Best regards, Matthias

  3. Default Re: How to check if object already activated?

    Matthias Riese <Matthias.Riese@rieseIT.de> wrote in message news:<c1sclk$2st$1@news1.ewetel.de>...
    > brightoceanlight@hotmail.com (Gil) writes:
    >
    > > I have a factory that creates objects, but it gives an error if
    > > objects with the same id are created.
    > >
    > > Is there a way to check if an object with a particular id is
    > > already activated so I won't activate the same object twice?
    > >
    > > My current factory code :
    > >
    > > SessImpl *si = new SessImpl(poa_m, objectid, _this());
    > > PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId(objectid);
    > > // is there a way to check if the id above already is activated before
    > > // I call the code below??

    >
    > You could use
    > poa_m->id_to_reference(id);
    > or
    > poa_m->id_to_servant(id);
    > If it throws ObjectNotActive, it's not active.
    >
    > > poa_m->activate_object_with_id(id,si);
    > > CORBA::Object_var obj = poa_m->id_to_reference(id);
    > > sessref = Mod::Sess::_narrow(obj);

    >
    > Best regards, Matthias


    Thanks Matthias for the response!

    So basically, I need to call poa_m->id_to_reference(id) before
    poa_m->activate_object_with_id(id,si), and activate the object
    in the catch block?

  4. Default Re: How to check if object already activated?

    Matthias Riese <Matthias.Riese@rieseIT.de> wrote in message news:<c1sclk$2st$1@news1.ewetel.de>...
    > brightoceanlight@hotmail.com (Gil) writes:
    >
    > > I have a factory that creates objects, but it gives an error if
    > > objects with the same id are created.
    > >
    > > Is there a way to check if an object with a particular id is
    > > already activated so I won't activate the same object twice?
    > >
    > > My current factory code :
    > >
    > > SessImpl *si = new SessImpl(poa_m, objectid, _this());
    > > PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId(objectid);
    > > // is there a way to check if the id above already is activated before
    > > // I call the code below??

    >
    > You could use
    > poa_m->id_to_reference(id);
    > or
    > poa_m->id_to_servant(id);
    > If it throws ObjectNotActive, it's not active.
    >
    > > poa_m->activate_object_with_id(id,si);
    > > CORBA::Object_var obj = poa_m->id_to_reference(id);
    > > sessref = Mod::Sess::_narrow(obj);

    >
    > Best regards, Matthias


    Thanks Matthias for the response!

    So basically, I need to call poa_m->id_to_reference(id) before
    poa_m->activate_object_with_id(id,si), and activate the object
    in the catch block?

+ Reply to Thread

Similar Threads

  1. XmlSerializer fails on object loaded from an activated assembly
    By Application Development in forum XML SOAP
    Replies: 2
    Last Post: 04-09-2007, 02:48 PM
  2. how to maintain a client activated object in COM+ web services
    By Application Development in forum DOTNET
    Replies: 0
    Last Post: 06-21-2005, 10:54 AM
  3. how to maintain a client activated object in COM+ web services
    By Application Development in forum basic.visual
    Replies: 0
    Last Post: 06-21-2005, 10:40 AM
  4. How to create a client activated remoting object in an MFC Client
    By Application Development in forum DOTNET
    Replies: 2
    Last Post: 01-29-2004, 11:55 AM
  5. COM+ Interop, activated object reference not decrementing
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 10-28-2003, 03:47 AM