Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
ServantLocator.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_SERVANT_LOCATOR_H
4#define ICE_SERVANT_LOCATOR_H
5
6#include "Current.h"
7#include "ObjectF.h"
8
9namespace Ice
10{
11 /// An application-provided class that an object adapter uses to locate servants.
12 /// @remark Servant locators are provided for backward compatibility with earlier versions of Ice. You should
13 /// consider using a default servant instead (see ObjectAdapter::addDefaultServant). For more advanced use cases,
14 /// you can create a middleware (see ObjectAdapter::use).
15 /// @headerfile Ice/Ice.h
16 /// @see ObjectAdapter::addServantLocator
17 class ICE_API ServantLocator
18 {
19 public:
20 virtual ~ServantLocator();
21
22 /// Asks this servant locator to find and return a servant.
23 /// @remark The caller (the object adapter) does not insert the returned servant into its Active Servant Map.
24 /// @remark The implementation can throw any exception, including UserException. The Ice runtime marshals this
25 /// exception in the response.
26 /// @param curr Information about the incoming request being dispatched.
27 /// @param cookie A "cookie" that will be passed to #finished.
28 /// @return The located servant, or nullptr if no suitable servant has been found.
29 virtual ObjectPtr locate(const Current& curr, std::shared_ptr<void>& cookie) = 0;
30
31 /// Notifies this servant locator that the dispatch on the servant returned by #locate is complete.
32 /// The object adapter calls this function only when #locate returns a non-null servant.
33 /// @remark The implementation can throw any exception, including UserException. The Ice runtime marshals this
34 /// exception in the response. If both the dispatch and `finished` throw an exception, the exception thrown by
35 /// `finished` prevails and is marshaled back to the client.
36 /// @param curr Information about the incoming request being dispatched.
37 /// @param servant The servant that was returned by #locate.
38 /// @param cookie The cookie that was returned by #locate.
39 virtual void finished(const Current& curr, const ObjectPtr& servant, const std::shared_ptr<void>& cookie) = 0;
40
41 /// Notifies this servant locator that the object adapter is being deactivated.
42 /// @param category The category with which this servant locator was registered.
43 /// @see ObjectAdapter#destroy
44 virtual void deactivate(std::string_view category) = 0;
45 };
46
47 /// A shared pointer to a ServantLocator.
48 using ServantLocatorPtr = std::shared_ptr<ServantLocator>;
49}
50
51#endif
virtual ObjectPtr locate(const Current &curr, std::shared_ptr< void > &cookie)=0
Asks this servant locator to find and return a servant.
virtual void deactivate(std::string_view category)=0
Notifies this servant locator that the object adapter is being deactivated.
virtual void finished(const Current &curr, const ObjectPtr &servant, const std::shared_ptr< void > &cookie)=0
Notifies this servant locator that the dispatch on the servant returned by locate is complete.
An application-provided class that an object adapter uses to locate servants.
std::shared_ptr< ServantLocator > ServantLocatorPtr
A shared pointer to a ServantLocator.
std::shared_ptr< Object > ObjectPtr
A shared pointer to an Object.
Definition ObjectF.h:13
The Ice RPC framework.
Definition SampleEvent.h:59
Provides information about an incoming request being dispatched.
Definition Current.h:18