1 /*----------------------------------------------------------------------------
2 Name: DefaultCallback.h
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 Comment: Default implementation of the POA_serverIdl::BlasterCallback.
6 -----------------------------------------------------------------------------*/
7
8 #ifndef _CLIENT_PROTOCOL_CORBA_DEFAULTCALLBACK_H
9 #define _CLIENT_PROTOCOL_CORBA_DEFAULTCALLBACK_H
10
11 #include <string>
12 #include <util/lexical_cast.h>
13 #include <client/I_Callback.h>
14 #include <client/key/UpdateKey.h>
15 #include <client/qos/UpdateQos.h>
16 #include <util/key/MsgKeyFactory.h>
17 #include <util/qos/MsgQosFactory.h>
18 #define SERVER_HEADER 1 // does #include <generated/xmlBlasterS.h> with CompatibleCorba.h, OMNIORB: use -Wbh=.h to force this extension
19 #include <client/protocol/corba/CompatibleCorba.h>
20 #include COSNAMING
21
22 namespace org {
23 namespace xmlBlaster {
24 namespace client {
25 namespace protocol {
26 namespace corba {
27
28 /**
29 * Example for a callback implementation.<p />
30 * You can use this default callback handling with your clients,
31 * but if you need other handling of callbacks, take a copy
32 * of this Callback implementation and add your own code.
33 */
34 class Dll_Export DefaultCallback : public virtual POA_clientIdl::BlasterCallback {
35
36 protected:
37 org::xmlBlaster::util::Global& global_;
38 org::xmlBlaster::util::I_Log& log_;
39 org::xmlBlaster::util::key::MsgKeyFactory msgKeyFactory_;
40 org::xmlBlaster::util::qos::MsgQosFactory msgQosFactory_;
41
42 private:
43 std::string me() {
44 return "DefaultCallback-" + loginName_;
45 }
46
47 org::xmlBlaster::client::I_Callback *boss_;
48 std::string loginName_;
49 // BlasterCache cache_;
50
51
52 void copy(const DefaultCallback &el)
53 {
54 boss_ = el.boss_;
55 loginName_ = el.loginName_;
56 }
57
58
59 /**
60 * Construct a persistently named object.
61 */
62 public:
63 DefaultCallback(org::xmlBlaster::util::Global& global, const std::string &name="", org::xmlBlaster::client::I_Callback *boss=0,
64 /*BlasterCache*/ void* /*cache*/=0);
65
66 DefaultCallback(const DefaultCallback &el)
67 : global_(el.global_), log_(el.log_), msgKeyFactory_(el.global_), msgQosFactory_(el.global_)
68 {
69 copy(el);
70 }
71
72 DefaultCallback& operator =(const DefaultCallback &el) {
73 copy(el);
74 return *this;
75 }
76
77 ~DefaultCallback() {
78 //log_.trace(me(), "DEBUG ONLY: entering ~DefaultCallback");
79 // delete boss_; MUST BE DELETED OUTSIDE
80 // BECAUSE IT IS NOT OWNED BY THIS OBJECT
81 }
82
83
84 /**
85 * This is the callback method invoked from the server
86 * informing the client in an asynchronous mode about new messages.
87 * <p />
88 * You don't need to use this little method, but it nicely converts
89 * the raw CORBA BlasterCallback.update() with raw Strings and arrays
90 * in corresponding objects and calls for every received message
91 * the org::xmlBlaster::client::I_Callback.update().
92 * <p />
93 * So you should implement in your client the org::xmlBlaster::client::I_Callback interface -
94 * suppling the update() method.
95 *
96 * @param loginName The name to whom the callback belongs
97 * @param msgUnit Contains a org::xmlBlaster::util::MessageUnit structs (your message)
98 * @param qos Quality of Service of the org::xmlBlaster::util::MessageUnit
99 */
100 serverIdl::XmlTypeArr* update(const char* sessionId,
101 const serverIdl::MessageUnitArr& msgUnitArr)
102 UPDATE_THROW_SPECIFIER;
103
104 /**
105 * This is the oneway variant, not returning a value (no application level ACK).
106 * @see update()
107 */
108 void updateOneway(const char* sessionId, const serverIdl::MessageUnitArr& msgUnitArr) PING_THROW_SPECIFIER;
109
110 /**
111 * Check the callback server.
112 * @see xmlBlaster.idl
113 */
114 char *ping(const char *qos) PING_THROW_SPECIFIER;
115
116 }; // class DefaultCallback
117 }}}}} // namespace
118
119
120 #endif
syntax highlighted by Code2HTML, v. 0.9.1