diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-11-21 17:58:52 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-11-21 17:58:52 -0500 |
commit | 7826d8dd30b3bbbd3be4c65df8260164a9021798 (patch) | |
tree | 415bad61d47d08332f3ea6a377dc95b6dea467f9 /cpp/src/IceGrid/NodeServerAdminRouter.cpp | |
parent | Added AMI call (diff) | |
download | ice-7826d8dd30b3bbbd3be4c65df8260164a9021798.tar.bz2 ice-7826d8dd30b3bbbd3be4c65df8260164a9021798.tar.xz ice-7826d8dd30b3bbbd3be4c65df8260164a9021798.zip |
Refactored server-properties access/retrieval from IceGrid admin client
Diffstat (limited to 'cpp/src/IceGrid/NodeServerAdminRouter.cpp')
-rw-r--r-- | cpp/src/IceGrid/NodeServerAdminRouter.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/cpp/src/IceGrid/NodeServerAdminRouter.cpp b/cpp/src/IceGrid/NodeServerAdminRouter.cpp new file mode 100644 index 00000000000..62d9c5c4dcb --- /dev/null +++ b/cpp/src/IceGrid/NodeServerAdminRouter.cpp @@ -0,0 +1,86 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceGrid/NodeServerAdminRouter.h> +#include <Ice/Ice.h> +#include <IceGrid/ServerI.h> + +using namespace IceGrid; +using namespace Ice; +using namespace std; + +namespace +{ + +class AMICallback : public AMI_Array_Object_ice_invoke +{ +public: + + AMICallback(const AMD_Array_Object_ice_invokePtr& cb) : + _cb(cb) + { + } + + virtual void ice_response(bool ok, const pair<const Byte*, const Byte*>& outParams) + { + _cb->ice_response(ok, outParams); + } + + virtual void ice_exception(const Ice::Exception& ex) + { + _cb->ice_exception(ex); + } + +private: + AMD_Array_Object_ice_invokePtr _cb; +}; + +} + +IceGrid::NodeServerAdminRouter::NodeServerAdminRouter(const NodeIPtr& node) : + _node(node) +{ +} + +void +IceGrid::NodeServerAdminRouter::ice_invoke_async(const AMD_Array_Object_ice_invokePtr& cb, + const pair<const Byte*, const Byte*>& inParams, + const Current& current) +{ + + // + // First, get the ServerI servant + // + Identity serverId = _node->createServerIdentity(current.id.name); + ServerIPtr server = ServerIPtr::dynamicCast(_node->getAdapter()->find(serverId)); + if(server == 0) + { + throw ObjectNotExistException(__FILE__, __LINE__); + } + + // + // Then get a proxy to the real admin object + // + ObjectPrx target = server->getRealAdmin(); + + if(target == 0) + { + throw ObjectNotExistException(__FILE__, __LINE__); + } + + // + // Set the facet + // + target = target->ice_facet(current.facet); + + // + // Call with AMI + // + target->ice_invoke_async(new AMICallback(cb), current.operation, current.mode, inParams, current.ctx); +} |