Changeset 3350

Show
Ignore:
Timestamp:
02/01/10 15:42:38 (6 weeks ago)
Author:
trichards
Message:

Implemented getMessageId and getRequestMessageId methods to ZBoostNetworking protocol classes.
I still think getMessageId is wrong, but I'll fix that later. I think I need to add a global unique messageId generator in ApplicationServer? instead of having one per Message implementation.

Location:
plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/XML/I_XMLResponse.hpp

    r1236 r3350  
    7575    /// @{ 
    7676public: 
    77     static pResponse_type createResponse(pEndpoint_type _pDestinationEndpoint, StatusType _status, const std::string& _body, const std::string& _contentType = "text/html"); 
     77    static pResponse_type createResponse(pEndpoint_type _pDestinationEndpoint,  
     78        StatusType _status, const std::string& _body,  
     79        unsigned int _requestMessageId, 
     80        const std::string& _contentType = "text/html"); 
    7881    /// @} 
    7982 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Message.cpp

    r1086 r3350  
    8282 
    8383//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     84unsigned int  
     85Message::getMessageId() const 
     86{ 
     87    static Zen::Threading::SpinLock sm_spinLock; 
     88    static unsigned int sm_lastId = 0; 
     89 
     90    Zen::Threading::xCriticalSection lock(sm_spinLock); 
     91    return ++sm_lastId; 
     92} 
     93 
     94//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    8495}   // namespace HTTP 
    8596}   // namespace AppServer 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Message.hpp

    r1086 r3350  
    4343    virtual pEndpoint_type getDestinationEndpoint(); 
    4444    virtual pResourceLocation_type getDestinationLocation(); 
     45    virtual unsigned int getMessageId() const; 
    4546    virtual void serialize(boost::archive::polymorphic_iarchive& _archive, const int _version); 
    4647    virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Reply.cpp

    r1494 r3350  
    261261} 
    262262 
     263//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     264unsigned int 
     265Reply::getMessageId() const 
     266{ 
     267    // This really shouldn't be used for HTTP messages. 
     268    return 0; 
     269} 
     270 
     271//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     272unsigned int 
     273Reply::getRequestMessageId() const 
     274{ 
     275    // This really shouldn't be used for HTTP messages. 
     276    return 0; 
     277} 
    263278//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    264279void 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Reply.hpp

    r3332 r3350  
    22// Zen Enterprise Framework 
    33// 
    4 // Copyright (C) 2001 - 2009 Tony Richards 
     4// Copyright (C) 2001 - 2010 Tony Richards 
    55// 
    66//  This software is provided 'as-is', without any express or implied 
     
    6363    virtual pResourceLocation_type getDestinationLocation(); 
    6464    virtual pMessageHeader_type getMessageHeader() const; 
     65    virtual unsigned int getMessageId() const; 
    6566    virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); 
    6667    virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version); 
     
    8990    /// @{ 
    9091public: 
    91              Reply(pEndpoint_type _pDestinationEndpoint, StatusType _status, const std::string& _body, const std::string& _contentType); 
     92             Reply(pEndpoint_type _pDestinationEndpoint, StatusType _status, const std::string& _body,  
     93                 const std::string& _contentType); 
    9294             Reply(); 
    9395    virtual ~Reply(); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Request.cpp

    r1494 r3350  
    22// Zen Enterprise Framework 
    33// 
    4 // Copyright (C) 2001 - 2009 Tony Richards 
     4// Copyright (C) 2001 - 2010 Tony Richards 
    55// 
    66//  This software is provided 'as-is', without any express or implied 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/HTTP/Request.hpp

    r1494 r3350  
    22// Zen Enterprise Framework 
    33// 
    4 // Copyright (C) 2001 - 2009 Tony Richards 
     4// Copyright (C) 2001 - 2010 Tony Richards 
    55// 
    66//  This software is provided 'as-is', without any express or implied 
     
    5656    virtual pResourceLocation_type getDestinationLocation() { return Message::getDestinationLocation(); } 
    5757    virtual pMessageHeader_type getMessageHeader() const; 
     58    virtual unsigned int getMessageId() const { return Message::getMessageId(); } 
    5859    virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); 
    5960    virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/I_XMLResponse.cpp

    r1236 r3350  
    6868//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    6969I_XMLResponse::pResponse_type 
    70 I_XMLResponse::createResponse(pEndpoint_type _pDestinationEndpoint, StatusType _status, const std::string& _body, const std::string& _contentType) 
     70I_XMLResponse::createResponse(pEndpoint_type _pDestinationEndpoint, StatusType _status,  
     71                              const std::string& _body, unsigned int _requestMessageId, 
     72                              const std::string& _contentType) 
    7173{ 
    72     Reply* pReply = new XML::Reply(_pDestinationEndpoint, _status, _body, _contentType); 
     74    Reply* pReply = new XML::Reply(_pDestinationEndpoint, _status, _body, _contentType, _requestMessageId); 
    7375 
    7476    pResponse_type pResponse(pReply, destroyResponse); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Message.cpp

    r1237 r3350  
    8484 
    8585//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     86unsigned int  
     87Message::getMessageId() const 
     88{ 
     89    static Zen::Threading::SpinLock sm_spinLock; 
     90    static unsigned int sm_lastId = 0; 
     91 
     92    Zen::Threading::xCriticalSection lock(sm_spinLock); 
     93    return ++sm_lastId; 
     94} 
     95 
     96//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    8697}   // namespace XML 
    8798}   // namespace AppServer 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Message.hpp

    r1237 r3350  
    4545    virtual pEndpoint_type getDestinationEndpoint(); 
    4646    virtual pResourceLocation_type getDestinationLocation(); 
     47    virtual unsigned int getMessageId() const; 
    4748    virtual void serialize(boost::archive::polymorphic_iarchive& _archive, const int _version); 
    4849    virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version); 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Reply.cpp

    r1494 r3350  
    102102 
    103103//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    104 Reply::Reply(pEndpoint_type _pDestinationEndpoint, StatusType _status, const std::string& _body, const std::string& _contentType) 
     104Reply::Reply(pEndpoint_type _pDestinationEndpoint, StatusType _status,  
     105             const std::string& _body, const std::string& _contentType, 
     106             unsigned int _requestMessageId) 
    105107:   m_pDestinationEndpoint(_pDestinationEndpoint) 
    106108,   m_content(_body) 
     109,   m_requestMessageId(_requestMessageId) 
    107110{ 
    108111    m_status = _status; 
     
    118121//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
    119122Reply::Reply() 
     123:   m_requestMessageId(0) 
    120124{ 
    121125} 
     
    153157{ 
    154158    throw Utility::runtime_exception("Reply::getMessageHeader(): Error, not implemented."); 
     159} 
     160 
     161//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     162unsigned int  
     163Reply::getMessageId() const 
     164{ 
     165    static Zen::Threading::SpinLock sm_spinLock; 
     166    static unsigned int sm_lastId = 0; 
     167 
     168    Zen::Threading::xCriticalSection lock(sm_spinLock); 
     169    return ++sm_lastId; 
     170} 
     171 
     172//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 
     173unsigned int 
     174Reply::getRequestMessageId() const 
     175{ 
     176    return m_requestMessageId; 
    155177} 
    156178 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Reply.hpp

    r1494 r3350  
    22// Zen Enterprise Framework 
    33// 
    4 // Copyright (C) 2001 - 2009 Tony Richards 
     4// Copyright (C) 2001 - 2010 Tony Richards 
    55// Copyright (C) 2008 - 2009 Matthew Alan Gray 
    66// 
     
    6565    virtual pResourceLocation_type getDestinationLocation(); 
    6666    virtual pMessageHeader_type getMessageHeader() const; 
     67    virtual unsigned int getMessageId() const; 
    6768    virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); 
    6869    virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version); 
     70    /// @} 
     71 
     72    /// @name I_Response implementation 
     73    /// @{ 
     74public: 
     75    virtual unsigned int getRequestMessageId() const; 
    6976    /// @} 
    7077 
     
    8592    /// @{ 
    8693public: 
    87              Reply(pEndpoint_type _pDestinationEndpoint, StatusType _status, const std::string& _body, const std::string& _contentType); 
     94             Reply(pEndpoint_type _pDestinationEndpoint, StatusType _status,  
     95                 const std::string& _body, const std::string& _contentType,  
     96                 unsigned int _requestMessageId); 
    8897             Reply(); 
    8998    virtual ~Reply(); 
     
    98107 
    99108    pEndpoint_type      m_pDestinationEndpoint; 
     109    unsigned int        m_requestMessageId; 
    100110 
    101111    //Buffers_type        m_buffers; 
  • plugins/branches/0185_GEN_PHYSICS_REFACTOR_2/ZBoostNetworking/src/XML/Request.hpp

    r1494 r3350  
    22// Zen Enterprise Framework 
    33// 
    4 // Copyright (C) 2001 - 2009 Tony Richards 
     4// Copyright (C) 2001 - 2010 Tony Richards 
    55// Copyright (C) 2008 - 2009 Matthew Alan Gray 
    66// 
     
    5858    virtual pResourceLocation_type getDestinationLocation() { return Message::getDestinationLocation(); } 
    5959    virtual pMessageHeader_type getMessageHeader() const; 
     60    virtual unsigned int getMessageId() const { return Message::getMessageId(); } 
    6061    virtual void serialize(pMessageHeader_type _pHeader, boost::archive::polymorphic_iarchive& _archive, const int _version); 
    6162    virtual void serialize(boost::archive::polymorphic_oarchive& _archive, const int _version);