// // Copyright (c) ZeroC, Inc. All rights reserved. // #include #include #include using namespace std; using namespace Ice; using namespace Test; // // Dummy ServerLocatorRegistry, ServerLocator and ServantLocator. For // simplicity, we essentially 'alias' all possible requests to a single // object adapter and a single servant. // class ServerLocatorRegistry final : public LocatorRegistry { public: void setAdapterDirectProxyAsync(string, shared_ptr, function response, function, const Current&) override { response(); } void setReplicatedAdapterDirectProxyAsync(string, string, shared_ptr, function response, function, const Current&) override { response(); } void setServerProcessProxyAsync(string, shared_ptr, function response, function, const Current&) override { response(); } }; class ServerLocatorI final : public Locator { public: ServerLocatorI(shared_ptr backend, const shared_ptr& adapter) : _backend(move(backend)), _adapter(adapter), _registryPrx(uncheckedCast( adapter->add(make_shared(), Ice::stringToIdentity("registry")))) { } void findObjectByIdAsync(Identity id, function&)> response, function, const Current&) const override { response(_adapter->createProxy(id)); } void findAdapterByIdAsync(string, function&)> response, function, const Current&) const override { response(_adapter->createDirectProxy(stringToIdentity("dummy"))); } shared_ptr getRegistry(const Current&) const override { return _registryPrx; } private: const shared_ptr _backend; const shared_ptr _adapter; const shared_ptr _registryPrx; }; class BackendServer final : public Test::TestHelper { public: void run(int, char**) override; }; void BackendServer::run(int argc, char** argv) { Ice::CommunicatorHolder communicator = initialize(argc, argv); string endpoints = communicator->getProperties()->getPropertyWithDefault("BackendAdapter.Endpoints", "tcp -p 12010:ssl -p 12011"); communicator->getProperties()->setProperty("BackendAdapter.Endpoints", endpoints); auto adapter = communicator->createObjectAdapter("BackendAdapter"); auto backend = make_shared(); auto locator = make_shared(backend, adapter); adapter->add(locator, Ice::stringToIdentity("locator")); adapter->addDefaultServant(backend, ""); adapter->activate(); communicator->waitForShutdown(); } DEFINE_TEST(BackendServer)