1 /*------------------------------------------------------------------------------
2 Name: DispatchManager.cpp
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 Comment: Manager to retrieve the correct callback protocol implementation
6 ------------------------------------------------------------------------------*/
7
8 /**
9 * It returns the appropriate implementation of the I_CallbackServer
10 * interface (note that this is a class in c++) for the given protocol.
11 * with your own lowlevel SOCKET or CORBA coding as well.
12 *
13 * @see org.xmlBlaster.client.protocol.I_CallbackServer
14 * @author <a href="mailto:michele@laghi.eu">Michele Laghi</a>.
15 */
16
17 #include <util/dispatch/DispatchManager.h>
18 // #include <util/dispatch/ConnectionsHandler.h>
19 #ifdef COMPILE_CORBA_PLUGIN
20 # include <client/protocol/corba/CorbaDriverFactory.h>
21 #endif
22 #ifdef COMPILE_SOCKET_PLUGIN
23 # include <client/protocol/socket/SocketDriverFactory.h>
24 #endif
25 #include <util/Global.h>
26
27 namespace org { namespace xmlBlaster { namespace util { namespace dispatch {
28
29 using namespace std;
30 using namespace org::xmlBlaster::util;
31 using namespace org::xmlBlaster::client::protocol;
32
33 DispatchManager::DispatchManager(Global& global)
34 : ME("DispatchManager"),
35 global_(global),
36 log_(global.getLog("org.xmlBlaster.util.dispatch"))
37 {
38 if (log_.call()) log_.call(ME, "::constructor");
39 }
40
41
42 DispatchManager::~DispatchManager()
43 {
44 if (log_.call()) log_.call(ME, "::destructor");
45 }
46
47 void DispatchManager::releasePlugin(const string& instanceName, const string& type, const string& version)
48 {
49 if (log_.call()) log_.call(ME, "::releasePlugin");
50 if (log_.trace())
51 log_.trace(ME, string("releasePlugin: type: '") + type + string("', version: '") + version + "' for instance '" + instanceName + "'");
52 if (type == Constants::IOR) {
53 # ifdef COMPILE_CORBA_PLUGIN
54 org::xmlBlaster::client::protocol::corba::CorbaDriverFactory::getFactory(global_).killDriverInstance(&global_);
55 # endif
56 return;
57 }
58 else if (type == Constants::SOCKET) {
59 # ifdef COMPILE_SOCKET_PLUGIN
60 org::xmlBlaster::client::protocol::socket::SocketDriverFactory::getFactory(global_).killDriverInstance(&global_);
61 return;
62 # endif
63 }
64 string embeddedMsg = string("plugin: '") + type +
65 string("' and version: '") + version +
66 string("' not supported");
67 throw XmlBlasterException(RESOURCE_CONFIGURATION_PLUGINFAILED,
68 "client-c++",
69 ME + string("::releasePlugin"),
70 "en",
71 global_.getVersion() + " " + global_.getBuildTimestamp(),
72 "",
73 "",
74 embeddedMsg);
75 }
76
77 I_XmlBlasterConnection& DispatchManager::getPlugin(const string& instanceName, const string& type, const string& version)
78 {
79 if (log_.call()) log_.call(ME, "::getPlugin");
80 if (log_.trace())
81 log_.trace(ME, string("getPlugin: type: '") + type + string("', version: '") + version + "' for instance '" + instanceName + "'");
82
83 if (type == Constants::IOR) {
84 # ifdef COMPILE_CORBA_PLUGIN
85 return org::xmlBlaster::client::protocol::corba::CorbaDriverFactory::getFactory(global_).getDriverInstance(&global_);
86 # endif
87 }
88 else if (type == Constants::SOCKET) {
89 # ifdef COMPILE_SOCKET_PLUGIN
90 return org::xmlBlaster::client::protocol::socket::SocketDriverFactory::getFactory(global_).getDriverInstance(&global_);
91 # endif
92 }
93
94 // add here other protocols ....
95
96 string embeddedMsg = string("plugin: '") + type +
97 string("' and version: '") + version +
98 string("' not supported");
99 throw XmlBlasterException(RESOURCE_CONFIGURATION_PLUGINFAILED,
100 "client-c++",
101 ME + string("::getPlugin"),
102 "en",
103 global_.getVersion() + " " + global_.getBuildTimestamp(),
104 "",
105 "",
106 embeddedMsg);
107 }
108
109
110 ConnectionsHandler* DispatchManager::getConnectionsHandler(const string& instanceName)
111 {
112 // it makes sense to have one per XmlBlasterAccess (must be destructed by the invoker of this method !!!)
113 return new ConnectionsHandler(global_, instanceName);
114 }
115
116
117 }}}} // namespaces
syntax highlighted by Code2HTML, v. 0.9.1