View Single Post
  #1 (permalink)  
Old 02-28-2004
damingyipai damingyipai is offline
Registered User
 
 
Join Date: Jan 2004
Posts: 59
problem when call another service at start function.

Maybe it's not a bug, but it's little discommodiousness.



I'll work with multiple service on a single IceBox server.

I want to call another service in start function(that is

IceBox::Service member), it must initialize it-self in

start function. But Ice can not specify the Services

startup order, so be desirous to call another service in

start function maybe fail, because that service maybe

not loaded by IceBox. It's a little bit discommodiousness.

maybe i can do it by another way, Can you help me?

thanks a lot.


sample code:

void
MyService1I::start(
const ::std::string& name,
const ::Ice::CommunicatorPtr& communicator,
const ::Ice::StringSeq& args)
{
m_adapter = communicator->createObjectAdapter(name);

// !!!! this call maybe fail. !!!
::jf::accounts::Connection conn = getSystemConn();

m_fs = new FilesysI( conn );
m_adapter->add( m_fs, Ice::stringToIdentity( gProxyName ) );


m_adapter->activate();
}

::jf::accounts::ConnectionPrx MyServiceI::getSystemConn(void) const
{
if ( m_system_conn ) {
return m_system_conn;
}

Ice::PropertiesPtr properties = getFilesys()->getProperties();
const std::string proxyProperty = jf::accounts::gProxyName + ".Proxy";
std::string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
{
throw jf::GenericError e;
}
Ice::ObjectPrx base = getFilesys()->getCommunicator()->stringToProxy(proxy);
::jf::accounts::AccountsPrx twoway = ::jf::accounts::AccountsPrx::checkedCast(base->ice_twoway()->ice_timeout(-1)->ice_secure(false));
m_system_conn = twoway->findConnection( jf::accounts::getSystemConnID() );
return m_system_conn;
}
Reply With Quote