Michael Shearer
2006-06-13 20:25:12 UTC
Hi!
I'm trying to figure out a nice and clean way of passing arguments to
the preinvoke primitive when using a CORBA servant locator. I have an
object that needs two parameters in the constructor when creating the
instance. Obviously I could add a primitive to initialize this data
separately but ideally I'd like some way of passing the 2 arguments to
the preinvoke. What I'm doing right now is basically setting 2 member
variables in the servant locator which are used in the preinvoke. These
2 member variables are currently locked with a mutex as I'm not sure if
the POA ensures that no other object references will be requested before
the previous one has been dispatched. Is that the best I can do or am I
missing something? Here's what it looks like in a nutshell:
Class Line :
public POA_LineInterface,
public PortableServer::RefCountServantBase,
{
public:
Line(string mac, string userAgent);
virtual ~Line();
private:
Line();
};
class LineMgr :
public POA_PortableServer::ServantLocator
{
public:
// CORBA servant locator
PortableServer::Servant
preinvoke(const PortableServer::ObjectId& oid,
PortableServer::POA_ptr adapter, const char* operation,
PortableServer::ServantLocator::Cookie& the_cookie)
{
lines[macM] = new Line(macM, userAgentM);
return lines[macM];
}
void
postinvoke(const PortableServer::ObjectId& oid,
PortableServer::POA_ptr adapter, const char* operation,
PortableServer::ServantLocator::Cookie the_cookie,
PortableServer::Servant the_servant)
{
the_servant->_remove_ref();
}
LinePtr getLine(string mac, string userAgent)
{
mutex.lock();
macM = mac;
userAgentM = userAgent;
CORBA::Object_var obj =
root_poaM->create_reference("IDL:LineInterface:1.0");
Mutex.unlock();
return lines[mac];
}
private:
string macM;
string userAgentM;
map<string, LinePtr> lines;
};
Note: LinePtr is a reference counting class.
I would appreciate any help!
Thanks,
Mike
Michael Shearer
New Product Development
Aastra Telecom US, CVX Division
8 Federal Street
Billerica, MA, USA, 01821-3570
* Phone (978) 436-4248
* Fax (978) 436-4233
* Internet Mail ***@aastra.com
* Web www.aastra.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20060613/85c846df/attachment.htm
I'm trying to figure out a nice and clean way of passing arguments to
the preinvoke primitive when using a CORBA servant locator. I have an
object that needs two parameters in the constructor when creating the
instance. Obviously I could add a primitive to initialize this data
separately but ideally I'd like some way of passing the 2 arguments to
the preinvoke. What I'm doing right now is basically setting 2 member
variables in the servant locator which are used in the preinvoke. These
2 member variables are currently locked with a mutex as I'm not sure if
the POA ensures that no other object references will be requested before
the previous one has been dispatched. Is that the best I can do or am I
missing something? Here's what it looks like in a nutshell:
Class Line :
public POA_LineInterface,
public PortableServer::RefCountServantBase,
{
public:
Line(string mac, string userAgent);
virtual ~Line();
private:
Line();
};
class LineMgr :
public POA_PortableServer::ServantLocator
{
public:
// CORBA servant locator
PortableServer::Servant
preinvoke(const PortableServer::ObjectId& oid,
PortableServer::POA_ptr adapter, const char* operation,
PortableServer::ServantLocator::Cookie& the_cookie)
{
lines[macM] = new Line(macM, userAgentM);
return lines[macM];
}
void
postinvoke(const PortableServer::ObjectId& oid,
PortableServer::POA_ptr adapter, const char* operation,
PortableServer::ServantLocator::Cookie the_cookie,
PortableServer::Servant the_servant)
{
the_servant->_remove_ref();
}
LinePtr getLine(string mac, string userAgent)
{
mutex.lock();
macM = mac;
userAgentM = userAgent;
CORBA::Object_var obj =
root_poaM->create_reference("IDL:LineInterface:1.0");
Mutex.unlock();
return lines[mac];
}
private:
string macM;
string userAgentM;
map<string, LinePtr> lines;
};
Note: LinePtr is a reference counting class.
I would appreciate any help!
Thanks,
Mike
Michael Shearer
New Product Development
Aastra Telecom US, CVX Division
8 Federal Street
Billerica, MA, USA, 01821-3570
* Phone (978) 436-4248
* Fax (978) 436-4233
* Internet Mail ***@aastra.com
* Web www.aastra.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20060613/85c846df/attachment.htm