summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Glacier/GlacierRouter.cpp23
-rw-r--r--cpp/src/Glacier/GlacierStarter.cpp6
-rw-r--r--cpp/src/Glacier/StarterI.cpp20
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp66
-rw-r--r--cpp/src/Ice/CommunicatorI.h2
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.cpp4
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.h2
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp52
-rw-r--r--cpp/src/Ice/ObjectAdapterI.h6
-rw-r--r--cpp/src/IceBox/Admin.cpp38
-rw-r--r--cpp/src/IceBox/Exception.cpp21
-rw-r--r--cpp/src/IceBox/Makefile3
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp202
-rw-r--r--cpp/src/IceBox/ServiceManagerI.h11
-rw-r--r--cpp/src/IcePack/Client.cpp2
-rw-r--r--cpp/src/IcePack/IcePackNode.cpp16
-rw-r--r--cpp/src/IcePack/NodeInfo.cpp8
-rw-r--r--cpp/src/IcePack/NodeRegistryI.cpp8
-rw-r--r--cpp/src/IcePack/Registry.cpp41
-rw-r--r--cpp/src/IcePack/ServerBuilder.cpp72
-rw-r--r--cpp/src/IcePack/ServerBuilder.h2
-rw-r--r--cpp/src/IcePack/ServiceBuilder.cpp17
-rw-r--r--cpp/src/IcePatch/Server.cpp5
-rw-r--r--cpp/src/IceStorm/Admin.cpp12
-rw-r--r--cpp/src/IceStorm/Service.cpp16
-rw-r--r--cpp/src/Yellow/Service.cpp9
26 files changed, 328 insertions, 336 deletions
diff --git a/cpp/src/Glacier/GlacierRouter.cpp b/cpp/src/Glacier/GlacierRouter.cpp
index 2035ef2d13c..83fb5e59270 100644
--- a/cpp/src/Glacier/GlacierRouter.cpp
+++ b/cpp/src/Glacier/GlacierRouter.cpp
@@ -167,26 +167,20 @@ Glacier::RouterApp::run(int argc, char* argv[])
// Initialize the client object adapter.
//
const char* clientEndpointsProperty = "Glacier.Router.Client.Endpoints";
- string clientEndpoints = properties->getProperty(clientEndpointsProperty);
- if(clientEndpoints.empty())
+ if(properties->getProperty(clientEndpointsProperty).empty())
{
cerr << appName() << ": property `" << clientEndpointsProperty << "' is not set" << endl;
return EXIT_FAILURE;
}
- ObjectAdapterPtr clientAdapter = communicator()->createObjectAdapterFromProperty("Client",
- clientEndpointsProperty);
- clientAdapter->setLocator(0);
+ ObjectAdapterPtr clientAdapter = communicator()->createObjectAdapter("Glacier.Router.Client");
//
// Initialize the server object adapter.
//
- const char* serverEndpointsProperty = "Glacier.Router.Server.Endpoints";
- string serverEndpoints = properties->getProperty(serverEndpointsProperty);
ObjectAdapterPtr serverAdapter;
- if(!serverEndpoints.empty())
+ if(!properties->getProperty("Glacier.Router.Server.Endpoints").empty())
{
- serverAdapter = communicator()->createObjectAdapterFromProperty("Server", serverEndpointsProperty);
- serverAdapter->setLocator(0);
+ serverAdapter = communicator()->createObjectAdapter("Glacier.Router.Server");
}
//
@@ -209,8 +203,7 @@ Glacier::RouterApp::run(int argc, char* argv[])
// Initialize the router object adapter and the router object.
//
const char* routerEndpointsProperty = "Glacier.Router.Endpoints";
- string routerEndpoints = properties->getProperty(routerEndpointsProperty);
- if(routerEndpoints.empty())
+ if(properties->getProperty(routerEndpointsProperty).empty())
{
cerr << appName() << ": property `" << routerEndpointsProperty << "' is not set" << endl;
return EXIT_FAILURE;
@@ -231,9 +224,7 @@ Glacier::RouterApp::run(int argc, char* argv[])
const char* userIdProperty = "Glacier.Router.UserId";
string userId = properties->getProperty(userIdProperty);
- ObjectAdapterPtr routerAdapter =
- communicator()->createObjectAdapterFromProperty("Router", routerEndpointsProperty);
- routerAdapter->setLocator(0);
+ ObjectAdapterPtr routerAdapter = communicator()->createObjectAdapter("Glacier.Router");
RouterPtr router = new RouterI(clientAdapter, serverAdapter, routingTable, sessionManagerPrx, userId);
routerAdapter->add(router, stringToIdentity(routerIdentity));
@@ -307,7 +298,7 @@ main(int argc, char* argv[])
defaultProperties = getDefaultProperties(argc, argv);
StringSeq args = argsToStringSeq(argc, argv);
args = defaultProperties->parseCommandLineOptions("Ice", args);
- args = defaultProperties->parseCommandLineOptions("Glacier", args);
+ args = defaultProperties->parseCommandLineOptions("Glacier.Router", args);
stringSeqToArgs(args, argc, argv);
}
catch(const Exception& ex)
diff --git a/cpp/src/Glacier/GlacierStarter.cpp b/cpp/src/Glacier/GlacierStarter.cpp
index e337d7bd0ab..c3601c998b0 100644
--- a/cpp/src/Glacier/GlacierStarter.cpp
+++ b/cpp/src/Glacier/GlacierStarter.cpp
@@ -75,14 +75,12 @@ Glacier::RouterApp::run(int argc, char* argv[])
// adapter doesn't register itself with the locator).
//
const char* endpointsProperty = "Glacier.Starter.Endpoints";
- string endpoints = properties->getProperty(endpointsProperty);
- if(endpoints.empty())
+ if(properties->getProperty(endpointsProperty).empty())
{
cerr << appName() << ": property `" << endpointsProperty << "' is not set" << endl;
return EXIT_FAILURE;
}
- ObjectAdapterPtr adapter = communicator()->createObjectAdapterFromProperty("Starter", endpointsProperty);
- adapter->setLocator(0);
+ ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Glacier.Starter");
//
// Get the password verifier, or create one if no verifier is
diff --git a/cpp/src/Glacier/StarterI.cpp b/cpp/src/Glacier/StarterI.cpp
index 6d034d72a35..44de87d35a8 100644
--- a/cpp/src/Glacier/StarterI.cpp
+++ b/cpp/src/Glacier/StarterI.cpp
@@ -59,6 +59,19 @@ Glacier::StarterI::StarterI(const CommunicatorPtr& communicator, const PasswordV
_certContext.setSecondsValid(issuedAdjust);
}
+static bool
+prefixOK(const string& property)
+{
+ if(property.find("--Ice.") == 0)
+ return false;
+ if(property.find("--IceSSL.") == 0)
+ return false;
+ if(property.find("--Glacier.Router") == 0)
+ return false;
+
+ return true;
+}
+
void
Glacier::StarterI::destroy()
{
@@ -173,6 +186,13 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt
// Setup arguments to start the router with.
//
StringSeq args = _properties->getCommandLineOptions();
+
+ //
+ // Filter all arguments that don't start with "--Ice.",
+ // "--IceSSL.", or "--Glacier.Router.".
+ //
+ args.erase(remove_if(args.begin(), args.end(), prefixOK), args.end());
+
args.push_back("--Glacier.Router.Identity=" + uuid);
//
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index 79e72685229..a53cd53cc73 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -97,52 +97,36 @@ Ice::CommunicatorI::createObjectAdapter(const string& name)
throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
- ObjectAdapterPtr adapter = createObjectAdapterFromProperty(name, "Ice.Adapter." + name + ".Endpoints");
-
- string router = _instance->properties()->getProperty("Ice.Adapter." + name + ".Router");
- if(!router.empty())
- {
- adapter->addRouter(RouterPrx::uncheckedCast(_instance->proxyFactory()->stringToProxy(router)));
- }
+ ObjectAdapterPtr adapter;
- string locator = _instance->properties()->getProperty("Ice.Adapter." + name + ".Locator");
- if(!locator.empty())
+ if(name.empty())
{
- adapter->setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->stringToProxy(locator)));
+ adapter = _instance->objectAdapterFactory()->createObjectAdapter("", "", "");
}
-
- return adapter;
-}
-
-ObjectAdapterPtr
-Ice::CommunicatorI::createObjectAdapterFromProperty(const string& name, const string& property)
-{
- RecMutex::Lock sync(*this);
- if(_destroyed)
+ else
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
-
- string endpts = _instance->properties()->getProperty(property);
-
- return createObjectAdapterWithEndpoints(name, endpts);
-}
-
-ObjectAdapterPtr
-Ice::CommunicatorI::createObjectAdapterWithEndpoints(const string& name, const string& endpts)
-{
- RecMutex::Lock sync(*this);
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ string id = _instance->properties()->getProperty(name + ".AdapterId");
+
+ string endpts = _instance->properties()->getProperty(name + ".Endpoints");
+
+ adapter = _instance->objectAdapterFactory()->createObjectAdapter(name, endpts, id);
+
+ string router = _instance->properties()->getProperty(name + ".Router");
+ if(!router.empty())
+ {
+ adapter->addRouter(RouterPrx::uncheckedCast(_instance->proxyFactory()->stringToProxy(router)));
+ }
+
+ string locator = _instance->properties()->getProperty(name + ".Locator");
+ if(!locator.empty())
+ {
+ adapter->setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->stringToProxy(locator)));
+ }
+ else
+ {
+ adapter->setLocator(_instance->referenceFactory()->getDefaultLocator());
+ }
}
-
- ObjectAdapterPtr adapter = _instance->objectAdapterFactory()->createObjectAdapter(name, endpts);
-
- //
- // Set the adapter locator to this communicator default locator.
- //
- adapter->setLocator(_instance->referenceFactory()->getDefaultLocator());
if(!_serverThreadPool) // Lazy initialization of _serverThreadPool.
{
diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h
index 7f73035a2a8..cc1616698c1 100644
--- a/cpp/src/Ice/CommunicatorI.h
+++ b/cpp/src/Ice/CommunicatorI.h
@@ -32,8 +32,6 @@ public:
virtual std::string proxyToString(const ObjectPrx&);
virtual ObjectAdapterPtr createObjectAdapter(const std::string&);
- virtual ObjectAdapterPtr createObjectAdapterFromProperty(const std::string&, const std::string&);
- virtual ObjectAdapterPtr createObjectAdapterWithEndpoints(const std::string&, const std::string&);
virtual void addObjectFactory(const ObjectFactoryPtr&, const std::string&);
virtual void removeObjectFactory(const std::string&);
diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp
index 2d19064514e..ec29ed96bf7 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.cpp
+++ b/cpp/src/Ice/ObjectAdapterFactory.cpp
@@ -31,7 +31,7 @@ IceInternal::ObjectAdapterFactory::shutdown()
}
ObjectAdapterPtr
-IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const string& endpts)
+IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const string& endpts, const string& id)
{
IceUtil::Mutex::Lock sync(*this);
@@ -41,7 +41,7 @@ IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const
return p->second;
}
- ObjectAdapterIPtr adapter = new ObjectAdapterI(_instance, _communicator, name, endpts);
+ ObjectAdapterIPtr adapter = new ObjectAdapterI(_instance, _communicator, name, endpts, id);
_adapters.insert(make_pair(name, adapter));
return adapter;
}
diff --git a/cpp/src/Ice/ObjectAdapterFactory.h b/cpp/src/Ice/ObjectAdapterFactory.h
index 7657b955fa5..ed6477ba69c 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.h
+++ b/cpp/src/Ice/ObjectAdapterFactory.h
@@ -22,7 +22,7 @@ class ObjectAdapterFactory : public ::IceUtil::Shared, public ::IceUtil::Mutex
public:
void shutdown();
- ::Ice::ObjectAdapterPtr createObjectAdapter(const std::string&, const std::string&);
+ ::Ice::ObjectAdapterPtr createObjectAdapter(const std::string&, const std::string&, const std::string&);
::Ice::ObjectAdapterPtr findObjectAdapter(const ::Ice::ObjectPrx&);
private:
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 55269d7bba5..23102d5690c 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -36,12 +36,6 @@ using namespace std;
using namespace Ice;
using namespace IceInternal;
-string
-Ice::ObjectAdapterI::getName()
-{
- return _name; // _name is immutable
-}
-
CommunicatorPtr
Ice::ObjectAdapterI::getCommunicator()
{
@@ -67,7 +61,7 @@ Ice::ObjectAdapterI::activate()
if(!_printAdapterReadyDone)
{
- if(_locatorInfo)
+ if(_locatorInfo && !_id.empty())
{
Identity ident;
ident.name = "dummy";
@@ -80,7 +74,7 @@ Ice::ObjectAdapterI::activate()
//
try
{
- _locatorInfo->getLocatorRegistry()->setAdapterDirectProxy(_name, newDirectProxy(ident));
+ _locatorInfo->getLocatorRegistry()->setAdapterDirectProxy(_id, newDirectProxy(ident));
}
catch(const Ice::AdapterNotRegistered&)
{
@@ -429,12 +423,6 @@ Ice::ObjectAdapterI::addRouter(const RouterPrx& router)
// callbacks.
//
_instance->outgoingConnectionFactory()->setRouter(routerInfo->getRouter());
-
- //
- // Creates proxies with endpoints instead of the adapter name
- // when there is a router.
- //
- _useEndpointsInProxy = true;
}
}
@@ -449,21 +437,6 @@ Ice::ObjectAdapterI::setLocator(const LocatorPrx& locator)
}
_locatorInfo = _instance->locatorManager()->get(locator);
- if(_locatorInfo)
- {
- //
- // If a locator is set, we create proxies with adapter names in
- // the reference instead of endpoints. If it's not set, we create
- // proxies with endpoints if there's at least one incoming
- // connection factory or router endpoints.
- //
- _useEndpointsInProxy = false;
- }
- else
- {
- IceUtil::Mutex::Lock routerEndpointsSync(_routerEndpointsMutex);
- _useEndpointsInProxy = !_incomingConnectionFactories.empty() || !_routerEndpoints.empty();
- }
}
list<ConnectionPtr>
@@ -484,11 +457,12 @@ Ice::ObjectAdapterI::getIncomingConnections() const
}
Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const CommunicatorPtr& communicator,
- const string& name, const string& endpts) :
+ const string& name, const string& endpts, const string& id) :
_instance(instance),
_communicator(communicator),
_printAdapterReadyDone(false),
_name(name),
+ _id(id),
_activeServantMapHint(_activeServantMap.end()),
_locatorMapHint(_locatorMap.end())
{
@@ -541,15 +515,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
__setNoDelete(false);
throw;
}
- __setNoDelete(false);
-
- //
- // Create proxies with the adapter endpoints only if there's
- // incoming connection factories. If there's no incoming
- // connection factories we will create proxies with the adapter
- // name in the reference (to allow collocation to work).
- //
- _useEndpointsInProxy = !_incomingConnectionFactories.empty();
+ __setNoDelete(false);
//
// Object Adapters without incoming connection factories are
@@ -576,7 +542,7 @@ Ice::ObjectAdapterI::~ObjectAdapterI()
ObjectPrx
Ice::ObjectAdapterI::newProxy(const Identity& ident) const
{
- if(_useEndpointsInProxy)
+ if(_id.empty())
{
return newDirectProxy(ident);
}
@@ -587,7 +553,7 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident) const
//
vector<EndpointPtr> endpoints;
ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway,
- false, false, _name, endpoints, 0, 0, 0);
+ false, false, _id, endpoints, 0, 0, 0);
//
// Return a proxy for the reference.
@@ -637,9 +603,9 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
{
//
// Proxy is local if the reference adapter id matches this
- // adapter name.
+ // adapter id.
//
- return ref->adapterId == _name;
+ return ref->adapterId == _id;
}
//
diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h
index 88009692b78..f7a6dc565b6 100644
--- a/cpp/src/Ice/ObjectAdapterI.h
+++ b/cpp/src/Ice/ObjectAdapterI.h
@@ -35,7 +35,6 @@ class ObjectAdapterI : public ObjectAdapter, public ::IceUtil::Mutex
{
public:
- virtual std::string getName();
virtual CommunicatorPtr getCommunicator();
virtual void activate();
@@ -66,7 +65,8 @@ public:
private:
- ObjectAdapterI(const ::IceInternal::InstancePtr&, const CommunicatorPtr&, const std::string&, const std::string&);
+ ObjectAdapterI(const ::IceInternal::InstancePtr&, const CommunicatorPtr&, const std::string&, const std::string&,
+ const std::string&);
virtual ~ObjectAdapterI();
friend class ::IceInternal::ObjectAdapterFactory;
@@ -78,7 +78,7 @@ private:
CommunicatorPtr _communicator;
bool _printAdapterReadyDone;
std::string _name;
- bool _useEndpointsInProxy;
+ std::string _id;
ObjectDict _activeServantMap;
ObjectDict::iterator _activeServantMapHint;
std::map<std::string, ServantLocatorPtr> _locatorMap;
diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp
index 07d05a0899c..6246fcff773 100644
--- a/cpp/src/IceBox/Admin.cpp
+++ b/cpp/src/IceBox/Admin.cpp
@@ -88,39 +88,31 @@ Client::run(int argc, char* argv[])
return EXIT_SUCCESS;
}
-
- //
- // TODO: Simplify configuration, this is way too complicated. We
- // should most likely have only two configuration variables, one
- // for the identity and the other one for the endpoints.
- //
-
- string namePrefix = properties->getProperty("IceBox.Name");
- if(!namePrefix.empty())
- {
- namePrefix += ".";
- }
-
string managerProxy;
- string managerEndpoints = properties->getProperty("IceBox.ServiceManager.Endpoints");
- if(managerEndpoints.empty())
+ string managerIdentity = properties->getPropertyWithDefault("IceBox.ServiceManager.Identity", "ServiceManager");
+
+ if(properties->getProperty("Ice.Default.Locator").empty())
{
- if(!properties->getProperty("Ice.Default.Locator").empty() && !namePrefix.empty())
- {
- managerProxy = namePrefix + "ServiceManager@" + namePrefix + "ServiceManagerAdapter";
- }
- else
+ string managerEndpoints = properties->getProperty("IceBox.ServiceManager.Endpoints");
+ if(managerEndpoints.empty())
{
cerr << appName() << ": property `IceBox.ServiceManager.Endpoints' is not set" << endl;
return EXIT_FAILURE;
}
+
+ managerProxy = managerIdentity + ":" + managerEndpoints;
}
else
{
- string managerIdentity = properties->getPropertyWithDefault("IceBox.ServiceManager.Identity",
- "ServiceManager");
- managerProxy = namePrefix + managerIdentity + ":" + managerEndpoints;
+ string managerAdapterId = properties->getProperty("IceBox.ServiceManager.AdapterId");
+ if(managerAdapterId.empty())
+ {
+ cerr << appName() << ": property `IceBox.ServiceManager.AdapterId' is not set" << endl;
+ return EXIT_FAILURE;
+ }
+
+ managerProxy = managerIdentity + "@" + managerAdapterId;
}
ObjectPrx base = communicator()->stringToProxy(managerProxy);
diff --git a/cpp/src/IceBox/Exception.cpp b/cpp/src/IceBox/Exception.cpp
new file mode 100644
index 00000000000..6374851379e
--- /dev/null
+++ b/cpp/src/IceBox/Exception.cpp
@@ -0,0 +1,21 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// Mutable Realms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <IceBox/IceBox.h>
+
+using namespace std;
+
+void
+IceBox::FailureException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ":\nservice failure exception: " << reason;
+}
+
diff --git a/cpp/src/IceBox/Makefile b/cpp/src/IceBox/Makefile
index 5eb8d8f1d3f..b7538acd9b9 100644
--- a/cpp/src/IceBox/Makefile
+++ b/cpp/src/IceBox/Makefile
@@ -21,7 +21,8 @@ ADMIN = $(top_srcdir)/bin/iceboxadmin
TARGETS = $(NAME) $(VERSIONED_NAME) $(SERVER) $(ADMIN)
-OBJS = IceBox.o
+OBJS = IceBox.o \
+ Exception.o
SOBJS = ServiceManagerI.o \
Server.o
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index ab79dfe2c8c..eef3af10afd 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -34,9 +34,6 @@ IceBox::ServiceManagerI::ServiceManagerI(Application* server, int& argc, char* a
{
_argv.push_back(argv[i]);
}
-
- PropertiesPtr properties = _server->communicator()->getProperties();
- _options = properties->getCommandLineOptions();
}
IceBox::ServiceManagerI::~ServiceManagerI()
@@ -56,34 +53,16 @@ IceBox::ServiceManagerI::run()
{
ServiceManagerPtr obj = this;
- //
- // TODO: Simplify configuration, this is way too complicated. We
- // should most likely have only two configuration properties, one
- // for the identity and the other one for the endpoints.
- //
-
- //
- // Prefix the adapter name and object identity with the value
- // of the IceBox.Name property.
- //
- PropertiesPtr properties = _server->communicator()->getProperties();
- string namePrefix = properties->getProperty("IceBox.Name");
- if(!namePrefix.empty())
- {
- namePrefix += ".";
- }
-
//
// Create an object adapter. Services probably should NOT share
// this object adapter, as the endpoint(s) for this object adapter
// will most likely need to be firewalled for security reasons.
//
- ObjectAdapterPtr adapter =
- _server->communicator()->createObjectAdapterFromProperty(namePrefix + "ServiceManagerAdapter",
- "IceBox.ServiceManager.Endpoints");
+ ObjectAdapterPtr adapter = _server->communicator()->createObjectAdapter("IceBox.ServiceManager");
- string identity = properties->getPropertyWithDefault("IceBox.ServiceManager.Identity",
- namePrefix + "ServiceManager");
+ PropertiesPtr properties = _server->communicator()->getProperties();
+
+ string identity = properties->getPropertyWithDefault("IceBox.ServiceManager.Identity", "ServiceManager");
adapter->add(obj, stringToIdentity(identity));
//
@@ -189,26 +168,14 @@ void
IceBox::ServiceManagerI::start(const string& service, const string& entryPoint, const StringSeq& args)
{
//
- // We need to create a property set to pass to start().
- // The property set is populated from a number of sources.
- // The precedence order (from lowest to highest) is:
- //
- // 1. Properties defined in the server property set (e.g.,
- // that were defined in the server's configuration file)
- // 2. Service arguments
- // 3. Server arguments
- //
- // We'll compose an array of arguments in the above order.
+ // Create the service property set from the service arguments and
+ // the server arguments. The service property set will be use to
+ // create a new communicator or we be added to the shared
+ // communicator depending on the value of the
+ // IceBox.UseSharedCommunicator property.
//
StringSeq serviceArgs;
StringSeq::size_type j;
- for(j = 0; j < _options.size(); j++)
- {
- if(_options[j].find("--" + service + ".") == 0)
- {
- serviceArgs.push_back(_options[j]);
- }
- }
for(j = 0; j < args.size(); j++)
{
serviceArgs.push_back(args[j]);
@@ -222,13 +189,6 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
}
//
- // Create the service property set.
- //
- PropertiesPtr serviceProperties = createProperties(serviceArgs);
- serviceArgs = serviceProperties->parseCommandLineOptions("Ice", serviceArgs);
- serviceArgs = serviceProperties->parseCommandLineOptions(service, serviceArgs);
-
- //
// Load the entry point.
//
DynamicLibraryPtr library = new DynamicLibrary();
@@ -236,7 +196,7 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
if(sym == 0)
{
string msg = library->getErrorMessage();
- FailureException ex;
+ FailureException ex(__FILE__, __LINE__);
ex.reason = "ServiceManager: unable to load entry point `" + entryPoint + "'";
if(!msg.empty())
{
@@ -256,13 +216,13 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
}
catch(const Exception& ex)
{
- FailureException e;
+ FailureException e(__FILE__, __LINE__);
e.reason = "ServiceManager: exception in entry point `" + entryPoint + "': " + ex.ice_name();
throw e;
}
catch (...)
{
- FailureException e;
+ FailureException e(__FILE__, __LINE__);
e.reason = "ServiceManager: unknown exception in entry point `" + entryPoint + "'";
throw e;
}
@@ -272,13 +232,48 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
//
try
{
+ //
+ // If Ice.UseSharedCommunicator.<name> is defined create a
+ // communicator for the service. The communicator inherits
+ // from the shared communicator properties. If it's not
+ // defined, add the service properties to the shared
+ // commnunicator property set.
+ //
+ PropertiesPtr properties = _server->communicator()->getProperties();
+ if(properties->getPropertyAsInt("IceBox.UseSharedCommunicator." + service) > 0)
+ {
+ Ice::PropertiesPtr fileProperties = Ice::createProperties(serviceArgs);
+ properties->parseCommandLineOptions("", fileProperties->getCommandLineOptions());
+
+ serviceArgs = properties->parseCommandLineOptions("Ice", serviceArgs);
+ serviceArgs = properties->parseCommandLineOptions(service, serviceArgs);
+ }
+ else
+ {
+ int argc = 0;
+ char **argv = 0;
+
+ Ice::PropertiesPtr serviceProperties = properties->clone();
+
+ Ice::PropertiesPtr fileProperties = Ice::createProperties(serviceArgs);
+ serviceProperties->parseCommandLineOptions("", fileProperties->getCommandLineOptions());
+
+ serviceArgs = serviceProperties->parseCommandLineOptions("Ice", serviceArgs);
+ serviceArgs = serviceProperties->parseCommandLineOptions(service, serviceArgs);
+
+ info.communicator = initializeWithProperties(argc, argv, serviceProperties);
+ }
+
+ Ice::CommunicatorPtr communicator = info.communicator ? info.communicator : _server->communicator();
+
::IceBox::ServicePtr s = ::IceBox::ServicePtr::dynamicCast(info.service);
+
if(s)
{
//
// IceBox::Service
//
- s->start(service, _server->communicator(), serviceProperties, serviceArgs);
+ s->start(service, communicator, serviceArgs);
}
else
{
@@ -290,32 +285,16 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
//
::IceBox::FreezeServicePtr fs = ::IceBox::FreezeServicePtr::dynamicCast(info.service);
- PropertiesPtr properties = _server->communicator()->getProperties();
- string propName = "IceBox.DBEnvName." + service;
- info.dbEnvName = properties->getProperty(propName);
+ info.dbEnv = ::Freeze::initialize(communicator, properties->getProperty("IceBox.DBEnvName." + service));
- DBEnvironmentInfo dbInfo;
- map<string,DBEnvironmentInfo>::iterator r = _dbEnvs.find(info.dbEnvName);
- if(r == _dbEnvs.end())
- {
- dbInfo.dbEnv = ::Freeze::initialize(_server->communicator(), info.dbEnvName);
- dbInfo.openCount = 1;
- }
- else
- {
- dbInfo = r->second;
- ++dbInfo.openCount;
- }
- _dbEnvs[info.dbEnvName] = dbInfo;
-
- fs->start(service, _server->communicator(), serviceProperties, serviceArgs, dbInfo.dbEnv);
+ fs->start(service, communicator, serviceArgs, info.dbEnv);
}
info.library = library;
_services[service] = info;
}
catch(const Freeze::DBException& ex)
{
- FailureException e;
+ FailureException e(__FILE__, __LINE__);
e.reason = "ServiceManager: database exception while starting service " + service + ": " + ex.ice_name() +
"\n" + ex.message;
throw e;
@@ -326,7 +305,7 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
}
catch(const Exception& ex)
{
- FailureException e;
+ FailureException e(__FILE__, __LINE__);
e.reason = "ServiceManager: exception while starting service " + service + ": " + ex.ice_name();
throw e;
}
@@ -345,56 +324,83 @@ IceBox::ServiceManagerI::stop(const string& service)
info.service->stop();
//
- // Close the database environment if service is a Freeze service and the
- // database open count is one.
+ // Close the database environment if the service database
+ // environment is set.
//
- ::IceBox::FreezeServicePtr fs = IceBox::FreezeServicePtr::dynamicCast(info.service);
- if(fs)
+ if(info.dbEnv)
{
- map<string,DBEnvironmentInfo>::iterator r = _dbEnvs.find(info.dbEnvName);
- assert(r != _dbEnvs.end());
- DBEnvironmentInfo dbInfo = r->second;
- if(--dbInfo.openCount == 0)
- {
- dbInfo.dbEnv->close();
- _dbEnvs.erase(info.dbEnvName);
- }
- else
- {
- _dbEnvs[info.dbEnvName] = dbInfo;
- }
+ info.dbEnv->close();
+ info.dbEnv = 0;
}
}
catch(const ::Freeze::DBException& ex)
{
- //
- // Release the service before the library
- //
info.service = 0;
+
+ if(info.communicator)
+ {
+ try
+ {
+ info.communicator->destroy();
+ }
+ catch(const Ice::Exception&)
+ {
+ }
+ info.communicator = 0;
+ }
+
info.library = 0;
- FailureException e;
+ FailureException e(__FILE__, __LINE__);
e.reason = "ServiceManager: database exception in stop for service " + service + ": " + ex.ice_name() +
"\n" + ex.message;
throw e;
}
catch(const Exception& ex)
{
- //
- // Release the service before the library
- //
info.service = 0;
+
+ if(info.communicator)
+ {
+ try
+ {
+ info.communicator->destroy();
+ }
+ catch(const Ice::Exception&)
+ {
+ }
+ info.communicator = 0;
+ }
+
info.library = 0;
- FailureException e;
+ FailureException e(__FILE__, __LINE__);
e.reason = "ServiceManager: exception in stop for service " + service + ": " + ex.ice_name();
throw e;
}
//
- // Release the service before the library
+ // Release the service, the service communicator and then the
+ // library. The order is important, the service must be release
+ // before destroying the communicator so that the communicator
+ // leak detector doesn't report potential leaks, and the
+ // communicator must be destroyed before the library is released
+ // since the library will destroy its global state.
//
info.service = 0;
+
+ if(info.communicator)
+ {
+ try
+ {
+ info.communicator->destroy();
+ }
+ catch(const Ice::Exception&)
+ {
+ }
+ info.communicator = 0;
+ }
+
info.library = 0;
}
diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h
index ac6cc047519..fb7f52721da 100644
--- a/cpp/src/IceBox/ServiceManagerI.h
+++ b/cpp/src/IceBox/ServiceManagerI.h
@@ -36,8 +36,9 @@ public:
struct ServiceInfo
{
ServiceBasePtr service;
- std::string dbEnvName;
::IceInternal::DynamicLibraryPtr library;
+ ::Ice::CommunicatorPtr communicator;
+ ::Freeze::DBEnvironmentPtr dbEnv;
};
private:
@@ -46,19 +47,11 @@ private:
void stop(const std::string&);
void stopAll();
- struct DBEnvironmentInfo
- {
- ::Freeze::DBEnvironmentPtr dbEnv;
- unsigned int openCount;
- };
-
::Ice::Application* _server;
::Ice::LoggerPtr _logger;
std::string _progName; // argv[0]
::Ice::StringSeq _argv; // Filtered server argument vector, not including program name
- ::Ice::StringSeq _options; // Server property set converted to command-line options
std::map<std::string, ServiceInfo> _services;
- std::map<std::string, DBEnvironmentInfo> _dbEnvs;
};
}
diff --git a/cpp/src/IcePack/Client.cpp b/cpp/src/IcePack/Client.cpp
index 5484c0b2c86..a8b21dee02d 100644
--- a/cpp/src/IcePack/Client.cpp
+++ b/cpp/src/IcePack/Client.cpp
@@ -143,7 +143,7 @@ Client::run(int argc, char* argv[])
return EXIT_FAILURE;
}
- AdminPrx admin = AdminPrx::checkedCast(communicator()->stringToProxy("IcePack/Admin@IcePackAdminAdapter"));
+ AdminPrx admin = AdminPrx::checkedCast(communicator()->stringToProxy("IcePack/Admin@IcePack.Registry.Admin"));
if(!admin)
{
cerr << appName() << ": no valid administrative endpoints" << endl;
diff --git a/cpp/src/IcePack/IcePackNode.cpp b/cpp/src/IcePack/IcePackNode.cpp
index ff00477bb42..4dad7b90bba 100644
--- a/cpp/src/IcePack/IcePackNode.cpp
+++ b/cpp/src/IcePack/IcePackNode.cpp
@@ -144,8 +144,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, const Free
//
// Check that required properties are set and valid.
//
- string endpoints = properties->getProperty("IcePack.Node.Endpoints");
- if(endpoints.empty())
+ if(properties->getProperty("IcePack.Node.Endpoints").empty())
{
Ice::Error out(communicator->getLogger());
out << "property `IcePack.Node.Endpoints' is not set";
@@ -170,8 +169,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, const Free
}
}
- Ice::ObjectAdapterPtr adapter =
- communicator->createObjectAdapterWithEndpoints("IcePackNodeAdapter." + name, endpoints);
+ //
+ // Set the adapter id for this node and create the node object
+ // adapter.
+ //
+ properties->setProperty("IcePack.Node.AdapterId", "IcePack.Node-" + name);
+
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("IcePack.Node");
TraceLevelsPtr traceLevels = new TraceLevels(properties, communicator->getLogger());
@@ -213,7 +217,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, const Free
try
{
NodeRegistryPrx nodeRegistry = NodeRegistryPrx::checkedCast(
- communicator->stringToProxy("IcePack/NodeRegistry@IcePackRegistryAdapter"));
+ communicator->stringToProxy("IcePack/NodeRegistry@IcePack.Registry.Internal"));
nodeRegistry->add(name, nodeProxy);
}
catch(const NodeActiveException&)
@@ -248,7 +252,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, const Free
AdminPrx admin;
try
{
- admin = AdminPrx::checkedCast(communicator->stringToProxy("IcePack/Admin@IcePackAdminAdapter"));
+ admin = AdminPrx::checkedCast(communicator->stringToProxy("IcePack/Admin@IcePack.Registry.Admin"));
}
catch(const Ice::LocalException& ex)
{
diff --git a/cpp/src/IcePack/NodeInfo.cpp b/cpp/src/IcePack/NodeInfo.cpp
index 1cf50a1a248..2f6cd5098b3 100644
--- a/cpp/src/IcePack/NodeInfo.cpp
+++ b/cpp/src/IcePack/NodeInfo.cpp
@@ -57,7 +57,7 @@ IcePack::NodeInfo::getAdapterRegistry() const
try
{
return AdapterRegistryPrx::checkedCast(
- _communicator->stringToProxy("IcePack/AdapterRegistry@IcePackRegistryAdapter"));
+ _communicator->stringToProxy("IcePack/AdapterRegistry@IcePack.Registry.Internal"));
}
catch(const Ice::LocalException& ex)
{
@@ -71,7 +71,7 @@ IcePack::NodeInfo::getServerRegistry() const
try
{
return ServerRegistryPrx::checkedCast(
- _communicator->stringToProxy("IcePack/ServerRegistry@IcePackRegistryAdapter"));
+ _communicator->stringToProxy("IcePack/ServerRegistry@IcePack.Registry.Internal"));
}
catch(const Ice::LocalException& ex)
{
@@ -87,7 +87,7 @@ IcePack::NodeInfo::getYellowQuery() const
//
try
{
- return Yellow::QueryPrx::checkedCast(_communicator->stringToProxy("Yellow/Query@YellowQueryAdapter"));
+ return Yellow::QueryPrx::checkedCast(_communicator->stringToProxy("Yellow/Query@Yellow.Query"));
}
catch(const Ice::LocalException& ex)
{
@@ -103,7 +103,7 @@ IcePack::NodeInfo::getYellowAdmin() const
//
try
{
- return Yellow::AdminPrx::checkedCast(_communicator->stringToProxy("Yellow/Admin@YellowAdminAdapter"));
+ return Yellow::AdminPrx::checkedCast(_communicator->stringToProxy("Yellow/Admin@Yellow.Admin"));
}
catch(const Ice::LocalException& ex)
{
diff --git a/cpp/src/IcePack/NodeRegistryI.cpp b/cpp/src/IcePack/NodeRegistryI.cpp
index 3393aad1d67..eae4cbb2108 100644
--- a/cpp/src/IcePack/NodeRegistryI.cpp
+++ b/cpp/src/IcePack/NodeRegistryI.cpp
@@ -81,7 +81,7 @@ IcePack::NodeRegistryI::add(const string& name, const NodePrx& node, const Ice::
try
{
- _adapterRegistry->findByName("IcePackNodeAdapter." + name);
+ _adapterRegistry->findByName("IcePack.Node-" + name);
//
// TODO: ensure this adapter has been created by the adapter
@@ -100,7 +100,7 @@ IcePack::NodeRegistryI::add(const string& name, const NodePrx& node, const Ice::
AdapterPrx adapter = _adapterFactory->createStandaloneAdapter("IcePackNodeAdapter." + name);
try
{
- _adapterRegistry->add("IcePackNodeAdapter." + name, adapter);
+ _adapterRegistry->add("IcePack.Node-" + name, adapter);
}
catch(const AdapterExistsException&)
{
@@ -133,9 +133,9 @@ IcePack::NodeRegistryI::remove(const string& name, const Ice::Current&)
//
try
{
- AdapterPrx adapter = _adapterRegistry->findByName("IcePackNodeAdapter." + name);
+ AdapterPrx adapter = _adapterRegistry->findByName("IcePack.Node-" + name);
adapter->destroy();
- _adapterRegistry->remove("IcePackNodeAdapter." + name);
+ _adapterRegistry->remove("IcePack.Node-" + name);
}
catch(const AdapterNotExistException&)
{
diff --git a/cpp/src/IcePack/Registry.cpp b/cpp/src/IcePack/Registry.cpp
index 9d5d0d368a7..9c7f7e7cf76 100644
--- a/cpp/src/IcePack/Registry.cpp
+++ b/cpp/src/IcePack/Registry.cpp
@@ -94,32 +94,28 @@ IcePack::Registry::start(bool nowarn)
//
// Check that required properties are set and valid.
//
- string registryEndpoints = properties->getProperty("IcePack.Registry.Internal.Endpoints");
- if(registryEndpoints.empty())
+ if(properties->getProperty("IcePack.Registry.Internal.Endpoints").empty())
{
Ice::Error out(_communicator->getLogger());
out << "property `IcePack.Registry.Internal.Endpoints' is not set";
return false;
}
- string locatorEndpoints = properties->getProperty("IcePack.Registry.Locator.Endpoints");
- if(locatorEndpoints.empty())
+ if(properties->getProperty("IcePack.Registry.Locator.Endpoints").empty())
{
Ice::Error out(_communicator->getLogger());
out << "property `IcePack.Registry.Locator.Endpoints' is not set";
return false;
}
- string locatorRegistryEndpoints = properties->getProperty("IcePack.Registry.LocatorRegistry.Endpoints");
- if(locatorRegistryEndpoints.empty())
+ if(properties->getProperty("IcePack.Registry.LocatorRegistry.Endpoints").empty())
{
Ice::Error out(_communicator->getLogger());
out << "property `IcePack.Registry.LocatorRegistry.Endpoints' is not set";
return false;
}
- string adminEndpoints = properties->getProperty("IcePack.Registry.Admin.Endpoints");
- if(!adminEndpoints.empty())
+ if(!properties->getProperty("IcePack.Registry.Admin.Endpoints").empty())
{
if(!nowarn)
{
@@ -140,8 +136,8 @@ IcePack::Registry::start(bool nowarn)
//
// Create the internal registries (node, server, adapter).
//
- Ice::ObjectAdapterPtr registryAdapter =
- _communicator->createObjectAdapterWithEndpoints("IcePackRegistryAdapter", registryEndpoints);
+ properties->setProperty("IcePack.Registry.Internal.AdapterId", "IcePack.Registry.Internal");
+ Ice::ObjectAdapterPtr registryAdapter = _communicator->createObjectAdapter("IcePack.Registry.Internal");
AdapterFactoryPtr adapterFactory = new AdapterFactory(registryAdapter, traceLevels, _dbEnv);
@@ -162,8 +158,8 @@ IcePack::Registry::start(bool nowarn)
// NOTE: the locator registry uses the registry object adapter
// to activate standalone object adapters.
//
- Ice::ObjectAdapterPtr locatorRegistryAdapter =
- _communicator->createObjectAdapterWithEndpoints("IcePackLocatorRegistryAdapter",locatorRegistryEndpoints);
+ Ice::ObjectAdapterPtr locatorRegistryAdapter =
+ _communicator->createObjectAdapter("IcePack.Registry.LocatorRegistry");
Ice::Identity locatorRegistryId;
locatorRegistryId.category = "IcePack";
@@ -176,8 +172,7 @@ IcePack::Registry::start(bool nowarn)
// Create the locator registry adapter and the locator
// registry servant.
//
- Ice::ObjectAdapterPtr locatorAdapter =
- _communicator->createObjectAdapterWithEndpoints("IcePackLocatorAdapter", locatorEndpoints);
+ Ice::ObjectAdapterPtr locatorAdapter = _communicator->createObjectAdapter("IcePack.Registry.Locator");
Ice::Identity locatorId;
locatorId.category = "IcePack";
@@ -189,37 +184,37 @@ IcePack::Registry::start(bool nowarn)
//
// Create the admin adapter and admin servant.
//
- Ice::ObjectAdapterPtr adminAdapter =
- _communicator->createObjectAdapterWithEndpoints("IcePackAdminAdapter", adminEndpoints);
+ properties->setProperty("IcePack.Registry.Admin.AdapterId", "IcePack.Registry.Admin");
+ Ice::ObjectAdapterPtr adminAdapter = _communicator->createObjectAdapter("IcePack.Registry.Admin");
AdminPtr admin = new AdminI(_communicator, nodeRegistry, serverRegistry, adapterRegistry);
adminAdapter->add(admin, Ice::stringToIdentity("IcePack/Admin"));
//
- // Register the IcePackRegistryAdapter adapter and
- // IcePackAdminAdapter with the adapter registry so that they can
+ // Register the IcePack.Registry.Internal adapter and
+ // IcePack.Registry.Admin with the adapter registry so that they can
// be located by clients.
//
try
{
- adapterRegistry->remove("IcePackRegistryAdapter");
+ adapterRegistry->remove("IcePack.Registry.Internal");
}
catch(const AdapterNotExistException&)
{
}
try
{
- adapterRegistry->remove("IcePackAdminAdapter");
+ adapterRegistry->remove("IcePack.Registry.Admin");
}
catch(const AdapterNotExistException&)
{
}
- adapterRegistry->add("IcePackRegistryAdapter", AdapterPrx::uncheckedCast(
+ adapterRegistry->add("IcePack.Registry.Internal", AdapterPrx::uncheckedCast(
locatorRegistryAdapter->addWithUUID(new StandaloneAdapterI())));
- adapterRegistry->add("IcePackAdminAdapter", AdapterPrx::uncheckedCast(
+ adapterRegistry->add("IcePack.Registry.Admin", AdapterPrx::uncheckedCast(
locatorRegistryAdapter->addWithUUID(new StandaloneAdapterI())));
-
+
//
// Set the locator on the registry and admin adapter. This should
// cause the adapters to register their endpoints with the locator
diff --git a/cpp/src/IcePack/ServerBuilder.cpp b/cpp/src/IcePack/ServerBuilder.cpp
index 029c356954b..72cc8061d52 100644
--- a/cpp/src/IcePack/ServerBuilder.cpp
+++ b/cpp/src/IcePack/ServerBuilder.cpp
@@ -8,6 +8,7 @@
//
// **********************************************************************
+#include <IceUtil/UUID.h>
#include <Ice/Ice.h>
#include <IcePack/ServerBuilder.h>
#include <IcePack/ServiceBuilder.h>
@@ -248,14 +249,28 @@ IcePack::ServerHandler::startElement(const XMLCh *const name, AttributeList &att
else if(kind == "cpp-icebox")
{
_builder.setKind(ServerBuilder::ServerKindCppIceBox);
- _builder.addProperty("IceBox.ServiceManager.Endpoints", getAttributeValue(attrs, "endpoints"));
_builder.createConfigFile("/config/config_icebox");
+ _builder.createDirectory("/dbs");
+
+ //
+ // TODO: is the server name a good category?
+ //
+ _builder.addProperty("IceBox.ServiceManager.Identity", _builder.substitute("${name}/ServiceManager"));
+
+ _builder.registerAdapter("IceBox.ServiceManager", getAttributeValue(attrs, "endpoints"), "");
}
else if(kind == "java-icebox")
{
_builder.setKind(ServerBuilder::ServerKindJavaIceBox);
- _builder.addProperty("IceBox.ServiceManager.Endpoints", getAttributeValue(attrs, "endpoints"));
_builder.createConfigFile("/config/config_icebox");
+ _builder.createDirectory("/dbs");
+
+ //
+ // TODO: is the server name a good category?
+ //
+ _builder.addProperty("IceBox.ServiceManager.Identity", _builder.substitute("${name}/ServiceManager"));
+
+ _builder.registerAdapter("IceBox.ServiceManager", getAttributeValue(attrs, "endpoints"), "");
}
}
else if(str == "service")
@@ -267,7 +282,8 @@ IcePack::ServerHandler::startElement(const XMLCh *const name, AttributeList &att
else if(str == "adapter")
{
_builder.registerAdapter(getAttributeValue(attrs, "name"),
- getAttributeValueWithDefault(attrs, "endpoints", ""));
+ getAttributeValue(attrs, "endpoints"),
+ getAttributeValueWithDefault(attrs, "id", ""));
}
else if(str == "activation")
{
@@ -521,7 +537,7 @@ IcePack::ServerBuilder::registerServer()
}
void
-IcePack::ServerBuilder::registerAdapter(const string& name, const string& endpoints)
+IcePack::ServerBuilder::registerAdapter(const string& name, const string& endpoints, const string& adapterId)
{
AdapterRegistryPrx adapterRegistry = _nodeInfo->getAdapterRegistry();
if(!adapterRegistry)
@@ -531,26 +547,33 @@ IcePack::ServerBuilder::registerAdapter(const string& name, const string& endpoi
if(name.empty())
{
- throw DeploySAXParseException("no adapter name", _locator);
+ throw DeploySAXParseException("empty adapter name", _locator);
+ }
+ if(endpoints.empty())
+ {
+ throw DeploySAXParseException("empty adapter endpoints", _locator);
}
+
+ //
+ // If the adapter id is not specified, generate one from the
+ // server and adapter name.
+ //
+ string id = adapterId.empty() ? name + "-" + _variables["name"] : adapterId;
//
- // A server adapter object will be created with the server
- // when the server is created (see ServerBuilder::execute()
+ // A server adapter object will be created with the server when
+ // the server is created (see ServerBuilder::execute()
// method). The RegisterServerAdapter task will get the server
- // adapter proxy through the builder method
- // getServerAdapter().
- //
- _serverAdapterNames.push_back(name);
- _tasks.push_back(new RegisterServerAdapterTask(adapterRegistry, name, *this));
-
- addProperty("Ice.Adapter." + name + ".Locator",
- _nodeInfo->getCommunicator()->getProperties()->getProperty("Ice.Default.Locator"));
+ // adapter proxy through the builder method getServerAdapter().
+ //
+ _serverAdapterNames.push_back(id);
+ _tasks.push_back(new RegisterServerAdapterTask(adapterRegistry, id, *this));
- if(!endpoints.empty())
- {
- addProperty("Ice.Adapter." + name + ".Endpoints", endpoints);
- }
+ //
+ // Generate adapter configuration properties.
+ //
+ addProperty(name + ".Endpoints", endpoints);
+ addProperty(name + ".AdapterId", id);
}
void
@@ -633,12 +656,10 @@ IcePack::ServerBuilder::setKind(ServerBuilder::ServerKind kind)
_description.serviceManager = IceBox::ServiceManagerPrx::uncheckedCast(
_nodeInfo->getCommunicator()->stringToProxy(
- _variables["name"] + ".ServiceManager@" + _variables["name"] + ".ServiceManagerAdapter"));
+ "IceBox/" + _variables["name"] + "@" + _variables["name"] + "ServiceManagerAdapter"));
_className = "IceBox.Server";
- createDirectory("/dbs");
- addProperty("IceBox.Name", _variables["name"]);
- registerAdapter(_variables["name"] + ".ServiceManagerAdapter","");
+
break;
}
case ServerKindCppIceBox:
@@ -650,11 +671,8 @@ IcePack::ServerBuilder::setKind(ServerBuilder::ServerKind kind)
_description.serviceManager = IceBox::ServiceManagerPrx::uncheckedCast(
_nodeInfo->getCommunicator()->stringToProxy(
- _variables["name"] + ".ServiceManager@" + _variables["name"] + ".ServiceManagerAdapter"));
+ "IceBox/" + _variables["name"] + "@" + _variables["name"] + "ServiceManagerAdapter"));
- createDirectory("/dbs");
- addProperty("IceBox.Name", _variables["name"]);
- registerAdapter(_variables["name"] + ".ServiceManagerAdapter","");
break;
}
}
diff --git a/cpp/src/IcePack/ServerBuilder.h b/cpp/src/IcePack/ServerBuilder.h
index 729c48f5306..e96ac3c5143 100644
--- a/cpp/src/IcePack/ServerBuilder.h
+++ b/cpp/src/IcePack/ServerBuilder.h
@@ -41,7 +41,7 @@ public:
void setClassName(const std::string&);
void setWorkingDirectory(const std::string&);
void registerServer();
- void registerAdapter(const std::string&, const std::string&);
+ void registerAdapter(const std::string&, const std::string&, const std::string&);
void addService(const std::string&, const std::string&);
void addOption(const std::string&);
void addJavaOption(const std::string&);
diff --git a/cpp/src/IcePack/ServiceBuilder.cpp b/cpp/src/IcePack/ServiceBuilder.cpp
index 3c7ba67497e..37adeaed70a 100644
--- a/cpp/src/IcePack/ServiceBuilder.cpp
+++ b/cpp/src/IcePack/ServiceBuilder.cpp
@@ -70,13 +70,24 @@ IcePack::ServiceHandler::startElement(const XMLCh *const name, AttributeList &at
_builder.setDBEnv(getAttributeValueWithDefault(attrs, "dbenv", ""));
}
- _builder.createConfigFile("/config/config_" + _builder.substitute("${name}"));
+ _builder.createConfigFile(_builder.substitute("/config/config_${name}"));
_builder.setEntryPoint(getAttributeValue(attrs, "entry"));
}
else if(str == "adapter")
{
- _builder.getServerBuilder().registerAdapter(getAttributeValue(attrs, "name"),
- getAttributeValueWithDefault(attrs, "endpoints", ""));
+ string name = getAttributeValue(attrs, "name");
+ string id = getAttributeValueWithDefault(attrs, "id", "");
+
+ //
+ // If the adapter id is not specified or empty, generate one
+ // from the server, service and adapter name: <adapter
+ // name>-<server name>-<service name>
+ //
+ if(id.empty())
+ {
+ id = name + "-" + _builder.getServerBuilder().substitute("${name}") + _builder.substitute("${name}");
+ }
+ _builder.getServerBuilder().registerAdapter(name, getAttributeValue(attrs, "endpoints"), id);
}
}
diff --git a/cpp/src/IcePatch/Server.cpp b/cpp/src/IcePatch/Server.cpp
index bb7029dfec7..222fc7a80d6 100644
--- a/cpp/src/IcePatch/Server.cpp
+++ b/cpp/src/IcePatch/Server.cpp
@@ -95,8 +95,7 @@ IcePatch::Server::run(int argc, char* argv[])
// Get the IcePatch endpoints.
//
const char* endpointsProperty = "IcePatch.Endpoints";
- string endpoints = properties->getProperty(endpointsProperty);
- if(endpoints.empty())
+ if(properties->getProperty(endpointsProperty).empty())
{
cerr << appName() << ": property `" << endpointsProperty << "' is not set" << endl;
return EXIT_FAILURE;
@@ -123,7 +122,7 @@ IcePatch::Server::run(int argc, char* argv[])
//
// Create and initialize the object adapter and the file locator.
//
- ObjectAdapterPtr adapter = communicator()->createObjectAdapterFromProperty("IcePatch", endpointsProperty);
+ ObjectAdapterPtr adapter = communicator()->createObjectAdapter("IcePatch");
ServantLocatorPtr fileLocator = new FileLocator(adapter);
adapter->addServantLocator(fileLocator, "IcePatch");
diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp
index a0bcd06acff..c385586e550 100644
--- a/cpp/src/IceStorm/Admin.cpp
+++ b/cpp/src/IceStorm/Admin.cpp
@@ -157,19 +157,19 @@ Client::run(int argc, char* argv[])
return EXIT_FAILURE;
}
- const char* managerReferenceProperty = "IceStorm.TopicManager";
- string managerReference = properties->getProperty(managerReferenceProperty);
- if(managerReference.empty())
+ const char* managerProxyProperty = "IceStorm.TopicManager.Proxy";
+ string managerProxy = properties->getProperty(managerProxyProperty);
+ if(managerProxy.empty())
{
- cerr << appName() << ": property `" << managerReferenceProperty << "' is not set" << endl;
+ cerr << appName() << ": property `" << managerProxyProperty << "' is not set" << endl;
return EXIT_FAILURE;
}
- ObjectPrx base = communicator()->stringToProxy(managerReference);
+ ObjectPrx base = communicator()->stringToProxy(managerProxy);
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base);
if(!manager)
{
- cerr << appName() << ": `" << managerReference << "' is not running" << endl;
+ cerr << appName() << ": `" << managerProxy << "' is not running" << endl;
return EXIT_FAILURE;
}
diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp
index 21f10259fa5..47612d9b8bd 100644
--- a/cpp/src/IceStorm/Service.cpp
+++ b/cpp/src/IceStorm/Service.cpp
@@ -35,7 +35,6 @@ public:
virtual void start(const string&,
const CommunicatorPtr&,
- const PropertiesPtr&,
const StringSeq&,
const DBEnvironmentPtr&);
@@ -73,18 +72,17 @@ IceStorm::ServiceI::~ServiceI()
void
IceStorm::ServiceI::start(const string& name,
- const CommunicatorPtr& communicator,
- const PropertiesPtr& properties,
- const StringSeq& args,
- const DBEnvironmentPtr& dbEnv)
+ const CommunicatorPtr& communicator,
+ const StringSeq& args,
+ const DBEnvironmentPtr& dbEnv)
{
DBPtr dbTopicManager = dbEnv->openDB("topicmanager", true);
- TraceLevelsPtr traceLevels = new TraceLevels(name, properties, communicator->getLogger());
- string endpoints = properties->getProperty(name + ".TopicManager.Endpoints");
- _adapter = communicator->createObjectAdapterWithEndpoints(name + ".TopicManagerAdapter", endpoints);
+ TraceLevelsPtr traceLevels = new TraceLevels(name, communicator->getProperties(), communicator->getLogger());
+ _adapter = communicator->createObjectAdapter(name + ".TopicManager");
+
_manager = new TopicManagerI(communicator, _adapter, traceLevels, dbEnv, dbTopicManager);
- _adapter->add(_manager, stringToIdentity(name + ".TopicManager"));
+ _adapter->add(_manager, stringToIdentity(name + "/TopicManager"));
_adapter->activate();
}
diff --git a/cpp/src/Yellow/Service.cpp b/cpp/src/Yellow/Service.cpp
index 93e5391c39c..007873e09b9 100644
--- a/cpp/src/Yellow/Service.cpp
+++ b/cpp/src/Yellow/Service.cpp
@@ -36,7 +36,6 @@ public:
virtual void start(const string&,
const CommunicatorPtr&,
- const PropertiesPtr&,
const StringSeq&,
const ::Freeze::DBEnvironmentPtr&);
@@ -75,7 +74,6 @@ Yellow::ServiceI::~ServiceI()
void
Yellow::ServiceI::start(const string& name,
const CommunicatorPtr& communicator,
- const PropertiesPtr& properties,
const StringSeq& args,
const DBEnvironmentPtr& dbEnv)
{
@@ -95,13 +93,12 @@ Yellow::ServiceI::start(const string& name,
//
// TODO: At present #2 isn't supported.
//
- string queryEndpoints = properties->getProperty(name + ".Query.Endpoints");
- _queryAdapter = communicator->createObjectAdapterWithEndpoints(name + "QueryAdapter", queryEndpoints);
+ _queryAdapter = communicator->createObjectAdapter(name + ".Query");
- string adminEndpoints = properties->getProperty(name + ".Admin.Endpoints");
+ string adminEndpoints = communicator->getProperties()->getProperty(name + ".Admin.Endpoints");
if(!adminEndpoints.empty())
{
- _adminAdapter = communicator->createObjectAdapterWithEndpoints(name + "AdminAdapter", adminEndpoints);
+ _adminAdapter = communicator->createObjectAdapter(name + ".Admin");
ObjectPtr admin = new AdminI(dbYellow);
_adminAdapter->add(admin, stringToIdentity(name + "/Admin"));
}