Ice 3.7 C++98 API Reference
Loading...
Searching...
No Matches
SessionHelper.h
Go to the documentation of this file.
1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5#ifndef GLACIER2_SESSION_HELPER_H
6#define GLACIER2_SESSION_HELPER_H
7
8#include <IceUtil/Shared.h>
9#include <IceUtil/Handle.h>
10#include <IceUtil/Thread.h>
11#include <IceUtil/Mutex.h>
12
13#include <Ice/Initialize.h>
14#include <Ice/Properties.h>
15#include <Ice/Communicator.h>
16#include <Ice/ObjectAdapter.h>
17#include <Ice/Ice.h>
18
19#include <Glacier2/Session.h>
20#include <Glacier2/Router.h>
21
22#include <map>
23#include <string>
24
25namespace Glacier2
26{
27
29const int GLACIER2_SSL_PORT = 4064;
31const int GLACIER2_TCP_PORT = 4063;
32
39#ifndef ICE_CPP11_MAPPING
40 : public virtual IceUtil::Shared
41#endif
42{
43public:
44 virtual ~SessionHelper();
45
49 virtual void destroy() = 0;
50
57
63 virtual std::string categoryForClient() const = 0;
64
72 virtual Ice::ObjectPrxPtr addWithUUID(const Ice::ObjectPtr& servant) = 0;
73
78 virtual SessionPrxPtr session() const = 0;
79
84 virtual bool isConnected() const = 0;
85
93
94#ifndef ICE_CPP11_MAPPING
95 bool operator==(const SessionHelper&) const;
96 bool operator!=(const SessionHelper&) const;
97#endif
98
99};
101
107#ifndef ICE_CPP11_MAPPING
108 : public virtual IceUtil::Shared
109#endif
110{
111public:
113
118 virtual void createdCommunicator(const SessionHelperPtr& session) = 0;
119
124 virtual void connected(const SessionHelperPtr& session) = 0;
125
130 virtual void disconnected(const SessionHelperPtr& session) = 0;
131
137 virtual void connectFailed(const SessionHelperPtr& session, const Ice::Exception& ex) = 0;
138};
140
142class SessionThreadCallback;
144
150#ifdef ICE_CPP11_MAPPING
151 : public std::enable_shared_from_this<SessionFactoryHelper>
152#else
153 : public virtual IceUtil::Shared
154#endif
155{
157 friend class SessionThreadCallback; // To access thread functions
159
160public:
161
168
175
181 SessionFactoryHelper(const Ice::PropertiesPtr& properties, const SessionCallbackPtr& callback);
182
184
188 void destroy();
189
194 void setRouterIdentity(const Ice::Identity& identity);
195
201
206 void setRouterHost(const std::string& host);
207
212 std::string getRouterHost() const;
213
215 ICE_DEPRECATED_API("is deprecated, use SessionFactoryHelper::setProtocol instead")
216 void setSecure(bool);
217 ICE_DEPRECATED_API("is deprecated, use SessionFactoryHelper::getProtocol instead")
218 bool getSecure() const;
220
225 void setProtocol(const std::string& protocol);
226
231 std::string getProtocol() const;
232
237 void setTimeout(int timeout);
238
243 int getTimeout() const;
244
249 void setPort(int port);
250
255 int getPort() const;
256
261 Ice::InitializationData getInitializationData() const;
262
267 void setConnectContext(const std::map<std::string, std::string>& context);
268
273 void setUseCallbacks(bool b);
274
279 bool getUseCallbacks() const;
280
286
291 SessionHelperPtr connect(const std::string& username, const std::string& password);
292
293private:
294
295 IceUtil::ThreadPtr addThread(const SessionHelper*, const IceUtil::ThreadPtr&);
296
297 Ice::InitializationData createInitData();
298 std::string getRouterFinderStr();
299 int getPortInternal() const;
300 std::string createProxyStr(const Ice::Identity& ident);
301 void setDefaultProperties();
302
303 IceUtil::Mutex _mutex;
304 std::string _routerHost;
305 Ice::Identity _identity;
306 std::string _protocol;
307 int _port;
308 int _timeout;
309 Ice::InitializationData _initData;
310 SessionCallbackPtr _callback;
311 std::map<std::string, std::string> _context;
312 bool _useCallbacks;
313 std::map<const SessionHelper*, IceUtil::ThreadPtr> _threads;
314};
316
317}
318
319#endif
#define ICE_DEFINE_PTR(TPtr, T)
Definition Config.h:377
#define ICE_DEPRECATED_API(msg)
Definition Config.h:217
#define GLACIER2_API
Definition PermissionsVerifierF.h:50
Allows an application to receive notification about events in the lifecycle of a Glacier2 session.
Definition SessionHelper.h:110
virtual void disconnected(const SessionHelperPtr &session)=0
Called after the Glacier2 session is destroyed.
virtual void createdCommunicator(const SessionHelperPtr &session)=0
Called after successfully initializing a communicator.
virtual void connectFailed(const SessionHelperPtr &session, const Ice::Exception &ex)=0
Called if a failure occurred while attempting to establish a Glacier2 session.
virtual void connected(const SessionHelperPtr &session)=0
Called after successfully establishing the Glacier2 session.
Facilitates the creation of new Glacier2 sessions.
Definition SessionHelper.h:155
void setRouterHost(const std::string &host)
Sets the host name of the Glacier2 router.
SessionFactoryHelper(const Ice::InitializationData &initData, const SessionCallbackPtr &callback)
Use this constructor when you want to provide your own instance of InitializationData.
void setProtocol(const std::string &protocol)
Sets the Ice protocol used for communications with the Glacier2 router.
bool getUseCallbacks() const
Determines whether the session helper automatically creates an object adapter for callback servants.
Ice::InitializationData getInitializationData() const
Returns a copy of the InitializationData object that will be used during communicator initialization.
SessionHelperPtr connect()
Initializes a communicator, creates a Glacier2 session using SSL credentials, and returns a new Sessi...
std::string getRouterHost() const
Obtains the host name of the Glacier2 router.
SessionFactoryHelper(const Ice::PropertiesPtr &properties, const SessionCallbackPtr &callback)
This constructor is convenient when you want to supply an initial set of properties.
void setRouterIdentity(const Ice::Identity &identity)
Sets the object identity of the Glacier2 router.
int getPort() const
Obtains the port on which the Glacier2 router is listening.
std::string getProtocol() const
Obtains the Ice protocol used for communications with the Glacier2 router.
SessionFactoryHelper(const SessionCallbackPtr &callback)
This constructor is useful when your application has no other configuration requirements.
void setUseCallbacks(bool b)
Determines whether the session helper automatically creates an object adapter for callback servants.
void setConnectContext(const std::map< std::string, std::string > &context)
Sets the request context to be used when creating a session.
Ice::Identity getRouterIdentity() const
Obtains the object identity of the Glacier2 router.
void destroy()
Blocks until all background threads are terminated.
int getTimeout() const
Obtains the timeout in milliseconds for the connection to the Glacier2 router.
void setPort(int port)
Sets the port on which the Glacier2 router is listening.
void setTimeout(int timeout)
Sets the timeout in milliseconds for the connection to the Glacier2 router.
Encapsulates a Glacier2 session and provides much of the same functionality as Glacier2::Application ...
Definition SessionHelper.h:42
virtual bool isConnected() const =0
Determines whether the session is active.
virtual void destroy()=0
Initiates the destruction of the Glacier2 session, including the communicator created by the SessionH...
virtual Ice::ObjectPrxPtr addWithUUID(const Ice::ObjectPtr &servant)=0
Adds a servant to the callback object adapter using a UUID for the identity name.
virtual Ice::ObjectAdapterPtr objectAdapter()=0
Obtains the callback object adapter.
virtual SessionPrxPtr session() const =0
Obtains a proxy for the Glacier2 session.
virtual Ice::CommunicatorPtr communicator() const =0
Obtains the communicator created by the SessionHelper.
bool operator==(const SessionHelper &) const
virtual std::string categoryForClient() const =0
Obtains the category that must be used in the identities of all callback objects.
bool operator!=(const SessionHelper &) const
Definition Shared.h:78
Definition PermissionsVerifier.h:524
::IceUtil::Handle< SessionHelper > SessionHelperPtr
Definition SessionHelper.h:100
::IceUtil::Handle< SessionFactoryHelper > SessionFactoryHelperPtr
Definition SessionHelper.h:315
const int GLACIER2_TCP_PORT
The IANA-registered port number for Glacier2 via TCP.
Definition SessionHelper.h:31
const int GLACIER2_SSL_PORT
The IANA-registered port number for Glacier2 via SSL.
Definition SessionHelper.h:29
::IceUtil::Handle< SessionCallback > SessionCallbackPtr
Definition SessionHelper.h:139
SessionPrx SessionPrxPtr
Definition Session.h:1521
Definition Cond.h:39
Definition BuiltinSequences.h:113
IceInternal::Handle< Object > ObjectPtr
Definition ObjectF.h:21
::IceInternal::Handle< Properties > PropertiesPtr
Definition Properties.h:256
::IceInternal::Handle< ObjectAdapter > ObjectAdapterPtr
Definition ObjectAdapter.h:620
::IceInternal::Handle< Communicator > CommunicatorPtr
Definition Communicator.h:608
IceUtil::Exception Exception
Definition Exception.h:22
ObjectPrx ObjectPrxPtr
Definition ProxyF.h:48
The identity of an Ice object.
Definition Identity.h:144
Encapsulates data to initialize a communicator.
Definition Initialize.h:279