summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Henriksen <austin.r.henriksen79@gmail.com>2018-09-19 10:56:16 -0400
committerGitHub <noreply@github.com>2018-09-19 10:56:16 -0400
commitf71fcb1ab9477721b5599b7b76dff498841ce10f (patch)
tree9b15158398b416d16126de313ed69315d43caf7b
parentFix slice2objc bogus generated code for Ice::Value data member (diff)
downloadice-f71fcb1ab9477721b5599b7b76dff498841ce10f.tar.bz2
ice-f71fcb1ab9477721b5599b7b76dff498841ce10f.tar.xz
ice-f71fcb1ab9477721b5599b7b76dff498841ce10f.zip
Removed Application from Ice Services (#196)
Removed Application from Ice services, fixes #50
-rw-r--r--cpp/src/IceBox/Admin.cpp117
-rw-r--r--cpp/src/IceGrid/Client.cpp428
-rw-r--r--cpp/src/IcePatch2/Client.cpp140
-rw-r--r--cpp/src/IceStorm/Admin.cpp112
-rw-r--r--cpp/src/IceStorm/IceStormDB.cpp153
-rw-r--r--cpp/src/icegriddb/IceGridDB.cpp182
-rw-r--r--cpp/src/iceserviceinstall/Install.cpp213
-rw-r--r--java-compat/src/Ice/src/main/java/Ice/AMD_Object_ice_invoke.java3
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/Ice/OutputStream.java4
-rw-r--r--scripts/Util.py9
-rw-r--r--slice/Ice/Communicator.ice2
11 files changed, 666 insertions, 697 deletions
diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp
index e6fcb866ae6..e679c1ed9f2 100644
--- a/cpp/src/IceBox/Admin.cpp
+++ b/cpp/src/IceBox/Admin.cpp
@@ -7,44 +7,57 @@
//
// **********************************************************************
-#include <Ice/Application.h>
+#include <Ice/Ice.h>
#include <Ice/SliceChecksums.h>
#include <Ice/ConsoleUtil.h>
#include <IceUtil/Options.h>
#include <IceBox/IceBox.h>
using namespace std;
-using namespace Ice;
using namespace IceInternal;
-class Client : public Ice::Application
-{
-public:
+int run(const Ice::StringSeq&);
- void usage();
- virtual int run(int, char*[]);
-};
+Ice::CommunicatorPtr communicator;
-#ifdef _WIN32
+void
+destroyCommunicator(int)
+{
+ communicator->destroy();
+}
int
+#ifdef _WIN32
wmain(int argc, wchar_t* argv[])
-
#else
-
-int
main(int argc, char* argv[])
-
#endif
{
- Client app;
- return app.main(argc, argv);
+ int status = 0;
+
+ try
+ {
+ Ice::CtrlCHandler ctrlCHandler;
+ Ice::CommunicatorHolder ich(argc, argv);
+ communicator = ich.communicator();
+
+ ctrlCHandler.setCallback(&destroyCommunicator);
+
+ status = run(Ice::argsToStringSeq(argc, argv));
+ }
+ catch(const std::exception& ex)
+ {
+ consoleErr << ex.what() << endl;
+ status = 1;
+ }
+
+ return status;
}
void
-Client::usage()
+usage(const string& name)
{
- consoleErr << "Usage: " << appName() << " [options] [command...]\n";
+ consoleErr << "Usage: " << name << " [options] [command...]\n";
consoleErr <<
"Options:\n"
"-h, --help Show this message.\n"
@@ -58,7 +71,7 @@ Client::usage()
}
int
-Client::run(int argc, char* argv[])
+run(const Ice::StringSeq& args)
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
@@ -67,33 +80,33 @@ Client::run(int argc, char* argv[])
vector<string> commands;
try
{
- commands = opts.parse(argc, const_cast<const char**>(argv));
+ commands = opts.parse(args);
}
catch(const IceUtilInternal::BadOptException& e)
{
consoleErr << e.reason << endl;
- usage();
- return EXIT_FAILURE;
+ usage(args[0]);
+ return 1;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage(args[0]);
+ return 0;
}
if(opts.isSet("version"))
{
consoleOut << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ return 0;
}
if(commands.empty())
{
- usage();
- return EXIT_FAILURE;
+ usage(args[0]);
+ return 1;
}
- ObjectPrxPtr base = communicator()->propertyToProxy("IceBoxAdmin.ServiceManager.Proxy");
+ Ice::ObjectPrxPtr base = communicator->propertyToProxy("IceBoxAdmin.ServiceManager.Proxy");
if(base == 0)
{
@@ -101,9 +114,9 @@ Client::run(int argc, char* argv[])
// The old deprecated way to retrieve the service manager proxy
//
- PropertiesPtr properties = communicator()->getProperties();
+ Ice::PropertiesPtr properties = communicator->getProperties();
- Identity managerIdentity;
+ Ice::Identity managerIdentity;
managerIdentity.category = properties->getPropertyWithDefault("IceBox.InstanceName", "IceBox");
managerIdentity.name = "ServiceManager";
@@ -113,32 +126,32 @@ Client::run(int argc, char* argv[])
string managerEndpoints = properties->getProperty("IceBox.ServiceManager.Endpoints");
if(managerEndpoints.empty())
{
- consoleErr << appName() << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
+ return 1;
}
- managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" :" + managerEndpoints;
+ managerProxy = "\"" + communicator->identityToString(managerIdentity) + "\" :" + managerEndpoints;
}
else
{
string managerAdapterId = properties->getProperty("IceBox.ServiceManager.AdapterId");
if(managerAdapterId.empty())
{
- consoleErr << appName() << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": property `IceBoxAdmin.ServiceManager.Proxy' is not set" << endl;
+ return 1;
}
- managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" @" + managerAdapterId;
+ managerProxy = "\"" + communicator->identityToString(managerIdentity) + "\" @" + managerAdapterId;
}
- base = communicator()->stringToProxy(managerProxy);
+ base = communicator->stringToProxy(managerProxy);
}
IceBox::ServiceManagerPrxPtr manager = ICE_CHECKED_CAST(IceBox::ServiceManagerPrx, base);
if(!manager)
{
- consoleErr << appName() << ": `" << base << "' is not an IceBox::ServiceManager" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": `" << base << "' is not an IceBox::ServiceManager" << endl;
+ return 1;
}
for(vector<string>::const_iterator r = commands.begin(); r != commands.end(); ++r)
@@ -151,8 +164,8 @@ Client::run(int argc, char* argv[])
{
if(++r == commands.end())
{
- consoleErr << appName() << ": no service name specified." << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": no service name specified." << endl;
+ return 1;
}
try
@@ -161,20 +174,20 @@ Client::run(int argc, char* argv[])
}
catch(const IceBox::NoSuchServiceException&)
{
- consoleErr << appName() << ": unknown service `" << *r << "'" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": unknown service `" << *r << "'" << endl;
+ return 1;
}
catch(const IceBox::AlreadyStartedException&)
{
- consoleErr << appName() << ": service already started." << endl;
+ consoleErr << args[0] << ": service already started." << endl;
}
}
else if((*r) == "stop")
{
if(++r == commands.end())
{
- consoleErr << appName() << ": no service name specified." << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": no service name specified." << endl;
+ return 1;
}
try
@@ -183,21 +196,21 @@ Client::run(int argc, char* argv[])
}
catch(const IceBox::NoSuchServiceException&)
{
- consoleErr << appName() << ": unknown service `" << *r << "'" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": unknown service `" << *r << "'" << endl;
+ return 1;
}
catch(const IceBox::AlreadyStoppedException&)
{
- consoleErr << appName() << ": service already stopped." << endl;
+ consoleErr << args[0] << ": service already stopped." << endl;
}
}
else
{
- consoleErr << appName() << ": unknown command `" << *r << "'" << endl;
- usage();
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": unknown command `" << *r << "'" << endl;
+ usage(args[0]);
+ return 1;
}
}
- return EXIT_SUCCESS;
+ return 0;
}
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index de5e2ebc1a2..604c042d173 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -36,10 +36,7 @@
#endif
using namespace std;
-using namespace Ice;
using namespace IceInternal;
-using namespace IceLocatorDiscovery;
-using namespace IceGrid;
class Client;
@@ -47,7 +44,8 @@ namespace
{
IceUtil::Mutex* _staticMutex = 0;
-Client* _globalClient = 0;
+Ice::CommunicatorPtr communicator;
+IceGrid::ParserPtr parser;
class Init
{
@@ -73,7 +71,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I
{
public:
- SessionKeepAliveThread(const AdminSessionPrx& session, long timeout) :
+ SessionKeepAliveThread(const IceGrid::AdminSessionPrx& session, long timeout) :
IceUtil::Thread("IceGrid admin session keepalive thread"),
_session(session),
_timeout(IceUtil::Time::seconds(timeout)),
@@ -96,7 +94,7 @@ public:
{
_session->keepAlive();
}
- catch(const Exception&)
+ catch(const Ice::Exception&)
{
break;
}
@@ -113,84 +111,74 @@ public:
private:
- AdminSessionPrx _session;
+ IceGrid::AdminSessionPrx _session;
const IceUtil::Time _timeout;
bool _destroy;
};
typedef IceUtil::Handle<SessionKeepAliveThread> SessionKeepAliveThreadPtr;
-class ReuseConnectionRouter : public Router
+class ReuseConnectionRouter : public Ice::Router
{
public:
- ReuseConnectionRouter(const ObjectPrx& proxy) : _clientProxy(proxy)
+ ReuseConnectionRouter(const Ice::ObjectPrx& proxy) : _clientProxy(proxy)
{
}
- virtual ObjectPrx
- getClientProxy(IceUtil::Optional<bool>& hasRoutingTable, const Current&) const
+ virtual Ice::ObjectPrx
+ getClientProxy(IceUtil::Optional<bool>& hasRoutingTable, const Ice::Current&) const
{
hasRoutingTable = false;
return _clientProxy;
}
- virtual ObjectPrx
- getServerProxy(const Current&) const
+ virtual Ice::ObjectPrx
+ getServerProxy(const Ice::Current&) const
{
return 0;
}
virtual void
- addProxy(const ObjectPrx&, const Current&)
+ addProxy(const Ice::ObjectPrx&, const Ice::Current&)
{
}
- virtual ObjectProxySeq
- addProxies(const ObjectProxySeq&, const Current&)
+ virtual Ice::ObjectProxySeq
+ addProxies(const Ice::ObjectProxySeq&, const Ice::Current&)
{
- return ObjectProxySeq();
+ return Ice::ObjectProxySeq();
}
private:
- const ObjectPrx _clientProxy;
+ const Ice::ObjectPrx _clientProxy;
};
-class Client : public IceUtil::Monitor<IceUtil::Mutex>
-{
-public:
-
- void usage();
- int main(StringSeq& args);
- int run(StringSeq& args);
- void interrupted();
-
- CommunicatorPtr communicator() const { return _communicator; }
- const string& appName() const { return _appName; }
-
- string getPassword(const string&);
-
-private:
-
- IceUtil::CtrlCHandler _ctrlCHandler;
- CommunicatorPtr _communicator;
- string _appName;
- ParserPtr _parser;
-};
+int run(const Ice::StringSeq&);
+//
+// Callback for CtrlCHandler
+//
static void
interruptCallback(int /*signal*/)
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(_staticMutex);
- if(_globalClient)
+ if(parser) // If there's an interactive parser, notify the parser.
+ {
+ parser->interrupt();
+ }
+ else
{
- _globalClient->interrupted();
+ //
+ // Otherwise, destroy the communicator.
+ //
+ assert(communicator);
+ communicator->destroy();
}
}
-#ifdef _WIN32
-
int
+#ifdef _WIN32
wmain(int argc, wchar_t* argv[])
{
//
@@ -198,121 +186,104 @@ wmain(int argc, wchar_t* argv[])
//
_setmode(_fileno(stdin), _O_BINARY);
#else
-
-int
main(int argc, char* argv[])
{
#endif
- Client app;
- StringSeq args = argsToStringSeq(argc, argv);
- return app.main(args);
-}
-
-void
-Client::usage()
-{
- consoleErr << "Usage: " << appName() << " [options]\n";
- consoleErr <<
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "-e COMMANDS Execute COMMANDS.\n"
- "-d, --debug Print debug messages.\n"
- "-s, --server Start icegridadmin as a server (to parse XML files).\n"
- "-i, --instanceName Connect to the registry with the given instance name.\n"
- "-H, --host Connect to the registry at the given host.\n"
- "-P, --port Connect to the registry running on the given port.\n"
- "-u, --username Login with the given username.\n"
- "-p, --password Login with the given password.\n"
- "-S, --ssl Authenticate through SSL.\n"
- "-r, --replica NAME Connect to the replica NAME.\n"
- ;
-}
-
-extern "C" ICE_LOCATOR_DISCOVERY_API Ice::Plugin*
-createIceLocatorDiscovery(const Ice::CommunicatorPtr&, const string&, const Ice::StringSeq&);
-
-int
-Client::main(StringSeq& args)
-{
- int status = EXIT_SUCCESS;
+ int status = 0;
+ Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
try
{
- _appName = args[0];
- PropertiesPtr defaultProps = createProperties();
+ Ice::CtrlCHandler ctrlCHandler;
+ Ice::PropertiesPtr defaultProps = Ice::createProperties();
defaultProps->setProperty("IceGridAdmin.Server.Endpoints", "tcp -h localhost");
- InitializationData id;
+ Ice::InitializationData id;
id.properties = createProperties(args, defaultProps);
id.properties->setProperty("Ice.Warn.Endpoints", "0");
- _communicator = initialize(id);
+ Ice::CommunicatorHolder ich(id);
+ communicator = ich.communicator();
- {
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(_staticMutex);
- _globalClient = this;
- }
- _ctrlCHandler.setCallback(interruptCallback);
+ ctrlCHandler.setCallback(interruptCallback);
try
{
status = run(args);
}
- catch(const CommunicatorDestroyedException&)
+ catch(const Ice::CommunicatorDestroyedException&)
{
// Expected if the client is interrupted during the initialization.
}
}
catch(const IceUtil::Exception& ex)
{
- consoleErr << _appName << ": " << ex << endl;
- status = EXIT_FAILURE;
+ consoleErr << args[0] << ": " << ex << endl;
+ status = 1;
}
catch(const std::exception& ex)
{
- consoleErr << _appName << ": std::exception: " << ex.what() << endl;
- status = EXIT_FAILURE;
+ consoleErr << args[0] << ": std::exception: " << ex.what() << endl;
+ status = 1;
}
catch(...)
{
- consoleErr << _appName << ": unknown exception" << endl;
- status = EXIT_FAILURE;
- }
-
- if(_communicator)
- {
- _communicator->destroy();
- }
-
- _ctrlCHandler.setCallback(0);
- {
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(_staticMutex);
- _globalClient = 0;
+ consoleErr << args[0] << ": unknown exception" << endl;
+ status = 1;
}
return status;
-
}
void
-Client::interrupted()
+usage(const string& name)
{
- Lock sync(*this);
- if(_parser) // If there's an interactive parser, notify the parser.
- {
- _parser->interrupt();
- }
- else
+ consoleErr << "Usage: " << name << " [options]\n";
+ consoleErr <<
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "-e COMMANDS Execute COMMANDS.\n"
+ "-d, --debug Print debug messages.\n"
+ "-s, --server Start icegridadmin as a server (to parse XML files).\n"
+ "-i, --instanceName Connect to the registry with the given instance name.\n"
+ "-H, --host Connect to the registry at the given host.\n"
+ "-P, --port Connect to the registry running on the given port.\n"
+ "-u, --username Login with the given username.\n"
+ "-p, --password Login with the given password.\n"
+ "-S, --ssl Authenticate through SSL.\n"
+ "-r, --replica NAME Connect to the replica NAME.\n"
+ ;
+}
+
+string
+getPassword(const string& prompt)
+{
+ consoleOut << prompt << flush;
+ string password;
+#ifndef _WIN32
+ struct termios oldConf;
+ struct termios newConf;
+ tcgetattr(0, &oldConf);
+ newConf = oldConf;
+ newConf.c_lflag &= (~ECHO);
+ tcsetattr(0, TCSANOW, &newConf);
+ getline(cin, password);
+ tcsetattr(0, TCSANOW, &oldConf);
+#else
+ char c;
+ while((c = _getch()) != '\r')
{
- //
- // Otherwise, destroy the communicator.
- //
- assert(_communicator);
- _communicator->destroy();
+ password += c;
}
+#endif
+ consoleOut << endl;
+ return IceUtilInternal::trim(password);
}
+extern "C" ICE_LOCATOR_DISCOVERY_API Ice::Plugin*
+createIceLocatorDiscovery(const Ice::CommunicatorPtr&, const string&, const Ice::StringSeq&);
+
int
-Client::run(StringSeq& originalArgs)
+run(const Ice::StringSeq& args)
{
string commands;
bool debug;
@@ -331,45 +302,43 @@ Client::run(StringSeq& originalArgs)
opts.addOpt("s", "server");
opts.addOpt("r", "replica", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::NoRepeat);
- vector<string> args;
try
{
- args = opts.parse(originalArgs);
+ if(!opts.parse(args).empty())
+ {
+ consoleErr << args[0] << ": too many arguments" << endl;
+ usage(args[0]);
+ return 1;
+ }
}
catch(const IceUtilInternal::BadOptException& e)
{
consoleErr << e.reason << endl;
- usage();
- return EXIT_FAILURE;
- }
- if(!args.empty())
- {
- consoleErr << _appName << ": too many arguments" << endl;
- usage();
- return EXIT_FAILURE;
+ usage(args[0]);
+ return 1;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage(args[0]);
+ return 0;
}
if(opts.isSet("version"))
{
consoleOut << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ return 0;
}
if(opts.isSet("server"))
{
- ObjectAdapterPtr adapter =
- communicator()->createObjectAdapter("IceGridAdmin.Server");
+ Ice::ObjectAdapterPtr adapter =
+ communicator->createObjectAdapter("IceGridAdmin.Server");
adapter->activate();
- ObjectPrx proxy = adapter->add(new FileParserI, stringToIdentity("FileParser"));
+ Ice::ObjectPrx proxy = adapter->add(new FileParserI, Ice::stringToIdentity("FileParser"));
consoleOut << proxy << endl;
- communicator()->waitForShutdown();
- return EXIT_SUCCESS;
+ communicator->waitForShutdown();
+ return 0;
}
if(opts.isSet("e"))
@@ -382,47 +351,47 @@ Client::run(StringSeq& originalArgs)
}
debug = opts.isSet("debug");
- bool ssl = communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL") > 0;
+ bool ssl = communicator->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL") > 0;
if(opts.isSet("ssl"))
{
ssl = true;
}
- string id = communicator()->getProperties()->getProperty("IceGridAdmin.Username");
+ string id = communicator->getProperties()->getProperty("IceGridAdmin.Username");
if(!opts.optArg("username").empty())
{
id = opts.optArg("username");
}
- string password = communicator()->getProperties()->getProperty("IceGridAdmin.Password");
+ string password = communicator->getProperties()->getProperty("IceGridAdmin.Password");
if(!opts.optArg("password").empty())
{
password = opts.optArg("password");
}
- string host = communicator()->getProperties()->getProperty("IceGridAdmin.Host");
+ string host = communicator->getProperties()->getProperty("IceGridAdmin.Host");
if(!opts.optArg("host").empty())
{
host = opts.optArg("host");
}
- string instanceName = communicator()->getProperties()->getProperty("IceGridAdmin.InstanceName");
+ string instanceName = communicator->getProperties()->getProperty("IceGridAdmin.InstanceName");
if(!opts.optArg("instanceName").empty())
{
instanceName = opts.optArg("instanceName");
}
- int port = communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.Port");
+ int port = communicator->getProperties()->getPropertyAsInt("IceGridAdmin.Port");
if(!opts.optArg("port").empty())
{
istringstream is(opts.optArg("port"));
if(!(is >> port))
{
- consoleErr << _appName << ": given port number is not a numeric value" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": given port number is not a numeric value" << endl;
+ return 1;
}
}
- PropertiesPtr properties = communicator()->getProperties();
+ Ice::PropertiesPtr properties = communicator->getProperties();
string replica = properties->getProperty("IceGridAdmin.Replica");
if(!opts.optArg("replica").empty())
{
@@ -430,14 +399,14 @@ Client::run(StringSeq& originalArgs)
}
Glacier2::RouterPrx router;
- AdminSessionPrx session;
+ IceGrid::AdminSessionPrx session;
SessionKeepAliveThreadPtr keepAlive;
- int status = EXIT_SUCCESS;
+ int status = 0;
try
{
int sessionTimeout;
int acmTimeout = 0;
- if(!communicator()->getDefaultLocator() && !communicator()->getDefaultRouter())
+ if(!communicator->getDefaultLocator() && !communicator->getDefaultRouter())
{
if(!host.empty())
{
@@ -446,21 +415,21 @@ Client::run(StringSeq& originalArgs)
os << "Ice/LocatorFinder" << (ssl ? " -s" : "");
os << ":tcp -h \"" << host << "\" -p " << (port == 0 ? 4061 : port) << " -t " << timeout;
os << ":ssl -h \"" << host << "\" -p " << (port == 0 ? 4062 : port) << " -t " << timeout;
- LocatorFinderPrx finder = LocatorFinderPrx::uncheckedCast(communicator()->stringToProxy(os.str()));
+ Ice::LocatorFinderPrx finder = Ice::LocatorFinderPrx::uncheckedCast(communicator->stringToProxy(os.str()));
try
{
- communicator()->setDefaultLocator(finder->getLocator());
+ communicator->setDefaultLocator(finder->getLocator());
}
catch(const Ice::LocalException&)
{
// Ignore.
}
if(!instanceName.empty() &&
- communicator()->getDefaultLocator()->ice_getIdentity().category != instanceName)
+ communicator->getDefaultLocator()->ice_getIdentity().category != instanceName)
{
- consoleErr << _appName << ": registry running on `" << host << "' uses a different instance name:\n";
- consoleErr << communicator()->getDefaultLocator()->ice_getIdentity().category << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": registry running on `" << host << "' uses a different instance name:\n";
+ consoleErr << communicator->getDefaultLocator()->ice_getIdentity().category << endl;
+ return 1;
}
}
else
@@ -471,7 +440,7 @@ Client::run(StringSeq& originalArgs)
// to lookup for locator proxies. We destroy the plugin, once we have selected a
// locator.
//
- Ice::PluginPtr p = createIceLocatorDiscovery(communicator(), "IceGridAdmin.Discovery", Ice::StringSeq());
+ Ice::PluginPtr p = createIceLocatorDiscovery(communicator, "IceGridAdmin.Discovery", Ice::StringSeq());
IceLocatorDiscovery::PluginPtr plugin = IceLocatorDiscovery::PluginPtr::dynamicCast(p);
plugin->initialize();
@@ -493,7 +462,7 @@ Client::run(StringSeq& originalArgs)
getline(cin, line);
if(!cin.good() || line.empty())
{
- return EXIT_FAILURE;
+ return 1;
}
line = IceUtilInternal::trim(line);
@@ -506,16 +475,16 @@ Client::run(StringSeq& originalArgs)
}
assert(num <= locators.size());
- communicator()->setDefaultLocator(locators[num - 1]);
+ communicator->setDefaultLocator(locators[num - 1]);
}
else if(locators.size() == 1)
{
consoleOut << "using discovered locator:\nproxy = `" << locators[0] << "'" << endl;
- communicator()->setDefaultLocator(locators[0]);
+ communicator->setDefaultLocator(locators[0]);
}
else
{
- communicator()->setDefaultLocator(0);
+ communicator->setDefaultLocator(0);
}
//
@@ -525,33 +494,33 @@ Client::run(StringSeq& originalArgs)
}
}
- if(communicator()->getDefaultRouter())
+ if(communicator->getDefaultRouter())
{
try
{
// Use SSL if available.
- router = Glacier2::RouterPrx::checkedCast(communicator()->getDefaultRouter()->ice_preferSecure(true));
+ router = Glacier2::RouterPrx::checkedCast(communicator->getDefaultRouter()->ice_preferSecure(true));
if(!router)
{
- consoleErr << _appName << ": configured router is not a Glacier2 router" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": configured router is not a Glacier2 router" << endl;
+ return 1;
}
}
- catch(const LocalException& ex)
+ catch(const Ice::LocalException& ex)
{
- consoleErr << _appName << ": could not contact the default router:" << endl << ex << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": could not contact the default router:" << endl << ex << endl;
+ return 1;
}
if(ssl)
{
- session = AdminSessionPrx::uncheckedCast(router->createSessionFromSecureConnection());
+ session = IceGrid::AdminSessionPrx::uncheckedCast(router->createSessionFromSecureConnection());
if(!session)
{
- consoleErr << _appName
+ consoleErr << args[0]
<< ": Glacier2 returned a null session, please set the Glacier2.SSLSessionManager property"
<< endl;
- return EXIT_FAILURE;
+ return 1;
}
}
else
@@ -562,7 +531,7 @@ Client::run(StringSeq& originalArgs)
getline(cin, id);
if(!cin.good())
{
- return EXIT_FAILURE;
+ return 1;
}
id = IceUtilInternal::trim(id);
}
@@ -573,20 +542,20 @@ Client::run(StringSeq& originalArgs)
#ifndef _WIN32
if(!cin.good())
{
- return EXIT_FAILURE;
+ return 1;
}
#endif
}
- session = AdminSessionPrx::uncheckedCast(router->createSession(id, password));
+ session = IceGrid::AdminSessionPrx::uncheckedCast(router->createSession(id, password));
fill(password.begin(), password.end(), '\0'); // Zero the password string.
if(!session)
{
- consoleErr << _appName
+ consoleErr << args[0]
<< ": Glacier2 returned a null session, please set the Glacier2.SessionManager property"
<< endl;
- return EXIT_FAILURE;
+ return 1;
}
}
sessionTimeout = static_cast<int>(router->getSessionTimeout());
@@ -598,13 +567,13 @@ Client::run(StringSeq& originalArgs)
{
}
}
- else if(communicator()->getDefaultLocator())
+ else if(communicator->getDefaultLocator())
{
//
// Create the identity of the registry to connect to.
//
- Identity registryId;
- registryId.category = communicator()->getDefaultLocator()->ice_getIdentity().category;
+ Ice::Identity registryId;
+ registryId.category = communicator->getDefaultLocator()->ice_getIdentity().category;
registryId.name = "Registry";
if(!replica.empty() && replica != "Master")
{
@@ -617,21 +586,21 @@ Client::run(StringSeq& originalArgs)
// proxy.
//
IceGrid::LocatorPrx locator;
- RegistryPrx localRegistry;
+ IceGrid::RegistryPrx localRegistry;
try
{
- locator = IceGrid::LocatorPrx::checkedCast(communicator()->getDefaultLocator());
+ locator = IceGrid::LocatorPrx::checkedCast(communicator->getDefaultLocator());
if(!locator)
{
- consoleErr << _appName << ": configured locator is not an IceGrid locator" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": configured locator is not an IceGrid locator" << endl;
+ return 1;
}
localRegistry = locator->getLocalRegistry();
}
- catch(const LocalException& ex)
+ catch(const Ice::LocalException& ex)
{
- consoleErr << _appName << ": could not contact the default locator:" << endl << ex << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": could not contact the default locator:" << endl << ex << endl;
+ return 1;
}
IceGrid::RegistryPrx registry;
@@ -647,24 +616,24 @@ Client::run(StringSeq& originalArgs)
try
{
- registry = RegistryPrx::checkedCast(locator->findObjectById(registryId));
+ registry = IceGrid::RegistryPrx::checkedCast(locator->findObjectById(registryId));
if(!registry)
{
- consoleErr << _appName << ": could not contact an IceGrid registry" << endl;
+ consoleErr << args[0] << ": could not contact an IceGrid registry" << endl;
}
}
- catch(const ObjectNotFoundException&)
+ catch(const Ice::ObjectNotFoundException&)
{
- consoleErr << _appName << ": no active registry replica named `" << replica << "'" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": no active registry replica named `" << replica << "'" << endl;
+ return 1;
}
- catch(const LocalException& ex)
+ catch(const Ice::LocalException& ex)
{
if(!replica.empty())
{
- consoleErr << _appName << ": could not contact the registry replica named `" << replica << "':\n";
+ consoleErr << args[0] << ": could not contact the registry replica named `" << replica << "':\n";
consoleErr << ex << endl;
- return EXIT_FAILURE;
+ return 1;
}
else
{
@@ -679,7 +648,7 @@ Client::run(StringSeq& originalArgs)
{
name = name.substr(prefix.size());
}
- consoleErr << _appName << ": warning: could not contact master, using slave `" << name << "'" << endl;
+ consoleErr << args[0] << ": warning: could not contact master, using slave `" << name << "'" << endl;
}
}
}
@@ -691,10 +660,10 @@ Client::run(StringSeq& originalArgs)
//
if(registry->ice_getIdentity() == localRegistry->ice_getIdentity())
{
- ObjectAdapterPtr colloc = communicator()->createObjectAdapter(""); // colloc-only adapter
- ObjectPrx router = colloc->addWithUUID(new ReuseConnectionRouter(locator));
- communicator()->setDefaultRouter(RouterPrx::uncheckedCast(router));
- registry = registry->ice_router(communicator()->getDefaultRouter());
+ Ice::ObjectAdapterPtr colloc = communicator->createObjectAdapter(""); // colloc-only adapter
+ Ice::ObjectPrx router = colloc->addWithUUID(new ReuseConnectionRouter(locator));
+ communicator->setDefaultRouter(Ice::RouterPrx::uncheckedCast(router));
+ registry = registry->ice_router(communicator->getDefaultRouter());
}
// Prefer SSL.
@@ -712,7 +681,7 @@ Client::run(StringSeq& originalArgs)
getline(cin, id);
if(!cin.good())
{
- return EXIT_FAILURE;
+ return 1;
}
id = IceUtilInternal::trim(id);
}
@@ -723,7 +692,7 @@ Client::run(StringSeq& originalArgs)
#ifndef _WIN32
if(!cin.good())
{
- return EXIT_FAILURE;
+ return 1;
}
#endif
}
@@ -743,14 +712,14 @@ Client::run(StringSeq& originalArgs)
}
else // No default locator or router set.
{
- consoleErr << _appName << ": could not contact the registry:" << endl;
+ consoleErr << args[0] << ": could not contact the registry:" << endl;
consoleErr << "no default locator or router configured" << endl;
- return EXIT_FAILURE;
+ return 1;
}
if(acmTimeout > 0)
{
- session->ice_getConnection()->setACM(acmTimeout, IceUtil::None, ICE_ENUM(ACMHeartbeat, HeartbeatAlways));
+ session->ice_getConnection()->setACM(acmTimeout, IceUtil::None, Ice::ICE_ENUM(ACMHeartbeat, HeartbeatAlways));
}
else if(sessionTimeout > 0)
{
@@ -759,43 +728,43 @@ Client::run(StringSeq& originalArgs)
}
{
- Lock sync(*this);
- _parser = Parser::createParser(communicator(), session, session->getAdmin(), commands.empty());
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(_staticMutex);
+ parser = IceGrid::Parser::createParser(communicator, session, session->getAdmin(), commands.empty());
}
if(!commands.empty()) // Commands were given
{
- int parseStatus = _parser->parse(commands, debug);
- if(parseStatus == EXIT_FAILURE)
+ int parseStatus = parser->parse(commands, debug);
+ if(parseStatus == 1)
{
- status = EXIT_FAILURE;
+ status = 1;
}
}
else // No commands, let's use standard input
{
- _parser->showBanner();
+ parser->showBanner();
- int parseStatus = _parser->parse(stdin, debug);
- if(parseStatus == EXIT_FAILURE)
+ int parseStatus = parser->parse(stdin, debug);
+ if(parseStatus == 1)
{
- status = EXIT_FAILURE;
+ status = 1;
}
}
}
catch(const IceGrid::PermissionDeniedException& ex)
{
consoleOut << "permission denied:\n" << ex.reason << endl;
- return EXIT_FAILURE;
+ return 1;
}
catch(const Glacier2::PermissionDeniedException& ex)
{
consoleOut << "permission denied:\n" << ex.reason << endl;
- return EXIT_FAILURE;
+ return 1;
}
catch(const Glacier2::CannotCreateSessionException& ex)
{
consoleOut << "session creation failed:\n" << ex.reason << endl;
- return EXIT_FAILURE;
+ return 1;
}
catch(...)
{
@@ -816,7 +785,7 @@ Client::run(StringSeq& originalArgs)
session->destroy();
}
}
- catch(const Exception&)
+ catch(const Ice::Exception&)
{
}
throw;
@@ -841,7 +810,7 @@ Client::run(StringSeq& originalArgs)
session->destroy();
}
}
- catch(const Exception&)
+ catch(const Ice::Exception&)
{
// Ignore. If the registry has been shutdown this will cause
// an exception.
@@ -850,28 +819,3 @@ Client::run(StringSeq& originalArgs)
return status;
}
-
-string
-Client::getPassword(const string& prompt)
-{
- consoleOut << prompt << flush;
- string password;
-#ifndef _WIN32
- struct termios oldConf;
- struct termios newConf;
- tcgetattr(0, &oldConf);
- newConf = oldConf;
- newConf.c_lflag &= (~ECHO);
- tcsetattr(0, TCSANOW, &newConf);
- getline(cin, password);
- tcsetattr(0, TCSANOW, &oldConf);
-#else
- char c;
- while((c = _getch()) != '\r')
- {
- password += c;
- }
-#endif
- consoleOut << endl;
- return IceUtilInternal::trim(password);
-}
diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp
index 3027bb73b0f..1960573cc36 100644
--- a/cpp/src/IcePatch2/Client.cpp
+++ b/cpp/src/IcePatch2/Client.cpp
@@ -9,7 +9,7 @@
#include <IceUtil/Options.h>
#include <IceUtil/StringUtil.h>
-#include <Ice/Application.h>
+#include <Ice/Ice.h>
#include <Ice/ConsoleUtil.h>
#include <IcePatch2Lib/Util.h>
#include <IcePatch2/ClientUtil.h>
@@ -22,12 +22,9 @@
#endif
using namespace std;
-using namespace Ice;
using namespace IceInternal;
-using namespace IcePatch2;
-using namespace IcePatch2Internal;
-class TextPatcherFeedback : public PatcherFeedback
+class TextPatcherFeedback : public IcePatch2::PatcherFeedback
{
public:
@@ -83,7 +80,7 @@ public:
virtual bool
checksumProgress(const string& path)
{
- consoleOut << "Calculating checksum for " << getBasename(path) << endl;
+ consoleOut << "Calculating checksum for " << IcePatch2Internal::getBasename(path) << endl;
return !keyPressed();
}
@@ -108,7 +105,7 @@ public:
}
virtual bool
- fileListProgress(Int percent)
+ fileListProgress(Ice::Int percent)
{
for(unsigned int i = 0; i < _lastProgress.size(); ++i)
{
@@ -129,7 +126,7 @@ public:
}
virtual bool
- patchStart(const string& path, Long size, Long totalProgress, Long totalSize)
+ patchStart(const string& path, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize)
{
if(!_pressAnyKeyMessage)
{
@@ -140,12 +137,12 @@ public:
ostringstream s;
s << "0/" << size << " (" << totalProgress << '/' << totalSize << ')';
_lastProgress = s.str();
- consoleOut << getBasename(path) << ' ' << _lastProgress << flush;
+ consoleOut << IcePatch2Internal::getBasename(path) << ' ' << _lastProgress << flush;
return !keyPressed();
}
virtual bool
- patchProgress(Long progress, Long size, Long totalProgress, Long totalSize)
+ patchProgress(Ice::Long progress, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize)
{
for(unsigned int i = 0; i < _lastProgress.size(); ++i)
{
@@ -255,71 +252,111 @@ private:
bool _pressAnyKeyMessage;
};
-class Client : public Ice::Application
+int run(const Ice::StringSeq&);
+
+Ice::CommunicatorPtr communicator;
+
+void
+destroyCommunicator(int)
{
-public:
+ communicator->destroy();
+}
- virtual int run(int, char*[]);
+int
+#ifdef _WIN32
+wmain(int argc, wchar_t* argv[])
+#else
+main(int argc, char* argv[])
+#endif
+{
+ int status = 0;
-private:
+ try
+ {
+ Ice::CtrlCHandler ctrlCHandler;
+ Ice::CommunicatorHolder ich(argc, argv);
+ communicator = ich.communicator();
- void usage(const std::string&);
-};
+ ctrlCHandler.setCallback(&destroyCommunicator);
+
+ status = run(Ice::argsToStringSeq(argc, argv));
+ }
+ catch(const std::exception& ex)
+ {
+ consoleErr << ex.what() << endl;
+ status = 1;
+ }
+
+ return status;
+}
+
+void
+usage(const string& appName)
+{
+ string options =
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "-t, --thorough Recalculate all checksums.";
+
+ consoleErr << "Usage: " << appName << " [options] [DIR]" << endl;
+ consoleErr << options << endl;
+}
int
-Client::run(int argc, char* argv[])
+run(const Ice::StringSeq& args)
{
- PropertiesPtr properties = communicator()->getProperties();
+ Ice::PropertiesPtr properties = communicator->getProperties();
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("t", "thorough");
- vector<string> args;
+ vector<string> props;
try
{
- args = opts.parse(argc, const_cast<const char**>(argv));
+ props = opts.parse(args);
}
catch(const IceUtilInternal::BadOptException& e)
{
consoleErr << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(args[0]);
+ return 1;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(args[0]);
+ return 0;
}
if(opts.isSet("version"))
{
consoleOut << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ return 0;
}
if(opts.isSet("thorough"))
{
properties->setProperty("IcePatch2Client.Thorough", "1");
}
- if(args.size() > 1)
+ if(props.size() > 1)
{
- consoleErr << argv[0] << ": too many arguments" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": too many arguments" << endl;
+ usage(args[0]);
+ return 1;
}
- if(args.size() == 1)
+ if(props.size() == 1)
{
- properties->setProperty("IcePatch2Client.Directory", simplify(args[0]));
+ properties->setProperty("IcePatch2Client.Directory", IcePatch2Internal::simplify(props[0]));
}
bool aborted = false;
try
{
- PatcherFeedbackPtr feedback = new TextPatcherFeedback;
- PatcherPtr patcher = PatcherFactory::create(communicator(), feedback);
+ IcePatch2::PatcherFeedbackPtr feedback = new TextPatcherFeedback;
+ IcePatch2::PatcherPtr patcher = IcePatch2::PatcherFactory::create(communicator, feedback);
aborted = !patcher->prepare();
@@ -335,46 +372,17 @@ Client::run(int argc, char* argv[])
}
catch(const exception& ex)
{
- consoleErr << argv[0] << ": " << ex.what() << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": " << ex.what() << endl;
+ return 1;
}
if(aborted)
{
consoleOut << "\n[Aborted]" << endl;
- return EXIT_FAILURE;
+ return 1;
}
else
{
- return EXIT_SUCCESS;
+ return 0;
}
}
-
-void
-Client::usage(const string& appName)
-{
- string options =
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "-t, --thorough Recalculate all checksums.";
-
- consoleErr << "Usage: " << appName << " [options] [DIR]" << endl;
- consoleErr << options << endl;
-}
-
-#ifdef _WIN32
-
-int
-wmain(int argc, wchar_t* argv[])
-
-#else
-
-int
-main(int argc, char* argv[])
-
-#endif
-{
- Client app;
- return app.main(argc, argv);
-}
diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp
index 4a074d50f31..79f85986e0c 100644
--- a/cpp/src/IceStorm/Admin.cpp
+++ b/cpp/src/IceStorm/Admin.cpp
@@ -8,7 +8,7 @@
// **********************************************************************
#include <IceUtil/Options.h>
-#include <Ice/Application.h>
+#include <Ice/Ice.h>
#include <Ice/ConsoleUtil.h>
#include <Ice/SliceChecksums.h>
#include <IceStorm/Parser.h>
@@ -19,21 +19,20 @@
#endif
using namespace std;
-using namespace Ice;
using namespace IceInternal;
-using namespace IceStorm;
-class Client : public Ice::Application
-{
-public:
+int run(const Ice::StringSeq&);
- void usage();
- virtual int run(int, char*[]);
-};
+Ice::CommunicatorPtr communicator;
-#ifdef _WIN32
+void
+destroyCommunicator(int)
+{
+ communicator->destroy();
+}
int
+#ifdef _WIN32
wmain(int argc, wchar_t* argv[])
{
//
@@ -41,24 +40,39 @@ wmain(int argc, wchar_t* argv[])
//
_setmode(_fileno(stdin), _O_BINARY);
#else
-
-int
main(int argc, char* argv[])
{
#endif
- Client app;
- Ice::InitializationData id;
- Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
- id.properties = Ice::createProperties(args);
- id.properties->setProperty("Ice.Warn.Endpoints", "0");
- int rc = app.main(argc, argv, id);
- return rc;
+ int status = 0;
+
+ try
+ {
+ Ice::CtrlCHandler ctrlCHandler;
+
+ Ice::InitializationData id;
+ Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
+ id.properties = Ice::createProperties(args);
+ id.properties->setProperty("Ice.Warn.Endpoints", "0");
+ Ice::CommunicatorHolder ich(id);
+ communicator = ich.communicator();
+
+ ctrlCHandler.setCallback(&destroyCommunicator);
+
+ status = run(args);
+ }
+ catch(const std::exception& ex)
+ {
+ consoleErr << ex.what() << endl;
+ status = 1;
+ }
+
+ return status;
}
void
-Client::usage()
+usage(const string& name)
{
- consoleErr << "Usage: " << appName() << " [options]\n";
+ consoleErr << "Usage: " << name << " [options]\n";
consoleErr <<
"Options:\n"
"-h, --help Show this message.\n"
@@ -69,7 +83,7 @@ Client::usage()
}
int
-Client::run(int argc, char* argv[])
+run(const Ice::StringSeq& args)
{
string commands;
bool debug;
@@ -80,33 +94,31 @@ Client::run(int argc, char* argv[])
opts.addOpt("e", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat);
opts.addOpt("d", "debug");
- vector<string> args;
try
{
- args = opts.parse(argc, const_cast<const char**>(argv));
+ if(!opts.parse(args).empty())
+ {
+ consoleErr << args[0] << ": too many arguments" << endl;
+ usage(args[0]);
+ return 1;
+ }
}
catch(const IceUtilInternal::BadOptException& e)
{
consoleErr << e.reason << endl;
- usage();
- return EXIT_FAILURE;
- }
- if(!args.empty())
- {
- consoleErr << argv[0] << ": too many arguments" << endl;
- usage();
- return EXIT_FAILURE;
+ usage(args[0]);
+ return 1;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage(args[0]);
+ return 0;
}
if(opts.isSet("version"))
{
consoleOut << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ return 0;
}
if(opts.isSet("e"))
{
@@ -120,10 +132,10 @@ Client::run(int argc, char* argv[])
// The complete set of Ice::Identity -> manager proxies.
map<Ice::Identity, IceStorm::TopicManagerPrx> managers;
- PropertiesPtr properties = communicator()->getProperties();
+ Ice::PropertiesPtr properties = communicator->getProperties();
IceStorm::TopicManagerPrx defaultManager;
- Ice::PropertyDict props = communicator()->getProperties()->getPropertiesForPrefix("IceStormAdmin.TopicManager.");
+ Ice::PropertyDict props = communicator->getProperties()->getPropertiesForPrefix("IceStormAdmin.TopicManager.");
{
for(Ice::PropertyDict::const_iterator p = props.begin(); p != props.end(); ++p)
{
@@ -135,14 +147,14 @@ Client::run(int argc, char* argv[])
try
{
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::uncheckedCast(
- communicator()->propertyToProxy(p->first));
+ communicator->propertyToProxy(p->first));
managers.insert(map<Ice::Identity, IceStorm::TopicManagerPrx>::value_type(
manager->ice_getIdentity(), manager));
}
catch(const Ice::ProxyParseException&)
{
- consoleErr << appName() << ": malformed proxy: " << p->second << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": malformed proxy: " << p->second << endl;
+ return 1;
}
}
}
@@ -151,7 +163,7 @@ Client::run(int argc, char* argv[])
if(!managerProxy.empty())
{
defaultManager = IceStorm::TopicManagerPrx::uncheckedCast(
- communicator()->stringToProxy(managerProxy));
+ communicator->stringToProxy(managerProxy));
}
else if(!managers.empty())
{
@@ -169,7 +181,7 @@ Client::run(int argc, char* argv[])
os << "IceStorm/Finder";
os << ":tcp" << (host.empty() ? "" : (" -h \"" + host + "\"")) << " -p " << port << " -t " << timeout;
os << ":ssl" << (host.empty() ? "" : (" -h \"" + host + "\"")) << " -p " << port << " -t " << timeout;
- IceStorm::FinderPrx finder = IceStorm::FinderPrx::uncheckedCast(communicator()->stringToProxy(os.str()));
+ IceStorm::FinderPrx finder = IceStorm::FinderPrx::uncheckedCast(communicator->stringToProxy(os.str()));
try
{
defaultManager = finder->getTopicManager();
@@ -182,19 +194,19 @@ Client::run(int argc, char* argv[])
if(!defaultManager)
{
- consoleErr << appName() << ": no manager proxies configured" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": no manager proxies configured" << endl;
+ return 1;
}
- ParserPtr p = Parser::createParser(communicator(), defaultManager, managers);
- int status = EXIT_SUCCESS;
+ IceStorm::ParserPtr p = IceStorm::Parser::createParser(communicator, defaultManager, managers);
+ int status = 0;
if(!commands.empty()) // Commands were given
{
int parseStatus = p->parse(commands, debug);
- if(parseStatus == EXIT_FAILURE)
+ if(parseStatus == 1)
{
- status = EXIT_FAILURE;
+ status = 1;
}
}
else // No commands, let's use standard input
@@ -202,9 +214,9 @@ Client::run(int argc, char* argv[])
p->showBanner();
int parseStatus = p->parse(stdin, debug);
- if(parseStatus == EXIT_FAILURE)
+ if(parseStatus == 1)
{
- status = EXIT_FAILURE;
+ status = 1;
}
}
diff --git a/cpp/src/IceStorm/IceStormDB.cpp b/cpp/src/IceStorm/IceStormDB.cpp
index 7fc13ef3a65..29785c65f83 100644
--- a/cpp/src/IceStorm/IceStormDB.cpp
+++ b/cpp/src/IceStorm/IceStormDB.cpp
@@ -17,39 +17,50 @@
#include <fstream>
using namespace std;
-using namespace Ice;
using namespace IceInternal;
-using namespace IceStorm;
-using namespace IceStormElection;
-class Client : public Ice::Application
-{
-public:
+int run(const Ice::StringSeq&);
- void usage();
- virtual int run(int, char*[]);
-};
+Ice::CommunicatorPtr communicator;
-#ifdef _WIN32
+void
+destroyCommunicator(int)
+{
+ communicator->destroy();
+}
int
+#ifdef _WIN32
wmain(int argc, wchar_t* argv[])
-
#else
-
-int
main(int argc, char* argv[])
-
#endif
{
- Client app;
- return app.main(argc, argv);
+ int status = 0;
+
+ try
+ {
+ Ice::CtrlCHandler ctrlCHandler;
+ Ice::CommunicatorHolder ich(argc, argv);
+ communicator = ich.communicator();
+
+ ctrlCHandler.setCallback(&destroyCommunicator);
+
+ status = run(Ice::argsToStringSeq(argc, argv));
+ }
+ catch(const std::exception& ex)
+ {
+ consoleErr << ex.what() << endl;
+ status = 1;
+ }
+
+ return status;
}
void
-Client::usage()
+usage(const string& name)
{
- consoleErr << "Usage: " << appName() << " <options>\n";
+ consoleErr << "Usage: " << name << " <options>\n";
consoleErr <<
"Options:\n"
"-h, --help Show this message.\n"
@@ -64,7 +75,7 @@ Client::usage()
}
int
-Client::run(int argc, char* argv[])
+run(const Ice::StringSeq& args)
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
@@ -76,48 +87,46 @@ Client::run(int argc, char* argv[])
opts.addOpt("", "dbpath", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "mapsize", IceUtilInternal::Options::NeedArg);
- vector<string> args;
try
{
- args = opts.parse(argc, const_cast<const char**>(argv));
+ if(!opts.parse(args).empty())
+ {
+ consoleErr << args[0] << ": too many arguments" << endl;
+ usage(args[0]);
+ return 1;
+ }
}
catch(const IceUtilInternal::BadOptException& e)
{
- consoleErr << argv[0] << ": " << e.reason << endl;
- usage();
- return EXIT_FAILURE;
- }
- if(!args.empty())
- {
- consoleErr << argv[0] << ": too many arguments" << endl;
- usage();
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": " << e.reason << endl;
+ usage(args[0]);
+ return 1;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage(args[0]);
+ return 0;
}
if(opts.isSet("version"))
{
consoleOut << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ return 0;
}
if(!(opts.isSet("import") ^ opts.isSet("export")))
{
- consoleErr << argv[0] << ": either --import or --export must be set" << endl;
- usage();
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": either --import or --export must be set" << endl;
+ usage(args[0]);
+ return 1;
}
if(!(opts.isSet("dbhome") ^ opts.isSet("dbpath")))
{
- consoleErr << argv[0] << ": set the database environment directory with either --dbhome or --dbpath" << endl;
- usage();
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": set the database environment directory with either --dbhome or --dbpath" << endl;
+ usage(args[0]);
+ return 1;
}
bool debug = opts.isSet("debug");
@@ -141,7 +150,7 @@ Client::run(int argc, char* argv[])
IceStorm::AllData data;
IceDB::IceContext dbContext;
- dbContext.communicator = communicator();
+ dbContext.communicator = communicator;
dbContext.encoding.major = 1;
dbContext.encoding.minor = 1;
@@ -151,22 +160,22 @@ Client::run(int argc, char* argv[])
if(!IceUtilInternal::directoryExists(dbPath))
{
- consoleErr << argv[0] << ": output directory does not exist: " << dbPath << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": output directory does not exist: " << dbPath << endl;
+ return 1;
}
if(!IceUtilInternal::isEmptyDirectory(dbPath))
{
- consoleErr << argv[0] << ": output directory is not empty: " << dbPath << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": output directory is not empty: " << dbPath << endl;
+ return 1;
}
ifstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << argv[0] << ": could not open input file: " << IceUtilInternal::errorToString(errno)
+ consoleErr << args[0] << ": could not open input file: " << IceUtilInternal::errorToString(errno)
<< endl;
- return EXIT_FAILURE;
+ return 1;
}
fs.unsetf(ios::skipws);
@@ -176,8 +185,8 @@ Client::run(int argc, char* argv[])
if(!fileSize)
{
fs.close();
- consoleErr << argv[0] << ": empty input file" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": empty input file" << endl;
+ return 1;
}
fs.seekg(0, ios::beg);
@@ -191,12 +200,12 @@ Client::run(int argc, char* argv[])
string type;
int version;
- Ice::InputStream stream(communicator(), dbContext.encoding, buf);
+ Ice::InputStream stream(communicator, dbContext.encoding, buf);
stream.read(type);
if(type != "IceStorm")
{
- consoleErr << argv[0] << ": incorrect input file type: " << type << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": incorrect input file type: " << type << endl;
+ return 1;
}
stream.read(version);
stream.read(data);
@@ -210,10 +219,10 @@ Client::run(int argc, char* argv[])
consoleOut << "Writing LLU Map:" << endl;
}
- IceDB::Dbi<string, LogUpdate, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<string,IceStormElection::LogUpdate, IceDB::IceContext, Ice::OutputStream>
lluMap(txn, "llu", dbContext, MDB_CREATE);
- for(StringLogUpdateDict::const_iterator p = data.llus.begin(); p != data.llus.end(); ++p)
+ for(IceStormElection::StringLogUpdateDict::const_iterator p = data.llus.begin(); p != data.llus.end(); ++p)
{
if(debug)
{
@@ -227,15 +236,15 @@ Client::run(int argc, char* argv[])
consoleOut << "Writing Subscriber Map:" << endl;
}
- IceDB::Dbi<SubscriberRecordKey, SubscriberRecord, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<IceStorm::SubscriberRecordKey, IceStorm::SubscriberRecord, IceDB::IceContext, Ice::OutputStream>
subscriberMap(txn, "subscribers", dbContext, MDB_CREATE);
- for(SubscriberRecordDict::const_iterator q = data.subscribers.begin(); q != data.subscribers.end(); ++q)
+ for(IceStorm::SubscriberRecordDict::const_iterator q = data.subscribers.begin(); q != data.subscribers.end(); ++q)
{
if(debug)
{
- consoleOut << " KEY = TOPIC(" << communicator()->identityToString(q->first.topic)
- << ") ID(" << communicator()->identityToString(q->first.id) << ")" << endl;
+ consoleOut << " KEY = TOPIC(" << communicator->identityToString(q->first.topic)
+ << ") ID(" << communicator->identityToString(q->first.id) << ")" << endl;
}
subscriberMap.put(txn, q->first, q->second);
}
@@ -257,12 +266,12 @@ Client::run(int argc, char* argv[])
consoleOut << "Reading LLU Map:" << endl;
}
- IceDB::Dbi<string, LogUpdate, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<string, IceStormElection::LogUpdate, IceDB::IceContext, Ice::OutputStream>
lluMap(txn, "llu", dbContext, 0);
string s;
- LogUpdate llu;
- IceDB::ReadOnlyCursor<string, LogUpdate, IceDB::IceContext, Ice::OutputStream> lluCursor(lluMap, txn);
+ IceStormElection::LogUpdate llu;
+ IceDB::ReadOnlyCursor<string, IceStormElection::LogUpdate, IceDB::IceContext, Ice::OutputStream> lluCursor(lluMap, txn);
while(lluCursor.get(s, llu, MDB_NEXT))
{
if(debug)
@@ -278,19 +287,19 @@ Client::run(int argc, char* argv[])
consoleOut << "Reading Subscriber Map:" << endl;
}
- IceDB::Dbi<SubscriberRecordKey, SubscriberRecord, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<IceStorm::SubscriberRecordKey, IceStorm::SubscriberRecord, IceDB::IceContext, Ice::OutputStream>
subscriberMap(txn, "subscribers", dbContext, 0);
- SubscriberRecordKey key;
- SubscriberRecord record;
- IceDB::ReadOnlyCursor<SubscriberRecordKey, SubscriberRecord, IceDB::IceContext, Ice::OutputStream>
+ IceStorm::SubscriberRecordKey key;
+ IceStorm::SubscriberRecord record;
+ IceDB::ReadOnlyCursor<IceStorm::SubscriberRecordKey, IceStorm::SubscriberRecord, IceDB::IceContext, Ice::OutputStream>
subCursor(subscriberMap, txn);
while(subCursor.get(key, record, MDB_NEXT))
{
if(debug)
{
- consoleOut << " KEY = TOPIC(" << communicator()->identityToString(key.topic)
- << ") ID(" << communicator()->identityToString(key.id) << ")" << endl;
+ consoleOut << " KEY = TOPIC(" << communicator->identityToString(key.topic)
+ << ") ID(" << communicator->identityToString(key.id) << ")" << endl;
}
data.subscribers.insert(std::make_pair(key, record));
}
@@ -300,7 +309,7 @@ Client::run(int argc, char* argv[])
env.close();
}
- Ice::OutputStream stream(communicator(), dbContext.encoding);
+ Ice::OutputStream stream(communicator, dbContext.encoding);
stream.write("IceStorm");
stream.write(ICE_INT_VERSION);
stream.write(data);
@@ -308,9 +317,9 @@ Client::run(int argc, char* argv[])
ofstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << argv[0] << ": could not open output file: " << IceUtilInternal::errorToString(errno)
+ consoleErr << args[0] << ": could not open output file: " << IceUtilInternal::errorToString(errno)
<< endl;
- return EXIT_FAILURE;
+ return 1;
}
fs.write(reinterpret_cast<const char*>(stream.b.begin()), stream.b.size());
fs.close();
@@ -318,9 +327,9 @@ Client::run(int argc, char* argv[])
}
catch(const IceUtil::Exception& ex)
{
- consoleErr << argv[0] << ": " << (import ? "import" : "export") << " failed:\n" << ex << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": " << (import ? "import" : "export") << " failed:\n" << ex << endl;
+ return 1;
}
- return EXIT_SUCCESS;
+ return 0;
}
diff --git a/cpp/src/icegriddb/IceGridDB.cpp b/cpp/src/icegriddb/IceGridDB.cpp
index 18c0e452c8e..bb75e4fe88b 100644
--- a/cpp/src/icegriddb/IceGridDB.cpp
+++ b/cpp/src/icegriddb/IceGridDB.cpp
@@ -20,9 +20,7 @@
#include <fstream>
using namespace std;
-using namespace Ice;
using namespace IceInternal;
-using namespace IceGrid;
namespace
{
@@ -80,7 +78,7 @@ public:
{
}
- virtual ObjectPtr create(const string& type)
+ virtual Ice::ObjectPtr create(const string& type)
{
if(type == "::IceGrid::ServerDescriptor")
{
@@ -125,34 +123,48 @@ struct StreamReader<IceGrid::ReplicaGroupDescriptor, Ice::InputStream>
};
}
-class Client : public Ice::Application
-{
-public:
+int run(const Ice::StringSeq&);
- void usage();
- virtual int run(int, char*[]);
-};
+Ice::CommunicatorPtr communicator;
-#ifdef _WIN32
+void
+destroyCommunicator(int)
+{
+ communicator->destroy();
+}
int
+#ifdef _WIN32
wmain(int argc, wchar_t* argv[])
-
#else
-
-int
main(int argc, char* argv[])
-
#endif
-{
- Client app;
- return app.main(argc, argv);
+{
+ int status = 0;
+
+ try
+ {
+ Ice::CtrlCHandler ctrlCHandler;
+ Ice::CommunicatorHolder ich(argc, argv);
+ communicator = ich.communicator();
+
+ ctrlCHandler.setCallback(&destroyCommunicator);
+
+ status = run(Ice::argsToStringSeq(argc, argv));
+ }
+ catch(const std::exception& ex)
+ {
+ consoleErr << ex.what() << endl;
+ status = 1;
+ }
+
+ return status;
}
void
-Client::usage()
+usage(const string& name)
{
- consoleErr << "Usage: " << appName() << " <options>\n";
+ consoleErr << "Usage: " << name << " <options>\n";
consoleErr <<
"Options:\n"
"-h, --help Show this message.\n"
@@ -168,7 +180,7 @@ Client::usage()
}
int
-Client::run(int argc, char* argv[])
+run(const Ice::StringSeq& args)
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
@@ -181,48 +193,46 @@ Client::run(int argc, char* argv[])
opts.addOpt("", "mapsize", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "server-version", IceUtilInternal::Options::NeedArg);
- vector<string> args;
try
{
- args = opts.parse(argc, const_cast<const char**>(argv));
+ if(!opts.parse(args).empty())
+ {
+ consoleErr << args[0] << ": too many arguments" << endl;
+ usage(args[0]);
+ return 1;
+ }
}
catch(const IceUtilInternal::BadOptException& e)
{
- consoleErr << argv[0] << ": " << e.reason << endl;
- usage();
- return EXIT_FAILURE;
- }
- if(!args.empty())
- {
- consoleErr << argv[0] << ": too many arguments" << endl;
- usage();
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": " << e.reason << endl;
+ usage(args[0]);
+ return 1;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage(args[0]);
+ return 0;
}
if(opts.isSet("version"))
{
consoleOut << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ return 0;
}
if(!(opts.isSet("import") ^ opts.isSet("export")))
{
- consoleErr << argv[0] << ": either --import or --export must be set" << endl;
- usage();
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": either --import or --export must be set" << endl;
+ usage(args[0]);
+ return 1;
}
if(!(opts.isSet("dbhome") ^ opts.isSet("dbpath")))
{
- consoleErr << argv[0] << ": set the database environment directory with either --dbhome or --dbpath" << endl;
- usage();
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": set the database environment directory with either --dbhome or --dbpath" << endl;
+ usage(args[0]);
+ return 1;
}
bool debug = opts.isSet("debug");
@@ -247,7 +257,7 @@ Client::run(int argc, char* argv[])
IceGrid::AllData data;
IceDB::IceContext dbContext;
- dbContext.communicator = communicator();
+ dbContext.communicator = communicator;
dbContext.encoding.major = 1;
dbContext.encoding.minor = 1;
@@ -258,21 +268,21 @@ Client::run(int argc, char* argv[])
if(!IceUtilInternal::directoryExists(dbPath))
{
- consoleErr << argv[0] << ": output directory does not exist: " << dbPath << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": output directory does not exist: " << dbPath << endl;
+ return 1;
}
if(!IceUtilInternal::isEmptyDirectory(dbPath))
{
- consoleErr << argv[0] << ": output directory is not empty: " << dbPath << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": output directory is not empty: " << dbPath << endl;
+ return 1;
}
ifstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << argv[0] << ": could not open input file: " << IceUtilInternal::errorToString(errno) << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": could not open input file: " << IceUtilInternal::errorToString(errno) << endl;
+ return 1;
}
fs.unsetf(ios::skipws);
@@ -282,8 +292,8 @@ Client::run(int argc, char* argv[])
if(!fileSize)
{
fs.close();
- consoleErr << argv[0] << ": empty input file" << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": empty input file" << endl;
+ return 1;
}
fs.seekg(0, ios::beg);
@@ -296,12 +306,12 @@ Client::run(int argc, char* argv[])
if(!serverVersion.empty())
{
- ValueFactoryPtr factory = new ValueFactoryI(serverVersion);
- communicator()->getValueFactoryManager()->add(factory, "::IceGrid::ServerDescriptor");
- communicator()->getValueFactoryManager()->add(factory, "::IceGrid::IceBoxDescriptor");
+ Ice::ValueFactoryPtr factory = new ValueFactoryI(serverVersion);
+ communicator->getValueFactoryManager()->add(factory, "::IceGrid::ServerDescriptor");
+ communicator->getValueFactoryManager()->add(factory, "::IceGrid::IceBoxDescriptor");
}
- Ice::InputStream stream(communicator(), dbContext.encoding, buf);
+ Ice::InputStream stream(communicator, dbContext.encoding, buf);
string type;
int version;
@@ -309,8 +319,8 @@ Client::run(int argc, char* argv[])
stream.read(type);
if(type != "IceGrid")
{
- consoleErr << argv[0] << ": incorrect input file type: " << type << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": incorrect input file type: " << type << endl;
+ return 1;
}
stream.read(version);
if(version / 100 == 305)
@@ -332,10 +342,10 @@ Client::run(int argc, char* argv[])
consoleOut << "Writing Applications Map:" << endl;
}
- IceDB::Dbi<string, ApplicationInfo, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<string, IceGrid::ApplicationInfo, IceDB::IceContext, Ice::OutputStream>
apps(txn, "applications", dbContext, MDB_CREATE);
- for(ApplicationInfoSeq::const_iterator p = data.applications.begin(); p != data.applications.end(); ++p)
+ for(IceGrid::ApplicationInfoSeq::const_iterator p = data.applications.begin(); p != data.applications.end(); ++p)
{
if(debug)
{
@@ -349,10 +359,10 @@ Client::run(int argc, char* argv[])
consoleOut << "Writing Adapters Map:" << endl;
}
- IceDB::Dbi<string, AdapterInfo, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<string, IceGrid::AdapterInfo, IceDB::IceContext, Ice::OutputStream>
adpts(txn, "adapters", dbContext, MDB_CREATE);
- for(AdapterInfoSeq::const_iterator p = data.adapters.begin(); p != data.adapters.end(); ++p)
+ for(IceGrid::AdapterInfoSeq::const_iterator p = data.adapters.begin(); p != data.adapters.end(); ++p)
{
if(debug)
{
@@ -366,14 +376,14 @@ Client::run(int argc, char* argv[])
consoleOut << "Writing Objects Map:" << endl;
}
- IceDB::Dbi<Identity, ObjectInfo, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<Ice::Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
objs(txn, "objects", dbContext, MDB_CREATE);
- for(ObjectInfoSeq::const_iterator p = data.objects.begin(); p != data.objects.end(); ++p)
+ for(IceGrid::ObjectInfoSeq::const_iterator p = data.objects.begin(); p != data.objects.end(); ++p)
{
if(debug)
{
- consoleOut << " NAME = " << communicator()->identityToString(p->proxy->ice_getIdentity())
+ consoleOut << " NAME = " << communicator->identityToString(p->proxy->ice_getIdentity())
<< endl;
}
objs.put(txn, p->proxy->ice_getIdentity(), *p);
@@ -384,15 +394,15 @@ Client::run(int argc, char* argv[])
consoleOut << "Writing Internal Objects Map:" << endl;
}
- IceDB::Dbi<Identity, ObjectInfo, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<Ice::Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
internalObjs(txn, "internal-objects", dbContext, MDB_CREATE);
- for(ObjectInfoSeq::const_iterator p = data.internalObjects.begin(); p != data.internalObjects.end();
+ for(IceGrid::ObjectInfoSeq::const_iterator p = data.internalObjects.begin(); p != data.internalObjects.end();
++p)
{
if(debug)
{
- consoleOut << " NAME = " << communicator()->identityToString(p->proxy->ice_getIdentity())
+ consoleOut << " NAME = " << communicator->identityToString(p->proxy->ice_getIdentity())
<< endl;
}
internalObjs.put(txn, p->proxy->ice_getIdentity(), *p);
@@ -403,10 +413,10 @@ Client::run(int argc, char* argv[])
consoleOut << "Writing Serials Map:" << endl;
}
- IceDB::Dbi<string, Long, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<string, Ice::Long, IceDB::IceContext, Ice::OutputStream>
srls(txn, "serials", dbContext, MDB_CREATE);
- for(StringLongDict::const_iterator p = data.serials.begin(); p != data.serials.end(); ++p)
+ for(IceGrid::StringLongDict::const_iterator p = data.serials.begin(); p != data.serials.end(); ++p)
{
if(debug)
{
@@ -437,7 +447,7 @@ Client::run(int argc, char* argv[])
applications(txn, "applications", dbContext, 0);
string name;
- ApplicationInfo application;
+ IceGrid::ApplicationInfo application;
IceDB::ReadOnlyCursor<string, IceGrid::ApplicationInfo, IceDB::IceContext, Ice::OutputStream>
appCursor(applications, txn);
while(appCursor.get(name, application, MDB_NEXT))
@@ -458,7 +468,7 @@ Client::run(int argc, char* argv[])
IceDB::Dbi<string, IceGrid::AdapterInfo, IceDB::IceContext, Ice::OutputStream>
adapters(txn, "adapters", dbContext, 0);
- AdapterInfo adapter;
+ IceGrid::AdapterInfo adapter;
IceDB::ReadOnlyCursor<string, IceGrid::AdapterInfo, IceDB::IceContext, Ice::OutputStream>
adapterCursor(adapters, txn);
while(adapterCursor.get(name, adapter, MDB_NEXT))
@@ -476,18 +486,18 @@ Client::run(int argc, char* argv[])
consoleOut << "Reading Object Map:" << endl;
}
- IceDB::Dbi<Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<Ice::Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
objects(txn, "objects", dbContext, 0);
- Identity id;
- ObjectInfo object;
- IceDB::ReadOnlyCursor<Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
+ Ice::Identity id;
+ IceGrid::ObjectInfo object;
+ IceDB::ReadOnlyCursor<Ice::Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
objCursor(objects, txn);
while(objCursor.get(id, object, MDB_NEXT))
{
if(debug)
{
- consoleOut << " IDENTITY = " << communicator()->identityToString(id) << endl;
+ consoleOut << " IDENTITY = " << communicator->identityToString(id) << endl;
}
data.objects.push_back(object);
}
@@ -498,16 +508,16 @@ Client::run(int argc, char* argv[])
consoleOut << "Reading Internal Object Map:" << endl;
}
- IceDB::Dbi<Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<Ice::Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
internalObjects(txn, "internal-objects", dbContext, 0);
- IceDB::ReadOnlyCursor<Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
+ IceDB::ReadOnlyCursor<Ice::Identity, IceGrid::ObjectInfo, IceDB::IceContext, Ice::OutputStream>
iobjCursor(internalObjects, txn);
while(iobjCursor.get(id, object, MDB_NEXT))
{
if(debug)
{
- consoleOut << " IDENTITY = " << communicator()->identityToString(id) << endl;
+ consoleOut << " IDENTITY = " << communicator->identityToString(id) << endl;
}
data.internalObjects.push_back(object);
}
@@ -518,11 +528,11 @@ Client::run(int argc, char* argv[])
consoleOut << "Reading Serials Map:" << endl;
}
- IceDB::Dbi<string, Long, IceDB::IceContext, Ice::OutputStream>
+ IceDB::Dbi<string, Ice::Long, IceDB::IceContext, Ice::OutputStream>
serials(txn, "serials", dbContext, 0);
- Long serial;
- IceDB::ReadOnlyCursor<string, Long, IceDB::IceContext, Ice::OutputStream>
+ Ice::Long serial;
+ IceDB::ReadOnlyCursor<string, Ice::Long, IceDB::IceContext, Ice::OutputStream>
serialCursor(serials, txn);
while(serialCursor.get(name, serial, MDB_NEXT))
{
@@ -538,7 +548,7 @@ Client::run(int argc, char* argv[])
env.close();
}
- Ice::OutputStream stream(communicator(), dbContext.encoding);
+ Ice::OutputStream stream(communicator, dbContext.encoding);
stream.write("IceGrid");
stream.write(ICE_INT_VERSION);
stream.write(data);
@@ -546,8 +556,8 @@ Client::run(int argc, char* argv[])
ofstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << argv[0] << ": could not open output file: " << IceUtilInternal::errorToString(errno) << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": could not open output file: " << IceUtilInternal::errorToString(errno) << endl;
+ return 1;
}
fs.write(reinterpret_cast<const char*>(stream.b.begin()), stream.b.size());
fs.close();
@@ -555,9 +565,9 @@ Client::run(int argc, char* argv[])
}
catch(const IceUtil::Exception& ex)
{
- consoleErr << argv[0] << ": " << (import ? "import" : "export") << " failed:\n" << ex << endl;
- return EXIT_FAILURE;
+ consoleErr << args[0] << ": " << (import ? "import" : "export") << " failed:\n" << ex << endl;
+ return 1;
}
- return EXIT_SUCCESS;
+ return 0;
}
diff --git a/cpp/src/iceserviceinstall/Install.cpp b/cpp/src/iceserviceinstall/Install.cpp
index d82e647ab31..1e6d5c79290 100644
--- a/cpp/src/iceserviceinstall/Install.cpp
+++ b/cpp/src/iceserviceinstall/Install.cpp
@@ -13,39 +13,47 @@
#include <ServiceInstaller.h>
using namespace std;
-using namespace Ice;
using namespace IceInternal;
-class Install : public Application
-{
-public:
- virtual int run(int, char*[]);
-
- Install();
+int run(const Ice::StringSeq&);
- bool pauseEnabled() const;
- bool debug() const;
- bool pause() const;
+Ice::CommunicatorPtr communicator;
-private:
-
- void usage() const;
+void
+destroyCommunicator(int)
+{
+ communicator->destroy();
+}
- bool _debug;
- bool _pauseEnabled;
- bool _pause;
-};
+bool debug = false;
+bool pauseEnabled = true;
+bool pause = false;
int
wmain(int argc, wchar_t* argv[])
{
- Install app;
- InitializationData id;
- id.properties = Ice::createProperties();
- id.properties->setProperty("Ice.Plugin.IceSSL", "IceSSL:createIceSSL");
- int status = app.main(argc, argv, id);
+ int status = 0;
- if(app.pauseEnabled() && (app.pause() || app.debug() || status != 0))
+ try
+ {
+ Ice::CtrlCHandler ctrlCHandler;
+ Ice::InitializationData id;
+ id.properties = Ice::createProperties();
+ id.properties->setProperty("Ice.Plugin.IceSSL", "IceSSL:createIceSSL");
+ Ice::CommunicatorHolder ich(argc, argv, id);
+ communicator = ich.communicator();
+
+ ctrlCHandler.setCallback(&destroyCommunicator);
+
+ status = run(Ice::argsToStringSeq(argc, argv));
+ }
+ catch(const std::exception& ex)
+ {
+ consoleErr << ex.what() << endl;
+ status = 1;
+ }
+
+ if(pauseEnabled && (pause || debug || status != 0))
{
system("pause");
}
@@ -53,8 +61,57 @@ wmain(int argc, wchar_t* argv[])
return status;
}
+void
+usage(const string& name)
+{
+ string defaultImagePath = IceServiceInstaller::getServiceInstallerPath();
+ if(defaultImagePath.empty())
+ {
+ defaultImagePath = string("<error: cannot retrieve path of ") + name + ">";
+ }
+ defaultImagePath += "\\<service>";
+#ifdef _DEBUG
+ defaultImagePath += 'd';
+#endif
+ defaultImagePath += ".exe";
+
+ consoleErr << "Usage: " << name
+ << " [options] service config-file [property] [property]\n";
+ consoleErr <<
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-n, --nopause Do not call pause after displaying a message.\n"
+ "-v, --version Display the Ice version.\n"
+ "-u, --uninstall Uninstall the Windows service.\n"
+ "\n"
+ "service must be icegridregistry, icegridnode or glacier2router.\n"
+ "\n"
+ "config-file Path to the Ice configuration file for this service.\n"
+ " If the path starts with HKLM\\ the configuration will be\n"
+ " read from the corresponding Windows registry keyword in\n"
+ " HKEY_LOCAL_MACHINE.\n"
+ "\n"
+ "Valid properties:\n"
+ "AutoStart 0 = Manual, 1 = Automatic, 2 = Automatic (Delayed Start)\n"
+ " The default value is 1.\n"
+ "Debug Show diagnostics when installing/uninstalling a service.\n"
+ "DependOnRegistry If non-zero, the service depends on the IceGrid registry\n"
+ " service (the IceGrid registry service name is computed\n"
+ " using Ice.Default.Locator in <config-file>).\n"
+ "Description Description of the service.\n"
+ "DisplayName Display name of the service.\n"
+ "EventLog The name of the EventLog used by this service;\n"
+ " the default is Application.\n"
+ "ImagePath Full path to <service>.exe. The default value is\n"
+ " " << defaultImagePath << "\n" <<
+ "ObjectName Account used to run the service. Defaults to\n"
+ " NT Authority\\LocalService.\n"
+ "Password Password for ObjectName.\n"
+ ;
+}
+
int
-Install::run(int argc, char* argv[])
+run(const Ice::StringSeq& args)
{
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
@@ -72,34 +129,34 @@ Install::run(int argc, char* argv[])
vector<string> commands;
try
{
- commands = opts.parse(argc, (const char**)argv);
+ commands = opts.parse(args);
}
catch(const IceUtilInternal::BadOptException& e)
{
consoleErr << "Error:" << e.reason << endl;
- usage();
- return EXIT_FAILURE;
+ usage(args[0]);
+ return 1;
}
- _pauseEnabled = !opts.isSet("nopause");
+ pauseEnabled = !opts.isSet("nopause");
if(opts.isSet("help"))
{
- usage();
- _pause = true;
- return EXIT_SUCCESS;
+ usage(args[0]);
+ pause = true;
+ return 0;
}
if(opts.isSet("version"))
{
consoleOut << ICE_STRING_VERSION << endl;
- _pause = true;
- return EXIT_SUCCESS;
+ pause = true;
+ return 0;
}
if(commands.size() != 2)
{
- usage();
- return EXIT_FAILURE;
+ usage(args[0]);
+ return 1;
}
int serviceType = -1;
@@ -115,14 +172,14 @@ Install::run(int argc, char* argv[])
if(serviceType == -1)
{
consoleErr << "Invalid service " << commands[0] << endl;
- return EXIT_FAILURE;
+ return 1;
}
string configFile = commands[1];
try
{
- IceServiceInstaller installer(serviceType, configFile, communicator());
+ IceServiceInstaller installer(serviceType, configFile, communicator);
if(opts.isSet("uninstall"))
{
@@ -130,7 +187,7 @@ Install::run(int argc, char* argv[])
}
else
{
- PropertiesPtr properties = communicator()->getProperties();
+ Ice::PropertiesPtr properties = communicator->getProperties();
for(size_t j = 0; j < propNames.size(); ++j)
{
@@ -140,7 +197,7 @@ Install::run(int argc, char* argv[])
}
}
- _debug = properties->getPropertyAsInt("Debug") > 0;
+ debug = properties->getPropertyAsInt("Debug") > 0;
installer.install(properties);
}
@@ -148,81 +205,7 @@ Install::run(int argc, char* argv[])
catch(const exception& ex)
{
consoleErr << "Error: " << ex.what() << endl;
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
-}
-
-Install::Install() :
- _pauseEnabled(true),
- _debug(false),
- _pause(false)
-{
-}
-
-bool
-Install::pauseEnabled() const
-{
- return _pauseEnabled;
-}
-
-bool
-Install::debug() const
-{
- return _debug;
-}
-
-bool
-Install::pause() const
-{
- return _pause;
-}
-
-void
-Install::usage() const
-{
- string defaultImagePath = IceServiceInstaller::getServiceInstallerPath();
- if(defaultImagePath.empty())
- {
- defaultImagePath = string("<error: cannot retrieve path of ") + appName() + ">";
+ return 1;
}
- defaultImagePath += "\\<service>";
-#ifdef _DEBUG
- defaultImagePath += 'd';
-#endif
- defaultImagePath += ".exe";
-
- consoleErr << "Usage: " << appName()
- << " [options] service config-file [property] [property]\n";
- consoleErr <<
- "Options:\n"
- "-h, --help Show this message.\n"
- "-n, --nopause Do not call pause after displaying a message.\n"
- "-v, --version Display the Ice version.\n"
- "-u, --uninstall Uninstall the Windows service.\n"
- "\n"
- "service must be icegridregistry, icegridnode or glacier2router.\n"
- "\n"
- "config-file Path to the Ice configuration file for this service.\n"
- " If the path starts with HKLM\\ the configuration will be\n"
- " read from the corresponding Windows registry keyword in\n"
- " HKEY_LOCAL_MACHINE.\n"
- "\n"
- "Valid properties:\n"
- "AutoStart 0 = Manual, 1 = Automatic, 2 = Automatic (Delayed Start)\n"
- " The default value is 1.\n"
- "Debug Show diagnostics when installing/uninstalling a service.\n"
- "DependOnRegistry If non-zero, the service depends on the IceGrid registry\n"
- " service (the IceGrid registry service name is computed\n"
- " using Ice.Default.Locator in <config-file>).\n"
- "Description Description of the service.\n"
- "DisplayName Display name of the service.\n"
- "EventLog The name of the EventLog used by this service;\n"
- " the default is Application.\n"
- "ImagePath Full path to <service>.exe. The default value is\n"
- " " << defaultImagePath << "\n" <<
- "ObjectName Account used to run the service. Defaults to\n"
- " NT Authority\\LocalService.\n"
- "Password Password for ObjectName.\n"
- ;
+ return 0;
}
diff --git a/java-compat/src/Ice/src/main/java/Ice/AMD_Object_ice_invoke.java b/java-compat/src/Ice/src/main/java/Ice/AMD_Object_ice_invoke.java
index a8d0b2cb25a..04738dbf588 100644
--- a/java-compat/src/Ice/src/main/java/Ice/AMD_Object_ice_invoke.java
+++ b/java-compat/src/Ice/src/main/java/Ice/AMD_Object_ice_invoke.java
@@ -11,8 +11,7 @@ package Ice;
/**
* Callback interface for Blobject AMD servants.
- *
- @see BlobjectAsync
+ * @see BlobjectAsync
**/
public interface AMD_Object_ice_invoke
{
diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/OutputStream.java b/java/src/Ice/src/main/java/com/zeroc/Ice/OutputStream.java
index 5ceab8938f7..76afa687cec 100644
--- a/java/src/Ice/src/main/java/com/zeroc/Ice/OutputStream.java
+++ b/java/src/Ice/src/main/java/com/zeroc/Ice/OutputStream.java
@@ -450,11 +450,11 @@ public class OutputStream
* Marks the start of a new slice for a class instance or user exception.
*
* @param typeId The Slice type ID corresponding to this slice.
-
+ *
* @param compactId The Slice compact type ID corresponding to
* this slice or -1 if no compact ID is defined for the
* type ID.
-
+ *
* @param last True if this is the last slice, false otherwise.
**/
public void startSlice(String typeId, int compactId, boolean last)
diff --git a/scripts/Util.py b/scripts/Util.py
index 3d282653d4e..a4ad0448d70 100644
--- a/scripts/Util.py
+++ b/scripts/Util.py
@@ -1289,15 +1289,6 @@ class ProcessFromBinDir:
return True
#
-# Executables for processes inheriting this marker class are looked up in the
-# Ice distribution bin directory.
-#
-class ProcessFromBinDir:
-
- def isFromBinDir(self):
- return True
-
-#
# Executables for processes inheriting this marker class are only provided
# as a Release executble on Windows
#
diff --git a/slice/Ice/Communicator.ice b/slice/Ice/Communicator.ice
index 00b2ba3fb97..978968e09e2 100644
--- a/slice/Ice/Communicator.ice
+++ b/slice/Ice/Communicator.ice
@@ -539,7 +539,7 @@ local interface Communicator
*
* If Ice.Admin.DelayCreation is 0 or not set, getAdmin is called by the communicator
* initialization, after initialization of all plugins.
-
+ *
* @return A proxy to the main ("") facet of the Admin object, or a null proxy if no
* Admin object is configured.
*