00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00046
00047 #ifndef __B2BITS_AdminApplication_h__
00048 #define __B2BITS_AdminApplication_h__
00049 #include <list>
00050 #include <xercesc/util/XercesDefs.hpp>
00051 #include "B2BITS_Application.h"
00052 #include "B2BITS_Statistics.h"
00053 #include "B2BITS_Mutex.h"
00054
00055 XERCES_CPP_NAMESPACE_BEGIN
00056 class DOMNode;
00057 class DOMDocument;
00058 XERCES_CPP_NAMESPACE_END
00059
00060 namespace Engine{
00062 const std::string RESULT_SUCCESS = "0";
00064 const std::string RESULT_NOT_IMPLEMENTED = "1";
00066 const std::string RESULT_NOT_ENOUGH_PARAMETERS = "2";
00068 const std::string RESULT_UNKNOWN_SESSION = "3";
00070 const std::string RESULT_INCORRECT_VALUE = "4";
00072 const std::string RESULT_ENGINE_EXCEPTION = "5";
00074 const std::string RESULT_UNKNOWN_ERROR = "6";
00076 const std::string RESULT_OPERATION_REJECTED = "7";
00078 const std::string RESULT_CONDITIONS_LACK = "8";
00080 const std::string RESULT_INVALIDARG = "9";
00082 const std::string RESULT_LOGIC_ERROR = "10";
00084 const std::string RESULT_RUNTIME_ERROR = "11";
00085
00089 class V12_API AdminApplication : protected Application
00090 {
00091 protected:
00107 protected:
00108 typedef std::map<std::string, std::string> CommandTable;
00109
00110
00111 public:
00112
00114 struct Context
00115 {
00117 const Session& session_;
00119 const FIXMessage& message_;
00120 Context(const Session& sn, const FIXMessage& msg) : session_(sn), message_(msg) {};
00121 };
00122
00123 public:
00124 AdminApplication();
00125 virtual ~AdminApplication();
00126
00128 void bindSession(Session* pSession);
00129
00131 void terminate();
00132 protected:
00140 virtual bool process(const std::string& action, const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00141
00146 void sendResponse(const XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* response, const Context& context) const;
00147
00152 virtual void sendResponse(const std::string& response, const Context& context) const;
00153
00162 void sendResponse(const std::string& resultCode, const std::string& description, const std::string& additionalData, const Context& context) const;
00163
00168 virtual void getAvailableCommands(CommandTable* commands) const;
00169
00182 virtual bool process(const FIXMessage& msg, const Session& sn);
00183
00187 virtual void OnBindAdminSession(const Session* pSession) {};
00188
00192 void sendReject(const Session& sn, const FIXMessage& msg, const std::string& text );
00193
00200 virtual void onLogonEvent(const LogonEvent* event, const Session& sn);
00201
00209 virtual void onLogoutEvent(const LogoutEvent* event, const Session& sn) {};
00210
00218 virtual void onUnexpectedMessageEvent(const UnexpectedMessageEvent* , const Session& ){}
00219
00226 virtual void onSequenceGapEvent(const SequenceGapEvent* event, const Session& sn) {};
00227
00234 virtual void onSessionLevelRejectEvent(const SessionLevelRejectEvent* event, const Session& sn) {};
00235
00240 virtual void onMsgRejectEvent(const MsgRejectEvent* event, const Session& sn) {};
00241
00251 virtual void onHeartbeatWithTestReqIDEvent(const HeartbeatWithTestReqIDEvent& event, const Session& sn) {};
00252
00259 virtual void onResendRequestEvent(const ResendRequestEvent& event, const Session& sn) {};
00260
00267 virtual void onNewStateEvent(const NewStateEvent& event, const Session& sn) {};
00268
00275 virtual void onUnableToRouteMessage(const UnableToRouteMessageEvent& event, const Session& sn) {};
00276
00288 virtual bool onResend(const FIXMessage& msg, const Session& sn) {return true;}
00289
00291
00295 void executeHelp(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00296
00300 void executeSessionStatus(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00301
00305 void executeSessionList(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00306
00310 void executeSessionStat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00311
00315 void executeGeneralSessionsStat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00316
00317
00321 void executeCreateAcceptor(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00322
00326 void executeDelete(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00327
00331 void executeAverageReceivedStat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00332
00336 void executeAverageSentStat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00337
00341 void executeAverageValidateStat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00342
00346 void executeReceivedStat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00347
00351 void executeSentStat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00352
00356 void executeProceedStat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00357
00361 void executeToBackup(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00362
00366 void executeChangeSeqNum(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00367
00371 void executeResetSeqNum(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00372
00376 void executeTestRequest(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00377
00381 void executeHeartbeat(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00382
00386 void executeSendMessage(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00387
00391 void executeDeleteAll(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const Context& context);
00392
00393 protected:
00394
00395
00399 bool getChildNodeValue(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const XMLCh* name, std::string* value ) const;
00400
00404 bool getChildNodeValues(
00405 const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* parentNode,
00406 const XMLCh* subnodeName,
00407 const XMLCh* paramName,
00408 std::list<std::string>& values ) const;
00409
00410
00414 bool getChildNodeValues(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const XMLCh* name, std::list<std::string>& values ) const;
00415
00416
00420 bool getChildNodeValueInt(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const XMLCh* name, int* value, std::string* ) const;
00421
00425 bool getChildNodeValueBool(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, const XMLCh* name, bool* value, std::string* ) const;
00426
00427 private:
00428
00432 FIXMessage* createLogon(FIXVersion version, const SessionExtraParameters* params, int HBI) const;
00433
00437 bool getSenderTarget(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, std::string* sender, std::string* target, const Context& context) const;
00438
00442 bool getVersionType(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* element, FIXVersion* version, std::string* type, const Context& context) const;
00443
00447 void createMsgProtocolTypeTSet(FIXVersion version, const std::string& type, std::set<StatisticsProvider::MsgProtocolTypeT>* typeSet) const ;
00448
00452 Session* findSession(const std::string& sender, const std::string& target, const Context& context) const;
00453
00457 void terminateSession(Session* session, bool sendLogout, const std::string& logoutReason) const;
00458
00459 void clearSessionList();
00460
00461 private:
00462
00466 typedef std::map<std::string, Session*> SESSIONS_CONTAINER;
00467
00471 SESSIONS_CONTAINER sessions_;
00472
00474 bool bStopped_;
00475
00477 System::Mutex lock_;
00478 };
00479
00480 }
00481
00482 #endif //__B2BITS_AdminApplication_h__