summaryrefslogtreecommitdiff
path: root/cpp/src/IceBox
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceBox')
-rw-r--r--cpp/src/IceBox/Admin.cpp3
-rw-r--r--cpp/src/IceBox/Makefile.mak4
-rw-r--r--cpp/src/IceBox/Service.cpp3
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp301
-rw-r--r--cpp/src/IceBox/ServiceManagerI.h3
5 files changed, 160 insertions, 154 deletions
diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp
index 2a77a8629ba..6cd3076b995 100644
--- a/cpp/src/IceBox/Admin.cpp
+++ b/cpp/src/IceBox/Admin.cpp
@@ -58,6 +58,9 @@ Client::run(int argc, char* argv[])
vector<string> commands;
try
{
+#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600)
+ IceUtil::DummyBCC dummy;
+#endif
commands = opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
diff --git a/cpp/src/IceBox/Makefile.mak b/cpp/src/IceBox/Makefile.mak
index d5f8061dfeb..54251f3d445 100644
--- a/cpp/src/IceBox/Makefile.mak
+++ b/cpp/src/IceBox/Makefile.mak
@@ -48,7 +48,7 @@ SPDBFLAGS = /pdb:$(SERVER:.exe=.pdb)
APDBFLAGS = /pdb:$(ADMIN:.exe=.pdb)
!endif
-!if "$(CPP_COMPILER)" == "BCC2007"
+!if "$(BCPLUSPLUS)" == "yes"
RES_FILE = ,, IceBox.res
SRES_FILE = ,, IceBoxExe.res
ARES_FILE = ,, IceBoxAdmin.res
@@ -92,7 +92,7 @@ install:: all
copy $(ADMIN) $(install_bindir)
-!if "$(CPP_COMPILER)" == "BCC2007" && "$(OPTIMIZE)" != "yes"
+!if "$(BCPLUSPLUS)" == "yes" && "$(OPTIMIZE)" != "yes"
install:: all
copy $(DLLNAME:.dll=.tds) $(install_bindir)
diff --git a/cpp/src/IceBox/Service.cpp b/cpp/src/IceBox/Service.cpp
index 2cfb70ce1ea..c98d593636d 100644
--- a/cpp/src/IceBox/Service.cpp
+++ b/cpp/src/IceBox/Service.cpp
@@ -72,6 +72,9 @@ IceBox::IceBoxService::start(int argc, char* argv[])
try
{
+#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600)
+ IceUtil::DummyBCC dummy;
+#endif
args = opts.parse(args);
}
catch(const IceUtilInternal::BadOptException& e)
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index 0cb8aba1c9d..e80a49474e6 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -76,6 +76,50 @@ private:
const PropertiesPtr _properties;
};
+struct StartServiceInfo
+{
+ StartServiceInfo(const std::string& service, const std::string& value, const Ice::StringSeq& serverArgs)
+ {
+ name = service;
+
+ //
+ // Separate the entry point from the arguments.
+ //
+ string::size_type pos = value.find_first_of(" \t\n");
+ if(pos == string::npos)
+ {
+ entryPoint = value;
+ }
+ else
+ {
+ entryPoint = value.substr(0, pos);
+ try
+ {
+ args = IceUtilInternal::Options::split(value.substr(pos + 1));
+ }
+ catch(const IceUtilInternal::BadOptException& ex)
+ {
+ FailureException e(__FILE__, __LINE__);
+ e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.reason;
+ throw e;
+ }
+ }
+
+ for(Ice::StringSeq::const_iterator p = serverArgs.begin(); p != serverArgs.end(); ++p)
+ {
+ if(p->find("--" + name + ".") == 0)
+ {
+ args.push_back(*p);
+ }
+ }
+ }
+
+ string name;
+ string entryPoint;
+ Ice::StringSeq args;
+};
+
+
}
IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) :
@@ -138,7 +182,7 @@ IceBox::ServiceManagerI::startService(const string& name, const Current&)
bool started = false;
try
{
- info.service->start(name, info.communicator == 0 ? _communicator : info.communicator, info.args);
+ info.service->start(name, info.communicator == 0 ? _sharedCommunicator : info.communicator, info.args);
started = true;
}
catch(const Ice::Exception& ex)
@@ -343,19 +387,19 @@ IceBox::ServiceManagerI::start()
}
//
- // Load and start the services defined in the property set
- // with the prefix "IceBox.Service.". These properties should
- // have the following format:
+ // Parse the property set with the prefix "IceBox.Service.". These
+ // properties should have the following format:
//
// IceBox.Service.Foo=entry_point [args]
//
- // We load the services specified in IceBox.LoadOrder first,
- // then load any remaining services.
+ // We parse the service properties specified in IceBox.LoadOrder
+ // first, then the ones from remaining services.
//
const string prefix = "IceBox.Service.";
PropertyDict services = properties->getPropertiesForPrefix(prefix);
PropertyDict::iterator p;
StringSeq loadOrder = properties->getPropertyAsList("IceBox.LoadOrder");
+ vector<StartServiceInfo> servicesInfo;
for(StringSeq::const_iterator q = loadOrder.begin(); q != loadOrder.end(); ++q)
{
p = services.find(prefix + *q);
@@ -365,13 +409,76 @@ IceBox::ServiceManagerI::start()
ex.reason = "ServiceManager: no service definition for `" + *q + "'";
throw ex;
}
- load(*q, p->second);
+ servicesInfo.push_back(StartServiceInfo(*q, p->second, _argv));
services.erase(p);
}
for(p = services.begin(); p != services.end(); ++p)
{
- string name = p->first.substr(prefix.size());
- load(name, p->second);
+ servicesInfo.push_back(StartServiceInfo(p->first.substr(prefix.size()), p->second, _argv));
+ }
+
+ //
+ // Check if some services are using the shared communicator in which
+ // case we create the shared communicator now with a property set which
+ // is the union of all the service properties (services which are using
+ // the shared communicator).
+ //
+ PropertyDict sharedCommunicatorServices = properties->getPropertiesForPrefix("IceBox.UseSharedCommunicator.");
+ if(!sharedCommunicatorServices.empty())
+ {
+ InitializationData initData;
+ initData.properties = createServiceProperties("SharedCommunicator");
+ for(vector<StartServiceInfo>::iterator q = servicesInfo.begin(); q != servicesInfo.end(); ++q)
+ {
+ if(properties->getPropertyAsInt("IceBox.UseSharedCommunicator." + q->name) <= 0)
+ {
+ continue;
+ }
+
+ //
+ // Load the service properties using the shared communicator properties as
+ // the default properties.
+ //
+ PropertiesPtr svcProperties = createProperties(q->args, initData.properties);
+
+ //
+ // Erase properties from the shared communicator which don't exist in the
+ // service properties (which include the shared communicator properties
+ // overriden by the service properties).
+ //
+ PropertyDict allProps = initData.properties->getPropertiesForPrefix("");
+ for(PropertyDict::iterator p = allProps.begin(); p != allProps.end(); ++p)
+ {
+ if(svcProperties->getProperty(p->first) == "")
+ {
+ initData.properties->setProperty(p->first, "");
+ }
+ }
+
+ //
+ // Add the service properties to the shared communicator properties.
+ //
+ PropertyDict props = svcProperties->getPropertiesForPrefix("");
+ for(PropertyDict::const_iterator r = props.begin(); r != props.end(); ++r)
+ {
+ initData.properties->setProperty(r->first, r->second);
+ }
+
+ //
+ // Parse <service>.* command line options (the Ice command line options
+ // were parsed by the createProperties above)
+ //
+ q->args = initData.properties->parseCommandLineOptions(q->name, q->args);
+ }
+ _sharedCommunicator = initialize(initData);
+ }
+
+ //
+ // Start the services.
+ //
+ for(vector<StartServiceInfo>::const_iterator r = servicesInfo.begin(); r != servicesInfo.end(); ++r)
+ {
+ start(r->name, r->entryPoint, r->args);
}
//
@@ -459,62 +566,14 @@ IceBox::ServiceManagerI::stop()
}
void
-IceBox::ServiceManagerI::load(const string& name, const string& value)
-{
- //
- // Separate the entry point from the arguments.
- //
- string entryPoint;
- StringSeq args;
- string::size_type pos = value.find_first_of(" \t\n");
- if(pos == string::npos)
- {
- entryPoint = value;
- }
- else
- {
- entryPoint = value.substr(0, pos);
- try
- {
- args = IceUtilInternal::Options::split(value.substr(pos + 1));
- }
- catch(const IceUtilInternal::BadOptException& ex)
- {
- FailureException e(__FILE__, __LINE__);
- e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.reason;
- throw e;
- }
- }
- start(name, entryPoint, args);
-}
-
-void
IceBox::ServiceManagerI::start(const string& service, const string& entryPoint, const StringSeq& args)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
- //
- // Create the service property set from the service arguments and
- // the server arguments. The service property set will be used to
- // create a new communicator, or will be added to the shared
- // communicator, depending on the value of the
- // IceBox.UseSharedCommunicator property.
- //
ServiceInfo info;
info.name = service;
info.status = Stopped;
- StringSeq::size_type j;
- for(j = 0; j < args.size(); j++)
- {
- info.args.push_back(args[j]);
- }
- for(j = 0; j < _argv.size(); j++)
- {
- if(_argv[j].find("--" + service + ".") == 0)
- {
- info.args.push_back(_argv[j]);
- }
- }
+ info.args = args;
//
// Load the entry point.
@@ -539,6 +598,9 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
SERVICE_FACTORY factory = (SERVICE_FACTORY)sym;
try
{
+#if defined(__BCPLUSPLUS__) && (__BCPLUSPLUS__ >= 0x0600)
+ IceUtil::DummyBCC dummy;
+#endif
info.service = factory(_communicator);
}
catch(const Exception& ex)
@@ -569,52 +631,40 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
Ice::CommunicatorPtr communicator;
if(_communicator->getProperties()->getPropertyAsInt("IceBox.UseSharedCommunicator." + service) > 0)
{
- if(!_sharedCommunicator)
- {
- Ice::StringSeq dummy = Ice::StringSeq();
- _sharedCommunicator = createCommunicator("", dummy);
- }
+ assert(_sharedCommunicator);
communicator = _sharedCommunicator;
-
- PropertiesPtr properties = _sharedCommunicator->getProperties();
-
- PropertiesPtr svcProperties = createProperties(info.args, properties);
-
+ }
+ else
+ {
//
- // Erase properties from the shared communicator which don't exist in the
- // service properties (which include the shared communicator properties
- // overriden by the service properties).
+ // Create the service properties. We use the communicator properties as the default
+ // properties if IceBox.InheritProperties is set.
//
- PropertyDict allProps = properties->getPropertiesForPrefix("");
- for(PropertyDict::iterator p = allProps.begin(); p != allProps.end(); ++p)
+ InitializationData initData;
+ initData.properties = createServiceProperties(service);
+ if(!info.args.empty())
{
- if(svcProperties->getProperty(p->first) == "")
- {
- properties->setProperty(p->first, "");
- }
- }
+ //
+ // Create the service properties with the given service arguments. This should
+ // read the service config file if it's specified with --Ice.Config.
+ //
+ initData.properties = createProperties(info.args, initData.properties);
- //
- // Add the service properties to the shared communicator properties.
- //
- PropertyDict props = svcProperties->getPropertiesForPrefix("");
- for(PropertyDict::const_iterator q = props.begin(); q != props.end(); ++q)
- {
- properties->setProperty(q->first, q->second);
+ //
+ // Next, parse the service "<service>.*" command line options (the Ice command
+ // line options were parsed by the createProperties above)
+ //
+ info.args = initData.properties->parseCommandLineOptions(service, info.args);
}
//
- // Parse <service>.* command line options (the Ice command line options
- // were parsed by the createProperties above)
+ // Remaining command line options are passed to the communicator. This is
+ // necessary for Ice plug-in properties (e.g.: IceSSL).
//
- info.args = properties->parseCommandLineOptions(service, info.args);
- }
- else
- {
- info.communicator = createCommunicator(service, info.args);
+ info.communicator = initialize(info.args, initData);
communicator = info.communicator;
}
-
+
//
// Start the service.
//
@@ -892,16 +942,11 @@ IceBox::ServiceManagerI::observerRemoved(const ServiceObserverPrx& observer, con
}
}
-Ice::CommunicatorPtr
-IceBox::ServiceManagerI::createCommunicator(const string& service, Ice::StringSeq& args)
+Ice::PropertiesPtr
+IceBox::ServiceManagerI::createServiceProperties(const string& service)
{
- PropertiesPtr communicatorProperties = _communicator->getProperties();
-
- //
- // Create the service properties. We use the communicator properties as the default
- // properties if IceBox.InheritProperties is set.
- //
PropertiesPtr properties;
+ PropertiesPtr communicatorProperties = _communicator->getProperties();
if(communicatorProperties->getPropertyAsInt("IceBox.InheritProperties") > 0)
{
properties = communicatorProperties->clone();
@@ -911,59 +956,15 @@ IceBox::ServiceManagerI::createCommunicator(const string& service, Ice::StringSe
{
properties = createProperties();
}
-
- //
- // Set the default program name for the service properties. By default it's
- // the IceBox program name + "-" + the service name, or just the IceBox
- // program name if we're creating the shared communicator (service == "").
- //
+
string programName = communicatorProperties->getProperty("Ice.ProgramName");
- if(service.empty())
+ if(programName.empty())
{
- if(programName.empty())
- {
- properties->setProperty("Ice.ProgramName", "SharedCommunicator");
- }
- else
- {
- properties->setProperty("Ice.ProgramName", programName + "-SharedCommunicator");
- }
+ properties->setProperty("Ice.ProgramName", service);
}
else
{
- if(programName.empty())
- {
- properties->setProperty("Ice.ProgramName", service);
- }
- else
- {
- properties->setProperty("Ice.ProgramName", programName + "-" + service);
- }
- }
-
- if(!args.empty())
- {
- //
- // Create the service properties with the given service arguments. This should
- // read the service config file if it's specified with --Ice.Config.
- //
- properties = createProperties(args, properties);
-
- if(!service.empty())
- {
- //
- // Next, parse the service "<service>.*" command line options (the Ice command
- // line options were parsed by the createProperties above)
- //
- args = properties->parseCommandLineOptions(service, args);
- }
+ properties->setProperty("Ice.ProgramName", programName + "-" + service);
}
-
- //
- // Remaining command line options are passed to the communicator. This is
- // necessary for Ice plug-in properties (e.g.: IceSSL).
- //
- InitializationData initData;
- initData.properties = properties;
- return initialize(args, initData);
+ return properties;
}
diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h
index 3e64aeb8ad1..5ef8cdd3bcb 100644
--- a/cpp/src/IceBox/ServiceManagerI.h
+++ b/cpp/src/IceBox/ServiceManagerI.h
@@ -63,7 +63,6 @@ private:
Ice::StringSeq args;
};
- void load(const std::string&, const std::string&);
void start(const std::string&, const std::string&, const ::Ice::StringSeq&);
void stopAll();
@@ -71,7 +70,7 @@ private:
void servicesStopped(const std::vector<std::string>&, const std::set<ServiceObserverPrx>&);
void observerRemoved(const ServiceObserverPrx&, const std::exception&);
- Ice::CommunicatorPtr createCommunicator(const std::string&, Ice::StringSeq&);
+ Ice::PropertiesPtr createServiceProperties(const std::string&);
::Ice::CommunicatorPtr _communicator;
::Ice::CommunicatorPtr _sharedCommunicator;