32 #include "../EventId.h"
33 #include "../MetaData.h"
34 #include "../Factory.h"
36 #include "../filter/MethodFilter.h"
42 using namespace rsc::runtime;
49 LocalServer::IntlCallback::~IntlCallback() {
52 LocalServer::CallbackBase::CallbackBase(
const string& requestType,
53 const string& replyType)
54 : requestType(requestType), replyType(replyType) {
58 return this->requestType;
62 return this->replyType;
66 return call(methodName, request);
72 const std::string& name,
76 :
Method(scope, name, listenerConfig, informerConfig),
77 logger(rsc::logging::Logger::getLogger(boost::str(boost::format(
"rsb.patterns.LocalMethod[%1%]")
86 return "local-method";
92 listener->addHandler(
HandlerPtr(shared_from_this()));
99 if (callbackWithReturnType) {
100 if (event->getType() != callbackWithReturnType->
getRequestType()) {
101 RSCERROR(this->logger, boost::format(
"Request type '%1%' "
102 "does not match expected request type '%2%' "
113 reply = this->callback->
intlCall(getName(), event);
115 }
catch (
const exception& e) {
116 reply.reset(
new Event());
117 reply->setType(typeName<string>());
118 reply->setData(boost::shared_ptr<string>(
new string(typeName(e) +
": " + e.what())));
119 reply->mutableMetaData().setUserInfo(
"rsb:error?",
"");
121 reply->setScopePtr(getInformer()->
getScope());
122 reply->setMethod(
"REPLY");
123 reply->addCause(event->getId());
124 getInformer()->publish(reply);
133 listenerConfig(listenerConfig),
134 informerConfig(informerConfig) {
138 for (std::map<std::string, LocalMethodPtr>::iterator it
140 it->second->deactivate();
145 return "local-server";
149 return std::set<std::string>();
LocalMethod(const Scope &scope, const std::string &name, const ParticipantConfig &listenerConfig, const ParticipantConfig &informerConfig, CallbackPtr callback)
EventPtr intlCall(const std::string &methodName, EventPtr request)
Indicates that a method of a Server already exists.
boost::shared_ptr< LocalMethod > LocalMethodPtr
Basic message that is exchanged between informers and listeners.
Objects of this class participate in the exchange of notifications on one channel of the bus...
virtual EventPtr intlCall(const std::string &methodName, EventPtr request)=0
virtual void call(const std::string &methodName)=0
Implement this method to perform actions.
Base class for callback classes.
boost::shared_ptr< Filter > FilterPtr
void registerMethod(const std::string &name, CallbackPtr callback)
Register a new method with the given name.
virtual const std::set< std::string > getTransportURLs() const
TODO.
Factory & getFactory()
Returns a factory for client-level RSB objects.
This filter matches events based on the value of their method field.
LocalServer(const Scope &scope, const ParticipantConfig &listenerConfig, const ParticipantConfig &informerConfig)
ListenerPtr makeListener()
Creates and returns the Listener participant.
boost::shared_ptr< Listener > ListenerPtr
std::map< std::string, LocalMethodPtr > methods
boost::shared_ptr< IntlCallback > CallbackPtr
boost::shared_ptr< Handler > HandlerPtr
virtual ListenerPtr makeListener()
Creates and returns the Listener participant.
Base class for method classes.
void handle(EventPtr event)
Handle event.
virtual std::string getKind() const
Return the kind of the participant.
A class describing the configuration of Participant instances.
virtual const std::string & getReplyType() const
ScopePtr getScope() const
Returns the scope of this participant.
patterns::LocalServer::LocalMethodPtr createLocalMethod(const Scope &scope, patterns::LocalServer::CallbackPtr callback, const ParticipantConfig &listenerConfig=getFactory().getDefaultParticipantConfig(), const ParticipantConfig &informerConfig=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a patterns::LocalServer::LocalMethod.
ParticipantConfig listenerConfig
boost::shared_ptr< Event > EventPtr
Scope is a descriptor for a hierarchical channel of the unified bus.
virtual const std::string & getRequestType() const
virtual std::string getKind() const
Return the kind of the participant.
ParticipantConfig informerConfig