本文整理汇总了C++中ice::ObjectAdapterPtr::addServantLocator方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectAdapterPtr::addServantLocator方法的具体用法?C++ ObjectAdapterPtr::addServantLocator怎么用?C++ ObjectAdapterPtr::addServantLocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::ObjectAdapterPtr
的用法示例。
在下文中一共展示了ObjectAdapterPtr::addServantLocator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allTests
int
TestServer::run(int argc, char* argv[])
{
communicator()->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010");
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter");
adapter->addServantLocator(new ServantLocatorI(""), "");
adapter->addServantLocator(new ServantLocatorI("category"), "category");
adapter->add(new TestI, communicator()->stringToIdentity("asm"));
adapter->add(new TestActivationI, communicator()->stringToIdentity("test/activation"));
Test::TestIntfPrx allTests(const CommunicatorPtr&, bool);
allTests(communicator(), true);
return EXIT_SUCCESS;
}
示例2: communicator
int
TestServer::run(int argc, char* argv[])
{
communicator()->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000:udp");
communicator()->getProperties()->setProperty("Ice.Warn.Dispatch", "0");
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter");
adapter->addServantLocator(new ServantLocatorI(""), "");
adapter->addServantLocator(new ServantLocatorI("category"), "category");
adapter->add(new TestI, communicator()->stringToIdentity("asm"));
adapter->activate();
adapter->waitForDeactivate();
return EXIT_SUCCESS;
}
示例3: catch
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
IceUtilInternal::Options opts;
opts.addOpt("", "array");
opts.addOpt("", "async");
vector<string> args;
try
{
args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtilInternal::BadOptException& e)
{
cout << argv[0] << ": " << e.reason << endl;
return false;
}
bool array = opts.isSet("array");
bool async = opts.isSet("async");
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorI, array, async), "");
adapter->activate();
TEST_READY
communicator->waitForShutdown();
return EXIT_SUCCESS;
}
示例4: allTests
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("Ice.Warn.Dispatch", "0");
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorI, ""), "");
adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorI, "category"), "category");
adapter->add(ICE_MAKE_SHARED(TestI), communicator->stringToIdentity("asm"));
adapter->add(ICE_MAKE_SHARED(TestActivationI), communicator->stringToIdentity("test/activation"));
Test::TestIntfPrxPtr allTests(const CommunicatorPtr&);
allTests(communicator);
return EXIT_SUCCESS;
}
示例5: getTestEndpoint
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0) + ":udp");
communicator->getProperties()->setProperty("Ice.Warn.Dispatch", "0");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorAMDI, ""), "");
adapter->addServantLocator(ICE_MAKE_SHARED(ServantLocatorAMDI, "category"), "category");
adapter->add(ICE_MAKE_SHARED(TestAMDI), communicator->stringToIdentity("asm"));
adapter->add(ICE_MAKE_SHARED(TestActivationI), communicator->stringToIdentity("test/activation"));
adapter->activate();
TEST_READY
adapter->waitForDeactivate();
return EXIT_SUCCESS;
}
示例6: ServantLocatorAMDI
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
communicator->getProperties()->setProperty("Ice.Warn.Dispatch", "0");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
adapter->addServantLocator(new ServantLocatorAMDI(""), "");
adapter->addServantLocator(new ServantLocatorAMDI("category"), "category");
adapter->add(new TestAMDI, communicator->stringToIdentity("asm"));
adapter->add(new TestActivationI, communicator->stringToIdentity("test/activation"));
adapter->activate();
TEST_READY
adapter->waitForDeactivate();
return EXIT_SUCCESS;
}
示例7: communicator
int
HRServer::run(int argc, char* argv[])
{
const string username = communicator()->getProperties()->getPropertyWithDefault("Oracle.Username", "scott");
const string password = communicator()->getProperties()->getPropertyWithDefault("Oracle.Password", "password");
const string connectString = communicator()->getProperties()->getProperty("Oracle.ConnectString");
//
// We use a single servant locator and a single category for all Emp and Dept objects
//
const string category = "OCCI";
Environment* env = 0;
StatelessConnectionPool* pool = 0;
try
{
env = Environment::createEnvironment(Environment::Mode(Environment::THREADED_MUTEXED | Environment::OBJECT));
DbTypesMap(env);
pool = env->createStatelessConnectionPool(username, password, connectString, 5, 2, 1,
StatelessConnectionPool::HOMOGENEOUS);
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("HR");
DeptFactoryIPtr factory = new DeptFactoryI(env, pool, category);
adapter->addServantLocator(new OCCIServantLocator(factory), category);
adapter->add(factory, communicator()->stringToIdentity("DeptFactory"));
adapter->activate();
communicator()->waitForShutdown();
}
catch(...)
{
if(pool != 0)
{
env->terminateStatelessConnectionPool(pool);
}
if(env != 0)
{
Environment::terminateEnvironment(env);
}
throw;
}
if(pool != 0)
{
env->terminateStatelessConnectionPool(pool);
}
if(env != 0)
{
Environment::terminateEnvironment(env);
}
return EXIT_SUCCESS;
}
示例8: SessionServantManager
Ice::ObjectAdapterPtr
RegistryI::setupAdminSessionFactory(const Ice::ObjectAdapterPtr& registryAdapter,
const Ice::ObjectPtr& router,
const IceGrid::LocatorPrx& locator)
{
Ice::PropertiesPtr properties = _communicator->getProperties();
Ice::ObjectAdapterPtr adapter;
SessionServantManagerPtr servantManager;
if(!properties->getProperty("IceGrid.Registry.AdminSessionManager.Endpoints").empty())
{
adapter = _communicator->createObjectAdapter("IceGrid.Registry.AdminSessionManager");
servantManager = new SessionServantManager(adapter, _instanceName, false, getServerAdminCategory(), router, 0);
adapter->addServantLocator(servantManager, "");
}
assert(_reaper);
_adminSessionFactory = new AdminSessionFactory(servantManager, _database, _reaper, this);
if(servantManager)
{
Identity sessionMgrId;
sessionMgrId.category = _instanceName;
sessionMgrId.name = "AdminSessionManager";
Identity sslSessionMgrId;
sslSessionMgrId.category = _instanceName;
sslSessionMgrId.name = "AdminSSLSessionManager";
if(!_master)
{
sessionMgrId.name += "-" + _replicaName;
sslSessionMgrId.name += "-" + _replicaName;
}
adapter->add(new AdminSessionManagerI(_adminSessionFactory), sessionMgrId);
adapter->add(new AdminSSLSessionManagerI(_adminSessionFactory), sslSessionMgrId);
_wellKnownObjects->add(adapter->createProxy(sessionMgrId), Glacier2::SessionManager::ice_staticId());
_wellKnownObjects->add(adapter->createProxy(sslSessionMgrId), Glacier2::SSLSessionManager::ice_staticId());
}
if(adapter)
{
Ice::Identity dummy;
dummy.name = "dummy";
_wellKnownObjects->addEndpoint("AdminSessionManager", adapter->createDirectProxy(dummy));
}
_adminVerifier = getPermissionsVerifier(registryAdapter,
locator,
"IceGrid.Registry.AdminPermissionsVerifier",
properties->getProperty("IceGrid.Registry.AdminCryptPasswords"));
_sslAdminVerifier = getSSLPermissionsVerifier(locator, "IceGrid.Registry.AdminSSLPermissionsVerifier");
return adapter;
}
示例9:
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
ServantLocatorPtr locator = new ServantLocatorI;
adapter->addServantLocator(locator, "");
adapter->activate();
TEST_READY
adapter->waitForDeactivate();
return EXIT_SUCCESS;
}
示例10: appName
int
LibraryServer::run(int argc, char*[])
{
if(argc > 1)
{
cerr << appName() << ": too many arguments" << endl;
return EXIT_FAILURE;
}
Ice::PropertiesPtr properties = communicator()->getProperties();
//
// Create an object adapter
//
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Library");
//
// Create an evictor for books.
//
Freeze::EvictorPtr evictor = Freeze::createBackgroundSaveEvictor(adapter, _envName, "books");
Ice::Int evictorSize = properties->getPropertyAsInt("EvictorSize");
if(evictorSize > 0)
{
evictor->setSize(evictorSize);
}
//
// Use the evictor as servant Locator.
//
adapter->addServantLocator(evictor, "book");
//
// Create the library, and add it to the object adapter.
//
LibraryIPtr library = new LibraryI(communicator(), _envName, "authors", evictor);
adapter->add(library, Ice::stringToIdentity("library"));
//
// Create and install a factory for books.
//
Ice::ValueFactoryPtr bookFactory = new BookFactory(library);
communicator()->getValueFactoryManager()->add(bookFactory, Demo::Book::ice_staticId());
//
// Everything ok, let's go.
//
shutdownOnInterrupt();
adapter->activate();
communicator()->waitForShutdown();
ignoreInterrupt();
return EXIT_SUCCESS;
}
示例11: allTests
int
TestServer::run(int argc, char* argv[])
{
communicator()->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000");
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("TestAdapter");
ServantLocatorPtr locator = new ServantLocatorI;
adapter->addServantLocator(locator, "");
TestIntfPrx allTests(const CommunicatorPtr&);
allTests(communicator());
adapter->waitForDeactivate();
return EXIT_SUCCESS;
}
示例12: allTests
void
Collocated::run(int argc, char** argv)
{
Ice::CommunicatorHolder communicator = initialize(argc, argv);
communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint());
//
// 2 threads are necessary to dispatch the collocated transient() call with AMI
//
communicator->getProperties()->setProperty("TestAdapter.ThreadPool.Size", "2");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
ServantLocatorPtr locator = ICE_MAKE_SHARED(ServantLocatorI);
adapter->addServantLocator(locator, "");
TestIntfPrxPtr allTests(TestHelper*);
allTests(this);
adapter->waitForDeactivate();
}
示例13: ule
//.........这里部分代码省略.........
{
Ice::Print printer(communicator->getLogger());
printer << ex;
}
}
adapter->remove(communicator->stringToIdentity("x"));
try
{
adapter->remove(communicator->stringToIdentity("x"));
test(false);
}
catch(const Ice::NotRegisteredException& ex)
{
if(printException)
{
Ice::Print printer(communicator->getLogger());
printer << ex;
}
}
adapter->deactivate();
}
cout << "ok" << endl;
cout << "testing servant locator registrations exceptions... " << flush;
{
string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ?
"127.0.0.1" : "\"0:0:0:0:0:0:0:1\"";
communicator->getProperties()->setProperty("TestAdapter2.Endpoints", "default -h " + host);
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter2");
Ice::ServantLocatorPtr loc = new ServantLocatorI;
adapter->addServantLocator(loc, "x");
try
{
adapter->addServantLocator(loc, "x");
test(false);
}
catch(const Ice::AlreadyRegisteredException&)
{
}
adapter->deactivate();
}
cout << "ok" << endl;
cout << "testing object factory registration exception... " << flush;
{
Ice::ObjectFactoryPtr of = new ObjectFactoryI;
communicator->addObjectFactory(of, "x");
try
{
communicator->addObjectFactory(of, "x");
test(false);
}
catch(const Ice::AlreadyRegisteredException&)
{
}
}
cout << "ok" << endl;
cout << "testing stringToProxy... " << flush;
string ref = "thrower:default -p 12010";
Ice::ObjectPrx base = communicator->stringToProxy(ref);
test(base);
示例14: runParser
int
PhoneBookCollocated::run(int argc, char* argv[])
{
Ice::PropertiesPtr properties = communicator()->getProperties();
//
// Create and install a factory for contacts.
//
ContactFactoryPtr contactFactory = new ContactFactory();
communicator()->addObjectFactory(contactFactory, Demo::Contact::ice_staticId());
//
// Create the name index.
//
NameIndexPtr index = new NameIndex("name");
vector<Freeze::IndexPtr> indices;
indices.push_back(index);
//
// Create an object adapter, use the evictor as servant locator.
//
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("PhoneBook");
//
// Create an evictor for contacts.
//
// When Freeze.Evictor.db.contacts.PopulateEmptyIndices is not 0
// and the Name index is empty, Freeze will traverse the database
// to recreate the index during createXXXEvictor(). Therefore the
// factories for the objects stored in evictor (contacts here)
// must be registered before the call to createXXXEvictor().
//
Freeze::EvictorPtr evictor = Freeze::createBackgroundSaveEvictor(adapter, _envName, "contacts", 0, indices);
adapter->addServantLocator(evictor, "contact");
Ice::Int evictorSize = properties->getPropertyAsInt("EvictorSize");
if(evictorSize > 0)
{
evictor->setSize(evictorSize);
}
//
// Completes the initialization of the contact factory. Note that ContactI/
// ContactFactoryI uses this evictor only when a Contact is destroyed,
// which cannot happen during createXXXEvictor().
//
contactFactory->setEvictor(evictor);
//
// Create the phonebook, and add it to the Object Adapter.
//
PhoneBookIPtr phoneBook = new PhoneBookI(evictor, contactFactory, index);
adapter->add(phoneBook, communicator()->stringToIdentity("phonebook"));
//
// Everything ok, let's go.
//
int runParser(int, char*[], const Ice::CommunicatorPtr&);
int status = runParser(argc, argv, communicator());
adapter->destroy();
return status;
}
示例15: db
int
WarehouseServer::run(int argc, char* argv[])
{
bool useSimpleEvictor = argc > 1 && string(argv[1]) == "simple";
if(useSimpleEvictor)
{
cout << "Using SimpleEvictor" << endl;
}
else
{
cout << "Using Evictor implemented with IceUtil::Cache" << endl;
}
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Warehouse");
const string envName = "db";
const string dbName = "items";
{
//
// Open our database, a Freeze dictionary.
//
Freeze::ConnectionPtr connection = Freeze::createConnection(communicator(), envName);
Database db(connection, dbName);
if(db.empty())
{
cout << "Creating new database..." << flush;
//
// Populate database with objectCount entries.
//
ItemInfo info;
connection->beginTransaction();
for(int i = 0; i < objectCount; ++i)
{
ostringstream os;
os << "P/N " << i;
string name = os.str();
info.description = "The description of " + name;
info.unitPrice = i + 0.95f;
info.quantityInStock = i;
info.filler = string(5000, 'x');
db.put(Database::value_type(name, info));
}
connection->currentTransaction()->commit();
cout << "done" << endl;
}
}
CurrentDatabase currentDb(communicator(), envName, dbName);
//
// This servant locator (evictor) will intercept all categories.
//
if(useSimpleEvictor)
{
adapter->addServantLocator(new SimpleEvictor(currentDb, evictorSize), "");
}
else
{
adapter->addServantLocator(new Evictor(currentDb, evictorSize), "");
}
adapter->activate();
communicator()->waitForShutdown();
return EXIT_SUCCESS;
}