susantha    2003/08/13 07:07:47

  Modified:    c/src/engine Main.c HandlerPool.h HandlerPool.cpp
                        HandlerLoader.h HandlerLoader.cpp HandlerChain.h
                        HandlerChain.cpp AxisEngine.h AxisEngine.cpp
                        Axis.cpp
  Added:       c/src/engine SharedObject.h SharedObject.cpp
                        SessionScopeHandlerPool.h
                        SessionScopeHandlerPool.cpp SerializerPool.h
                        SerializerPool.cpp RequestScopeHandlerPool.h
                        RequestScopeHandlerPool.cpp DeserializerPool.h
                        DeserializerPool.cpp AppScopeHandlerPool.h
                        AppScopeHandlerPool.cpp
  Log:
  After making code base thread safe. Also changed Module writing API accordingly. 
WSDD module too improved.
  
  Revision  Changes    Path
  1.6       +13 -12    xml-axis/c/src/engine/Main.c
  
  Index: Main.c
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/Main.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Main.c    5 Aug 2003 12:28:09 -0000       1.5
  +++ Main.c    13 Aug 2003 14:07:47 -0000      1.6
  @@ -68,10 +68,10 @@
   #include <malloc.h>
   #include "../common/Packet.h"
   
  -extern int process_request(soapstream *);
  +extern int process_request(Ax_soapstream *str);
   
   //soap request with headers
  -char* ip = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope \
  +//char* ip = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope \
                        xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"; \
                        xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; \
                        xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\";> \
  @@ -79,7 +79,7 @@
                        soapenv:mustUnderstand=\"true\" >Hello Req Header 
Val</t:Transaction></soapenv:Header> \
                        <soapenv:Body><add 
soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";><op1 
xsi:type=\"xsd:int\">3</op1><op2 
xsi:type=\"xsd:int\">4</op2></add></soapenv:Body></soapenv:Envelope>";
   
  -//char* ip = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope 
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"; 
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\";><soapenv:Body><add 
soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";><op1 
xsi:type=\"xsd:int\">3</op1><op2 
xsi:type=\"xsd:int\">4</op2></add></soapenv:Body></soapenv:Envelope>";
  +char* ip = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope 
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"; 
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\";><soapenv:Body><add 
soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";><op1 
xsi:type=\"xsd:int\">3</op1><op2 
xsi:type=\"xsd:int\">4</op2></add></soapenv:Body></soapenv:Envelope>";
   
   //   char* ip = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope 
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"; 
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; 
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\";><soapenv:Body><echo 
soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";><op1 
xsi:type=\"xsd:string\">Hello World!</op1></echo></soapenv:Body></soapenv:Envelope>";
   
  @@ -181,26 +181,27 @@
                </Point>\
                </enc:Array> </EchoPointArray></soapenv:Body></soapenv:Envelope>";
   
  -int main() { 
  -     
  -     soapstream* str = (soapstream*)malloc(sizeof(soapstream));
  +int main() 
  +{            
  +     Ax_soapstream* str = (Ax_soapstream*)malloc(sizeof(Ax_soapstream));
        str->trtype = APTHTTP;
  +     str->sessionid = "somesessionid";
  +     str->so.http.ip_method = AXIS_HTTP_POST;
   
  -     str->so.http.ip_method=POST;
  -
  -     str->so.http.ip_headers = (header*)malloc(sizeof(header));
  +     str->so.http.ip_headers = (Ax_header*)malloc(sizeof(Ax_header));
        str->so.http.ip_headers->headername = SOAPACTIONHEADER;
  -     str->so.http.ip_headers->headervalue = "\"Maths\"";     
  +     str->so.http.ip_headers->headervalue = "\"CalculatorService\""; 
        str->so.http.ip_headercount = 1;
   
        printf("soap request :\n %s\n", ip);
   
  +     initialize_module();
        process_request(str);   
   
        return 0;
   }
   
  -int send_response_bytes(char * res) {
  +int send_response_bytes(char * res, void* pOutputStream) {
   
        printf("sending SOAP response : \n%s\n", res);
   
  @@ -218,7 +219,7 @@
        return 0;
   }
   
  -int send_transport_information(soapstream* sSoapstream) {
  +int send_transport_information(Ax_soapstream* sSoapstream) {
   
        return 0;
   }
  
  
  
  1.2       +18 -40    xml-axis/c/src/engine/HandlerPool.h
  
  Index: HandlerPool.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/HandlerPool.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HandlerPool.h     25 Jun 2003 05:13:45 -0000      1.1
  +++ HandlerPool.h     13 Aug 2003 14:07:47 -0000      1.2
  @@ -64,6 +64,7 @@
   // HandlerPool.h: interface for the HandlerPool class.
   //
   //////////////////////////////////////////////////////////////////////
  +#pragma warning (disable : 4503)
   
   #if !defined(AFX_HANDLERPOOL_H__6C2A4C96_7115_43C6_9EFA_CDAC9247D109__INCLUDED_)
   #define AFX_HANDLERPOOL_H__6C2A4C96_7115_43C6_9EFA_CDAC9247D109__INCLUDED_
  @@ -77,8 +78,9 @@
   #include "../common/BasicHandler.h"
   #include "HandlerLoader.h"
   #include "HandlerChain.h"
  +#include "SharedObject.h"
   
  -#include <map>
  +#include <list>
   #include <string>
   
   using namespace std;
  @@ -87,52 +89,28 @@
    *
    *
    */
  -class HandlerPool  
  +class HandlerPool : protected SharedObject
   {
   private:
  -     class LoadedHandler {
  -     public:
  -             HandlerLoader* m_DL;
  -             BasicHandler* m_Handler;
  -             LoadedHandler(string &sFile, int nOptions=0);
  -             ~LoadedHandler();
  -     };
  +     int GetHandler(BasicHandler** ppHandler, string& sSessionId, int nScope, int 
nLibId);
  +     int PoolHandler(string& sSessionId, BasicHandler* pHandler, int nScope, int 
nLibId);
  +     int GetHandlerChain(string& sSessionId, HandlerChain** pChain, const 
WSDDHandlerList* pHandlerList);
   public:
  -     void UnloadWebService(WSDDService* pService);
  -     BasicHandler* LoadWebService(WSDDService* pService);
  -     void UnLoadServiceRequestFlowHandlers(WSDDHandlerList *pHandlerList);
  -     void UnLoadServiceResponseFlowHandlers(WSDDHandlerList *pHandlerList);
  -     int LoadServiceResponseFlowHandlers(WSDDHandlerList* pHandlerList);
  -     int LoadServiceRequestFlowHandlers(WSDDHandlerList* pHandlerList);
  -     HandlerChain* GetTransportRequestFlowHandlerChain(AXIS_PROTOCOL_TYPE Protocol);
  -     HandlerChain* GetTransportResponseFlowHandlerChain(AXIS_PROTOCOL_TYPE 
Protocol);
  -     HandlerChain* GetGlobalResponseFlowHandlerChain();
  -     HandlerChain* GetGlobalRequestFlowHandlerChain();
  -     HandlerChain* GetServiceRequestFlowHandlerChain();
  -     HandlerChain* GetServiceResponseFlowHandlerChain();
  -     //Following will load handlers and keep them in private members.
  -     int LoadTransportRequestFlowHandlers(AXIS_PROTOCOL_TYPE Protocol, 
WSDDHandlerList* pHandlerList);
  -     int LoadTransportResponseFlowHandlers(AXIS_PROTOCOL_TYPE Protocol, 
WSDDHandlerList* pHandlerList);
  -     int LoadGlobalResponseFlowHandlers(WSDDHandlerList* pHandlerList);
  -     int LoadGlobalRequestFlowHandlers(WSDDHandlerList* pHandlerList);
  +     int GetGlobalRequestFlowHandlerChain(HandlerChain** ppChain, string& 
sSessionId);
  +     int GetGlobalResponseFlowHandlerChain(HandlerChain** ppChain, string& 
sSessionId);
  +     int GetTransportRequestFlowHandlerChain(HandlerChain** ppChain, string& 
sSessionId, AXIS_PROTOCOL_TYPE Protocol);
  +     int GetTransportResponseFlowHandlerChain(HandlerChain** ppChain, string& 
sSessionId, AXIS_PROTOCOL_TYPE Protocol);
  +     int GetRequestFlowHandlerChain(HandlerChain** ppChain, string& sSessionId, 
const WSDDService* pService);
  +     int GetResponseFlowHandlerChain(HandlerChain** ppChain, string& sSessionId, 
const WSDDService* pService);
  +     void PoolHandlerChain(HandlerChain* pChain, string& sSessionId);
  +
  +     int GetWebService(BasicHandler** ppHandler, string& sSessionId, const 
WSDDHandler* pService);
  +     void PoolWebService(string& sSessionId, BasicHandler* pHandler, const 
WSDDHandler* pHandlerInfo);
   
        HandlerPool();
        virtual ~HandlerPool();
   private:
  -     BasicHandler* GetHandler(WSDDHandler* pHandlerInfo);
  -     int UnLoadHandler(WSDDHandler* pHandlerInfo);
  -     BasicHandler* LoadHandler(WSDDHandler* pHandlerInfo);
  -
  -private:
  -     void UnloadHandlerList(WSDDHandlerList *pHandlerList);
  -     HandlerChain* LoadHandlerChain(WSDDHandlerList* pHandlerList);
  -     map<string, LoadedHandler*> m_Handlers; //all handlers will be retained here
  -     HandlerChain* m_pGReqFChain; //Global Handler chain(Request)
  -     HandlerChain* m_pGResFChain; //Global Handler chain(Response)
  -     HandlerChain* m_pServiceReqFChain; //Service specific Handler chain(Request)
  -     HandlerChain* m_pServiceResFChain; //Service specific Handler chain(Response)
  -     map<AXIS_PROTOCOL_TYPE, HandlerChain*> m_TReqFChains; //Transport Handler 
chains (Request)
  -     map<AXIS_PROTOCOL_TYPE, HandlerChain*> m_TResFChains; //Transport Handler 
chains (Response)
  +     list<HandlerChain*> m_ChainStore;
   };
   
   #endif // 
!defined(AFX_HANDLERPOOL_H__6C2A4C96_7115_43C6_9EFA_CDAC9247D109__INCLUDED_)
  
  
  
  1.6       +177 -197  xml-axis/c/src/engine/HandlerPool.cpp
  
  Index: HandlerPool.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/HandlerPool.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HandlerPool.cpp   5 Aug 2003 05:48:37 -0000       1.5
  +++ HandlerPool.cpp   13 Aug 2003 14:07:47 -0000      1.6
  @@ -66,279 +66,259 @@
   //////////////////////////////////////////////////////////////////////
   
   #include "HandlerPool.h"
  -
  +#include "AppScopeHandlerPool.h"
  +#include "RequestScopeHandlerPool.h"
  +#include "SessionScopeHandlerPool.h"
  +#include "../wsdd/WSDDDeployment.h"
   //////////////////////////////////////////////////////////////////////
   // Construction/Destruction
   //////////////////////////////////////////////////////////////////////
   #include "../common/Debug.h"
   
  +extern AppScopeHandlerPool g_AppScopeHandlerPool;
  +extern RequestScopeHandlerPool g_RequestScopeHandlerPool;
  +extern SessionScopeHandlerPool g_SessionScopeHandlerPool;
  +extern WSDDDeployment g_WSDDDeployment;
  +
   HandlerPool::HandlerPool()
   {
  -     m_pGReqFChain = NULL;
  -     m_pGResFChain = NULL;
  -     m_pServiceReqFChain = NULL;
  -     m_pServiceResFChain = NULL;     
   }
   
   HandlerPool::~HandlerPool()
   {
  -     //unload all the handlers
  -     LoadedHandler* pLh = NULL;
  -     for (map<string, LoadedHandler*>::iterator it = m_Handlers.begin();
  -     it != m_Handlers.end(); it++)
  -     {
  -             pLh = (*it).second;
  -             pLh->m_DL->Finalize();
  -             delete pLh;
  -     }
  -     m_Handlers.clear();
  -
  -     //delete all handlers and chains etc
  -     if(m_pGReqFChain) delete m_pGReqFChain;
  -     if(m_pGResFChain) delete m_pGResFChain;
  -     if(m_pServiceReqFChain) delete m_pServiceReqFChain;
  -     if(m_pServiceResFChain) delete m_pServiceResFChain;
  -
  -     map<AXIS_PROTOCOL_TYPE, HandlerChain*>::iterator it1;
  -     for (it1 = m_TReqFChains.begin();it1 != m_TReqFChains.end(); it1++)
  -     {
  -             delete (*it1).second;
  -     }
  -     for (it1 = m_TResFChains.begin();it1 != m_TResFChains.end(); it1++)
  -     {
  -             delete (*it1).second;
  -     }
  -}
  -
  -HandlerPool::LoadedHandler::LoadedHandler(string &sFile, int nOptions)
  -{
  -     m_DL = new HandlerLoader(sFile, nOptions);
  -     m_Handler = NULL;
   }
   
  -HandlerPool::LoadedHandler::~LoadedHandler()
  +int HandlerPool::GetHandler(BasicHandler** ppHandler, string& sSessionId, int 
nScope, int nLibId)
   {
  -     delete m_DL;
  -}
  +     *ppHandler = NULL;
  +     int Status = FAIL;
   
  -BasicHandler* HandlerPool::LoadHandler(WSDDHandler *pHandlerInfo)
  -{
  -     LoadedHandler* pLh = NULL;
  -     if (pHandlerInfo) 
  +     switch (nScope)
        {
  -    
  -             pLh = new LoadedHandler(pHandlerInfo->GetLibName(), RTLD_LAZY);
  -
  -             if (SUCCESS == pLh->m_DL->Initialize())
  -             {
  -
  -                     BasicHandler* pBh = pLh->m_DL->GetHandler();
  -      //BasicHandler* pBh = NULL;
  -                     if (pBh) 
  +     case AH_APPLICATION:
  +             do {
  +                     if ((Status = g_AppScopeHandlerPool.GetInstance(ppHandler, 
nLibId)) == SUCCESS)
                        {
  -                             pLh->m_Handler = pBh;
  -                             //Add to m_Handlers - place holder
  -                             m_Handlers[pHandlerInfo->GetLibName()] = pLh;
  -                             return pBh;
  +                             return Status;
  +                     }
  +                     else if (Status == HANDLER_BEING_USED)
  +                     { //block this thread not this object
  +                             #ifdef WIN32
  +                             Sleep(0);
  +                             #else
  +                             sleep(0);
  +                             #endif
                        }
                        else
                        {
  -                             //something wrong
  -        return NULL;
  +                             return Status;
                        }
  -             }
  -             else
  -             {
  -                     //Uninitialize, unload and delete pLh
  -             }
  +             } while (Status == HANDLER_BEING_USED);
  +             break;
  +     case AH_SESSION:
  +             return g_SessionScopeHandlerPool.GetInstance(sSessionId, ppHandler, 
nLibId);
  +     case AH_REQUEST:
  +             return g_RequestScopeHandlerPool.GetInstance(ppHandler, nLibId);
        }
  -     return NULL;
  +     return Status;
   }
   
  -int HandlerPool::UnLoadHandler(WSDDHandler *pHandlerInfo)
  +int HandlerPool::PoolHandler(string& sSessionId, BasicHandler* pHandler, int 
nScope, int nLibId)
   {
  -     LoadedHandler* pLh = NULL;
  -     if (m_Handlers.find(pHandlerInfo->GetLibName()) != m_Handlers.end())
  +     switch (nScope)
        {
  -             pLh = m_Handlers[pHandlerInfo->GetLibName()];
  -             pLh->m_DL->Finalize();
  -             m_Handlers.erase(pHandlerInfo->GetLibName());
  -             delete pLh;
  -             return SUCCESS;
  +     case AH_APPLICATION:
  +             g_AppScopeHandlerPool.PutInstance(pHandler, nLibId);
  +             break;
  +     case AH_SESSION:
  +             g_SessionScopeHandlerPool.PutInstance(sSessionId, pHandler, nLibId);
  +             break;
  +     case AH_REQUEST:
  +             g_RequestScopeHandlerPool.PutInstance(pHandler, nLibId);
  +             break;
        }
  -     return FAIL;
  +     return SUCCESS;
   }
   
  -BasicHandler* HandlerPool::GetHandler(WSDDHandler *pHandlerInfo)
  +int HandlerPool::GetGlobalRequestFlowHandlerChain(HandlerChain** ppChain, string& 
sSessionId)
   {
  -     if (m_Handlers.find(pHandlerInfo->GetLibName()) != m_Handlers.end())
  +     const WSDDHandlerList* pHandlerList = 
g_WSDDDeployment.GetGlobalRequestFlowHandlers();
  +     if (pHandlerList)
        {
  -             return m_Handlers[pHandlerInfo->GetLibName()]->m_Handler;
  +             return GetHandlerChain(sSessionId, ppChain, pHandlerList);
        }
  -     return NULL;
  -}
  -
  -HandlerChain* HandlerPool::GetGlobalRequestFlowHandlerChain()
  -{
  -     return m_pGReqFChain;
  -}
  -
  -HandlerChain* HandlerPool::GetGlobalResponseFlowHandlerChain()
  -{
  -     return m_pGResFChain;
  -}
  -
  -HandlerChain* HandlerPool::GetTransportRequestFlowHandlerChain(AXIS_PROTOCOL_TYPE 
Protocol)
  -{
  -     if (m_TReqFChains.find(Protocol) != m_TReqFChains.end())
  -             return m_TReqFChains[Protocol];
  -     return NULL;
  -}
  -
  -HandlerChain* HandlerPool::GetTransportResponseFlowHandlerChain(AXIS_PROTOCOL_TYPE 
Protocol)
  -{
  -     if (m_TReqFChains.find(Protocol) != m_TReqFChains.end())
  -             return m_TResFChains[Protocol];
  -     return NULL;
  -}
  -
  -HandlerChain* HandlerPool::GetServiceRequestFlowHandlerChain()
  -{
  -     return m_pServiceReqFChain;
  -}
  -
  -HandlerChain* HandlerPool::GetServiceResponseFlowHandlerChain()
  -{
  -     return m_pServiceResFChain;
  -}
  -
  -int HandlerPool::LoadTransportRequestFlowHandlers(AXIS_PROTOCOL_TYPE Protocol, 
WSDDHandlerList* pHandlerList)
  -{
  -     HandlerChain* pHc = LoadHandlerChain(pHandlerList);
  -     if (pHc)
  +     else
        {
  -             m_TReqFChains[Protocol] = pHc;
  -             return SUCCESS;
  +             *ppChain = NULL;
  +             return SUCCESS; //NO_HANDLERS_CONFIGURED
        }
  -     return FAIL;
   }
   
  -int HandlerPool::LoadTransportResponseFlowHandlers(AXIS_PROTOCOL_TYPE Protocol, 
WSDDHandlerList* pHandlerList)
  +int HandlerPool::GetGlobalResponseFlowHandlerChain(HandlerChain** ppChain, string& 
sSessionId)
   {
  -     HandlerChain* pHc = LoadHandlerChain(pHandlerList);
  -     if (pHc)
  +     const WSDDHandlerList* pHandlerList = 
g_WSDDDeployment.GetGlobalResponseFlowHandlers();
  +     if (pHandlerList)
  +     {
  +             return GetHandlerChain(sSessionId, ppChain, pHandlerList);
  +     }
  +     else
        {
  -             m_TResFChains[Protocol] = pHc;
  -             return SUCCESS;
  +             *ppChain = NULL;
  +             return SUCCESS; //NO_HANDLERS_CONFIGURED
        }
  -     return FAIL;
   }
   
  -int HandlerPool::LoadGlobalResponseFlowHandlers(WSDDHandlerList* pHandlerList)
  +int HandlerPool::GetTransportRequestFlowHandlerChain(HandlerChain** ppChain, 
string& sSessionId, AXIS_PROTOCOL_TYPE Protocol)
   {
  -     m_pGResFChain = LoadHandlerChain(pHandlerList);
  -     return (m_pGResFChain != NULL) ? SUCCESS:FAIL;
  +     const WSDDHandlerList* pHandlerList = 
g_WSDDDeployment.GetTransportRequestFlowHandlers(Protocol);
  +     if (pHandlerList)
  +     {
  +             return GetHandlerChain(sSessionId, ppChain, pHandlerList);
  +     }
  +     else
  +     {
  +             *ppChain = NULL;
  +             return SUCCESS; //NO_HANDLERS_CONFIGURED
  +     }
   }
   
  -int HandlerPool::LoadGlobalRequestFlowHandlers(WSDDHandlerList* pHandlerList)
  +int HandlerPool::GetTransportResponseFlowHandlerChain(HandlerChain** ppChain, 
string& sSessionId, AXIS_PROTOCOL_TYPE Protocol)
   {
  -     m_pGReqFChain = LoadHandlerChain(pHandlerList);
  -     return (m_pGReqFChain != NULL) ? SUCCESS:FAIL;
  +     const WSDDHandlerList* pHandlerList = 
g_WSDDDeployment.GetTransportResponseFlowHandlers(Protocol);
  +     if (pHandlerList)
  +     {
  +             return GetHandlerChain(sSessionId, ppChain, pHandlerList);
  +     }
  +     else
  +     {
  +             *ppChain = NULL;
  +             return SUCCESS; //NO_HANDLERS_CONFIGURED
  +     }
   }
   
  -int HandlerPool::LoadServiceRequestFlowHandlers(WSDDHandlerList *pHandlerList)
  +int HandlerPool::GetRequestFlowHandlerChain(HandlerChain** ppChain, string& 
sSessionId, const WSDDService* pService)
   {
  -     m_pServiceReqFChain = LoadHandlerChain(pHandlerList);
  -     return (m_pServiceReqFChain != NULL) ? SUCCESS:FAIL;
  +     const WSDDHandlerList* pHandlerList = pService->GetRequestFlowHandlers();
  +     if (pHandlerList)
  +     {
  +             return GetHandlerChain(sSessionId, ppChain, pHandlerList);
  +     }
  +     else
  +     {
  +             *ppChain = NULL;
  +             return SUCCESS; //NO_HANDLERS_CONFIGURED
  +     }
   }
   
  -int HandlerPool::LoadServiceResponseFlowHandlers(WSDDHandlerList *pHandlerList)
  +int HandlerPool::GetResponseFlowHandlerChain(HandlerChain** ppChain, string& 
sSessionId, const WSDDService* pService)
   {
  -     m_pServiceResFChain = LoadHandlerChain(pHandlerList);
  -     return (m_pServiceResFChain != NULL) ? SUCCESS:FAIL;
  +     const WSDDHandlerList* pHandlerList = pService->GetResponseFlowHandlers();
  +     if (pHandlerList)
  +     {
  +             return GetHandlerChain(sSessionId, ppChain, pHandlerList);
  +     }
  +     else
  +     {
  +             *ppChain = NULL;
  +             return SUCCESS; //NO_HANDLERS_CONFIGURED
  +     }
   }
   
  -void HandlerPool::UnLoadServiceRequestFlowHandlers(WSDDHandlerList *pHandlerList)
  +int HandlerPool::GetHandlerChain(string& sSessionId, HandlerChain** ppChain, const 
WSDDHandlerList *pHandlerList)
   {
  -     UnloadHandlerList(pHandlerList);
  -     delete m_pServiceReqFChain;
  -     m_pServiceReqFChain = NULL;
  -}
  +     lock();
  +     *ppChain = NULL;
  +     HandlerChain* pChain;
  +     //check m_ChainStore to get a HandlerChain
  +     if (!m_ChainStore.empty())
  +     {
  +             pChain = m_ChainStore.front();
  +             m_ChainStore.pop_front();
  +             pChain->Init();
  +     }
  +     else
  +     {
  +             pChain = new HandlerChain();
  +     }
   
  -void HandlerPool::UnLoadServiceResponseFlowHandlers(WSDDHandlerList *pHandlerList)
  -{
  -     UnloadHandlerList(pHandlerList);
  -     delete m_pServiceResFChain;
  -     m_pServiceResFChain = NULL;
  -}
  +     WSDDHandler* pWSDDH;
  +     BasicHandler* pBH;
  +     int Status = SUCCESS;
   
  -HandlerChain* HandlerPool::LoadHandlerChain(WSDDHandlerList *pHandlerList)
  -{
  -     DEBUG1("HandlerPool::LoadHandlerChain");
  -     int nLoaded = 0;
  -     HandlerChain* pHc = NULL;
  -     if (pHandlerList && !pHandlerList->empty())
  +     for (WSDDHandlerList::const_iterator it = pHandlerList->begin(); it != 
pHandlerList->end(); it++)
        {
  -             pHc = new HandlerChain();
  -             //BasicHandler* pBh = NULL;;
  -             Handler* pH = NULL;
  -             for (WSDDHandlerList::iterator it=pHandlerList->begin(); it != 
pHandlerList->end(); it++)
  +             pWSDDH = (*it);
  +             if ((Status = GetHandler(&pBH, sSessionId, 
pWSDDH->GetScope(),pWSDDH->GetLibId())) == SUCCESS)
                {
  -                     //if ((pBh = LoadHandler(*it)) != NULL)
  -                     DEBUG1("BEFORE BasicHandler *pBh = LoadHandler(*it);");
  -                     BasicHandler *pBh = LoadHandler(*it);
  -                     DEBUG1("AFTER BasicHandler *pBh = LoadHandler(*it);");
  -                     if (pBh)
  +                     if (NORMAL_HANDLER == pBH->GetType())
                        {
  -                             DEBUG1("BEFORE pH = static_cast<Handler*>(pBh);");
  -                             if (pBh->GetType() == NORMAL_HANDLER)
  -                                     pH = static_cast<Handler*>(pBh);
  -                             else
  -                                     pH = NULL;
  -                             DEBUG1("AFTER pH = static_cast<Handler*>(pBh);");
  -                             if (pH)
  -                             {          
  -                                     DEBUG1("if (pH)");
  -                                     pH->SetOptionList((*it)->GetOptionList());
  -                                     nLoaded++;
  -                                     pHc->AddHandler(pH);
  -                             }
  -                             else
  -                             {
  -                                     return NULL;
  -                             }
  +                             pChain->AddHandler(static_cast<Handler*>(pBH), 
pWSDDH->GetScope(), pWSDDH->GetLibId());
  +                     }
  +                     else
  +                     {
  +                             Status = WRONG_HANDLER_TYPE;
  +                             break;
                        }
                }
  -             if (0!=nLoaded) 
  +             else
                {
  -                     return pHc;
  +                     break;
                }
  -             else 
  +     }
  +     if (Status != SUCCESS) //some failure so undo whatever done here
  +     {
  +             string nosession = SESSIONLESSHANDLERS;
  +             for (pChain->m_itCurrHandler = pChain->m_HandlerList.begin(); 
pChain->m_itCurrHandler != pChain->m_HandlerList.end(); pChain->m_itCurrHandler++)
                {
  -                     delete pHc;
  -                     return NULL;
  +                     if ((*pChain->m_itCurrHandler).m_pHandler != NULL)
  +                     {
  +                             PoolHandler(nosession, 
(*pChain->m_itCurrHandler).m_pHandler, (*pChain->m_itCurrHandler).m_nScope, 
(*pChain->m_itCurrHandler).m_nLibId);
  +                     }
                }
  +             pChain->Fini();
  +             m_ChainStore.push_back(pChain);
  +             unlock();
  +             return Status;
  +     }
  +     else
  +     {
  +             *ppChain = pChain;
  +             unlock();
  +             return Status;
        }
  -     return NULL;
   }
   
  -void HandlerPool::UnloadHandlerList(WSDDHandlerList *pHandlerList)
  +void HandlerPool::PoolHandlerChain(HandlerChain* pChain, string& sSessionId)
   {
  -     if (pHandlerList && !pHandlerList->empty()) {
  -             for (WSDDHandlerList::iterator it=pHandlerList->begin();
  -             it != pHandlerList->end(); it++)
  +     for (pChain->m_itCurrHandler = pChain->m_HandlerList.begin(); 
pChain->m_itCurrHandler != pChain->m_HandlerList.end(); pChain->m_itCurrHandler++)
  +     {
  +             if ((*pChain->m_itCurrHandler).m_pHandler != NULL)
                {
  -                     UnLoadHandler(*it);
  +                     PoolHandler(sSessionId, (*pChain->m_itCurrHandler).m_pHandler, 
(*pChain->m_itCurrHandler).m_nScope, (*pChain->m_itCurrHandler).m_nLibId);
                }
        }
  +     pChain->Fini();
  +     lock();
  +     m_ChainStore.push_back(pChain);
  +     unlock();
   }
   
  -BasicHandler* HandlerPool::LoadWebService(WSDDService* pService)
  +int HandlerPool::GetWebService(BasicHandler** ppHandler, string& sSessionId, const 
WSDDHandler* pService)
   {
  -     return LoadHandler(pService);
  +     int Status;
  +     if ((Status = GetHandler(ppHandler, sSessionId, pService->GetScope(), 
pService->GetLibId())) == SUCCESS)
  +     {
  +             if (SUCCESS != (Status = (*ppHandler)->Init()))
  +             {
  +                     (*ppHandler)->Fini();
  +                     PoolHandler(sSessionId, *ppHandler, pService->GetScope(), 
pService->GetLibId());
  +                     *ppHandler = NULL;
  +             }
  +     }
  +     return Status;
   }
   
  -void HandlerPool::UnloadWebService(WSDDService* pService)
  +void HandlerPool::PoolWebService(string& sSessionId, BasicHandler* pHandler, const 
WSDDHandler *pHandlerInfo)
   {
  -     UnLoadHandler(pService);
  +     PoolHandler(sSessionId, pHandler, pHandlerInfo->GetScope(), 
pHandlerInfo->GetLibId());
   }
  
  
  
  1.2       +32 -17    xml-axis/c/src/engine/HandlerLoader.h
  
  Index: HandlerLoader.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/HandlerLoader.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HandlerLoader.h   25 Jun 2003 05:13:45 -0000      1.1
  +++ HandlerLoader.h   13 Aug 2003 14:07:47 -0000      1.2
  @@ -67,7 +67,9 @@
   #include "../common/MessageData.h"
   #include "../common/GDefine.h"
   #include "../common/WrapperClassHandler.h"
  +#include "SharedObject.h"
   
  +#include <map>
   #include <string>
   
   using namespace std;
  @@ -85,29 +87,42 @@
   #else //Linux
   #include <dlfcn.h>
   #define DLHandler void*
  -
   #endif
   
  -class HandlerLoader {
  +//status codes
  +#define HANDLER_INIT_FAIL    1
  +#define CREATION_FAILED              2
  +#define LOADLIBRARY_FAILED   3
  +#define LIBRARY_PATH_EMPTY   4
  +#define HANDLER_NOT_LOADED   5
  +#define HANDLER_BEING_USED   6
  +#define GET_HANDLER_FAILED   7
  +#define WRONG_HANDLER_TYPE   8
  +#define NO_HANDLERS_CONFIGURED       9
  +
  +class HandlerLoader : protected SharedObject
  +{
   private:
  -     BasicHandler* m_pClass;
  -     string m_sLib;
  -     int m_nLoadOptions;
  -     DLHandler m_Handler;
  -     CREATE_OBJECT m_Create;
  -     DELETE_OBJECT m_Delete;
  +     typedef struct HandlerInformation
  +     {
  +             string m_sLib;
  +             int m_nLoadOptions;
  +             DLHandler m_Handler;
  +             CREATE_OBJECT m_Create;
  +             DELETE_OBJECT m_Delete;
  +             int m_nObjCount;
  +     } HandlerInformation;
  +
  +     map<int, HandlerInformation*> m_HandlerInfoList;
  +
   public:
  -     BasicHandler* GetHandler();
  -     HandlerLoader(string &sFile, int nOptions=RTLD_LAZY);
  +     int CreateHandler(BasicHandler** pHandler, int nLibId);
  +     int DeleteHandler(BasicHandler* pHandler, int nLibId);
  +     HandlerLoader();
        ~HandlerLoader();
  -     int Initialize();
  -     int Invoke(MessageData *pMsg);
  -     int Finalize();
   private:
  -     int LoadLib();
  -     CREATE_OBJECT GetCreate();
  -     DELETE_OBJECT GetDelete();
  -     int UnloadLib();
  +     int LoadLib(HandlerInformation* pHandlerInfo);
  +     int UnloadLib(HandlerInformation* pHandlerInfo);
   };
   
   
  
  
  
  1.4       +102 -91   xml-axis/c/src/engine/HandlerLoader.cpp
  
  Index: HandlerLoader.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/HandlerLoader.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HandlerLoader.cpp 4 Aug 2003 06:36:43 -0000       1.3
  +++ HandlerLoader.cpp 13 Aug 2003 14:07:47 -0000      1.4
  @@ -64,125 +64,136 @@
   #include "HandlerLoader.h"
   #include <stdio.h>
   #include "../common/Debug.h"
  +#include "../wsdd/WSDDDeployment.h"
   
  -HandlerLoader::HandlerLoader(string &sFile, int nOptions)
  -{
  -     m_sLib = sFile.c_str();
  -     m_nLoadOptions = nOptions;
  -     m_Handler = 0;
  -     m_pClass = NULL;
  -}
  +extern WSDDDeployment g_WSDDDeployment;
   
  -HandlerLoader::~HandlerLoader()
  +HandlerLoader::HandlerLoader()
   {
  -     if (m_pClass)
  -             m_Delete(m_pClass);
  -     if (m_Handler != 0)
  -             UnloadLib(); 
   }
   
  -int HandlerLoader::Initialize()
  +HandlerLoader::~HandlerLoader()
   {
  -     if (0 == m_Handler)
  -     {    
  -    DEBUG1("if (0 == m_Handler):HandlerLoader::Initialize()");
  -            
  -             if (LoadLib())
  -             {      
  -//                   printf("LoadLib success\n");
  -                     m_Create = GetCreate();
  -                     m_Delete = GetDelete();
  -                     if (!m_Create || !m_Delete)
  -                     {
  -//                           printf("could not get function pointers\n");
  -                             UnloadLib();
  -                             m_Handler = 0;
  -                             return FAIL;
  -                     }
  -                     m_Create(&m_pClass);
  -                     return SUCCESS;
  -             }
  -             else 
  -             {
  -//                   printf("LoadLib failed\n");
  -                     return FAIL;
  -             }
  +     lock();
  +     HandlerInformation* pHandlerInfo = NULL;
  +     for (map<int, HandlerInformation*>::iterator it = m_HandlerInfoList.begin(); 
it != m_HandlerInfoList.end(); it++)
  +     {
  +             pHandlerInfo = (*it).second;
  +             if (pHandlerInfo->m_nObjCount != 0); //it seems that some objects 
created have not been deleted - unexpected
  +             UnloadLib(pHandlerInfo);
  +             delete pHandlerInfo;
        }
  -     return SUCCESS;
  +     unlock();
   }
   
  -int HandlerLoader::Invoke(MessageData *pMsg)
  +int HandlerLoader::DeleteHandler(BasicHandler* pHandler, int nLibId)
   {
  -     if (m_pClass)
  +     lock();
  +     if (m_HandlerInfoList.find(nLibId) != m_HandlerInfoList.end())
        {
  -             return m_pClass->Invoke(pMsg);
  +             HandlerInformation* pHandlerInfo = m_HandlerInfoList[nLibId];
  +             pHandlerInfo->m_nObjCount--;
  +             pHandlerInfo->m_Delete(pHandler);
  +             if (pHandlerInfo->m_nObjCount == 0); //time to unload the DLL
  +             unlock();
  +             return SUCCESS;
        }
  -     return FAIL;
  -}
  -
  -int HandlerLoader::Finalize()
  -{
  -     m_Delete(m_pClass);
  -     m_pClass = NULL;
  -     UnloadLib();
  -     m_Handler = 0;
  -     return SUCCESS;
  -}
  -
  -int HandlerLoader::LoadLib()
  -{
  -  
  -  DEBUG2("in HandlerLoader::LoadLib(), Lib is :", m_sLib.c_str());
  -     
  -#ifdef WIN32
  -     m_Handler = LoadLibrary(m_sLib.c_str());
  -#else //Linux
  -  
  -     m_Handler = dlopen(m_sLib.c_str(), m_nLoadOptions);
  -  
  -  DEBUG1("after m_Handler = dlopen(m_sLib.c_str(), m_nLoadOptions);");
  -   
  -  
  -             if (!m_Handler)
  +     else
        {
  -    
  -//           printf("Error is :%s\n",dlerror());
  +             unlock();
  +             return HANDLER_NOT_LOADED;
        }
  -  
  -#endif
  -     return (m_Handler != 0);
  -}
  -
  -CREATE_OBJECT HandlerLoader::GetCreate()
  -{
  -#ifdef WIN32
  -     return (CREATE_OBJECT)GetProcAddress(m_Handler,CREATE_FUNCTION);
  -#else //Linux
  -     return (CREATE_OBJECT)dlsym(m_Handler,CREATE_FUNCTION);
  -#endif
   }
   
  -DELETE_OBJECT HandlerLoader::GetDelete()
  +int HandlerLoader::LoadLib(HandlerInformation* pHandlerInfo)
   {
  +     DEBUG2("in HandlerLoader::LoadLib(), Lib is :", pHandlerInfo->m_sLib.c_str());
   #ifdef WIN32
  -     return (DELETE_OBJECT)GetProcAddress(m_Handler,DELETE_FUNCTION);
  +     pHandlerInfo->m_Handler = LoadLibrary(pHandlerInfo->m_sLib.c_str());
   #else //Linux
  -     return (DELETE_OBJECT)dlsym(m_Handler,DELETE_FUNCTION);
  +     pHandlerInfo->m_Handler = dlopen(pHandlerInfo->m_sLib.c_str(), 
pHandlerInfo->m_nLoadOptions);
  +     DEBUG1("after m_Handler = dlopen(pHandlerInfo->m_sLib.c_str(), 
pHandlerInfo->m_nLoadOptions);");  
   #endif
  +     return (pHandlerInfo->m_Handler != 0)?SUCCESS:FAIL;
   }
   
  -int HandlerLoader::UnloadLib()
  +int HandlerLoader::UnloadLib(HandlerInformation* pHandlerInfo)
   {
   #ifdef WIN32
  -     FreeLibrary(m_Handler);
  +     FreeLibrary(pHandlerInfo->m_Handler);
   #else //Linux
  -     dlclose(m_Handler);
  +     dlclose(pHandlerInfo->m_Handler);
   #endif
        return SUCCESS;
   }
   
  -BasicHandler* HandlerLoader::GetHandler()
  +int HandlerLoader::CreateHandler(BasicHandler** pHandler, int nLibId)
   {
  -     BasicHandler* pH = m_pClass;
  -     return pH;
  +     lock();
  +     *pHandler = NULL;
  +     HandlerInformation* pHandlerInfo = NULL;
  +     if (m_HandlerInfoList.find(nLibId) == m_HandlerInfoList.end())
  +     {
  +             HandlerInformation* pHandlerInfo = new HandlerInformation();
  +             pHandlerInfo->m_sLib = g_WSDDDeployment.GetLibName(nLibId);
  +             if (pHandlerInfo->m_sLib.empty())
  +             {
  +                     delete pHandlerInfo;
  +                     unlock();
  +                     return LIBRARY_PATH_EMPTY;
  +             }
  +             pHandlerInfo->m_nLoadOptions = RTLD_LAZY;
  +             if (SUCCESS == LoadLib(pHandlerInfo))
  +             {  
  +                     #ifdef WIN32
  +                     pHandlerInfo->m_Create = 
(CREATE_OBJECT)GetProcAddress(pHandlerInfo->m_Handler,CREATE_FUNCTION);
  +                     pHandlerInfo->m_Delete = 
(DELETE_OBJECT)GetProcAddress(pHandlerInfo->m_Handler,DELETE_FUNCTION);
  +                     #else //Linux
  +                     pHandlerInfo->m_Create = 
(CREATE_OBJECT)dlsym(pHandlerInfo->m_Handler,CREATE_FUNCTION);
  +                     pHandlerInfo->m_Delete = 
(DELETE_OBJECT)dlsym(pHandlerInfo->m_Handler,DELETE_FUNCTION);
  +                     #endif          
  +                     if (!pHandlerInfo->m_Create || !pHandlerInfo->m_Delete)
  +                     {
  +                             UnloadLib(pHandlerInfo);
  +                             delete pHandlerInfo;
  +                             unlock();
  +                             return LOADLIBRARY_FAILED;
  +                     }
  +                     else //success
  +                     {
  +                             m_HandlerInfoList[nLibId] = pHandlerInfo;
  +                     }
  +             }
  +             else 
  +             {
  +                     unlock();
  +                     return LOADLIBRARY_FAILED;
  +             }
  +     }
  +     
  +     pHandlerInfo = m_HandlerInfoList[nLibId];
  +     BasicHandler* pBH = NULL;
  +     pHandlerInfo->m_Create(&pBH);
  +     if (pBH)
  +     {
  +             if (SUCCESS == pBH->Init())
  +             {
  +                     pHandlerInfo->m_nObjCount++;
  +                     *pHandler = pBH;
  +                     unlock();
  +                     return SUCCESS;
  +             }
  +             else
  +             {
  +                     pBH->Fini();
  +                     delete pBH;
  +                     unlock();
  +                     return HANDLER_INIT_FAIL;
  +             }
  +     }
  +     else
  +     {
  +             unlock();
  +             return CREATION_FAILED;
  +     }
   }
  
  
  
  1.5       +13 -4     xml-axis/c/src/engine/HandlerChain.h
  
  Index: HandlerChain.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/HandlerChain.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HandlerChain.h    4 Aug 2003 06:36:43 -0000       1.4
  +++ HandlerChain.h    13 Aug 2003 14:07:47 -0000      1.5
  @@ -80,18 +80,27 @@
   
   class HandlerChain : public BasicHandler  
   {
  +     friend class HandlerPool;
  +private:
  +     typedef struct ChainItem
  +     {
  +             Handler* m_pHandler;
  +             int m_nScope;
  +             int m_nLibId;
  +     } ChainItem;
   public:
  -     int AddHandler(Handler* pHandler);
  +     int AddHandler(Handler* pHandler, int nScope, int nLibId);
        HandlerChain();
        virtual ~HandlerChain();
  -
        int Invoke(IMessageData* pMsg);
        void OnFault(IMessageData* pMsg);
        int GetType(){return CHAIN_HANDLER;};
  +     int Init();
  +     int Fini();
   
   private:
  -     list<Handler*> m_HandlerList;
  -  list<Handler*>::iterator m_itCurrHandler;
  +     list<ChainItem> m_HandlerList;
  +     list<ChainItem>::iterator m_itCurrHandler;
   };
   
   #endif // 
!defined(AFX_HANDLERCHAIN_H__675E51BF_2FD7_4860_B3DE_F8B5A978EB99__INCLUDED_)
  
  
  
  1.5       +21 -10    xml-axis/c/src/engine/HandlerChain.cpp
  
  Index: HandlerChain.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/HandlerChain.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HandlerChain.cpp  15 Jul 2003 05:38:03 -0000      1.4
  +++ HandlerChain.cpp  13 Aug 2003 14:07:47 -0000      1.5
  @@ -84,17 +84,13 @@
   
   int HandlerChain::Invoke(IMessageData* pMsg)
   {
  -  
  -  DEBUG1("HandlerChain::Invoke(IMessageData* pMsg)");
  -  
  +     DEBUG1("HandlerChain::Invoke(IMessageData* pMsg)");
        m_itCurrHandler = m_HandlerList.begin();
        while (m_itCurrHandler != m_HandlerList.end())
        {
  -    DEBUG1("while (m_itCurrHandler != m_HandlerList.end())");
  -             if (SUCCESS == (*m_itCurrHandler)->Invoke(pMsg))
  +             if (SUCCESS == (*m_itCurrHandler).m_pHandler->Invoke(pMsg))
                {
                        m_itCurrHandler++;
  -      DEBUG1("if (SUCCESS == (*m_itCurrHandler)->Invoke(pMsg))");
                }
                else
                {
  @@ -102,7 +98,7 @@
                        return FAIL;
                }
        }
  -  DEBUG1("HandlerChain::Invoke end");
  +     DEBUG1("HandlerChain::Invoke end");
        return SUCCESS;
   }
   
  @@ -110,14 +106,29 @@
   {
        while (m_itCurrHandler != m_HandlerList.begin())
        {
  -             (*m_itCurrHandler)->OnFault(pMsg);
  +             (*m_itCurrHandler).m_pHandler->OnFault(pMsg);
                m_itCurrHandler--;
        }
   }
   
  -int HandlerChain::AddHandler(Handler *pHandler)
  +int HandlerChain::AddHandler(Handler* pHandler, int nScope, int nLibId)
   {
  -     m_HandlerList.push_back(pHandler);
  +     ChainItem item;
  +     item.m_pHandler = pHandler;
  +     item.m_nScope = nScope;
  +     item.m_nLibId = nLibId;
  +     m_HandlerList.push_back(item);
  +     return SUCCESS;
  +}
   
  +int HandlerChain::Init()
  +{
  +     m_HandlerList.clear();
        return SUCCESS;
  +}
  +
  +int HandlerChain::Fini()
  +{
  +     m_HandlerList.clear();
  +     return SUCCESS; 
   }
  
  
  
  1.5       +18 -19    xml-axis/c/src/engine/AxisEngine.h
  
  Index: AxisEngine.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/AxisEngine.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AxisEngine.h      27 Jul 2003 09:59:47 -0000      1.4
  +++ AxisEngine.h      13 Aug 2003 14:07:47 -0000      1.5
  @@ -67,36 +67,35 @@
   #define __AXISENGINE_INCLUDED__
   
   #include "../common/GDefine.h"
  -#include "../common/BasicHandler.h"
  -#include "../wsdd/WSDDDeployment.h"
  -#include "HandlerPool.h"
  -
   #include "../common/Packet.h"
  +#include "../soap/SoapSerializer.h"
  +#include "../soap/SoapDeSerializer.h"
  +#include "../common/BasicHandler.h"
  +#include "../common/MessageData.h"
  +#include "HandlerChain.h"
   
  -class AxisEngine // : public BasicHandler
  +class AxisEngine 
   {
   private:     
  -     static AxisEngine* m_pObject; //Singleton object.
        SoapSerializer* m_pSZ;
        SoapDeSerializer* m_pDZ;
  -     WSDDDeployment* m_pWSDD;
  -     HandlerPool* m_pHandlerPool;
  -//  string m_sResponse;
  -private:
  +     HandlerChain* m_pGReqFChain;
  +     HandlerChain* m_pGResFChain;
  +     HandlerChain* m_pTReqFChain;
  +     HandlerChain* m_pTResFChain;
  +     HandlerChain* m_pSReqFChain;
  +     HandlerChain* m_pSResFChain;
        BasicHandler* m_pWebService;
  -     int Initialize();
  -     void UnInitialize();
  -     AxisEngine();
  -
   public:
  +     AxisEngine();
        ~AxisEngine();
  -
  +     int Process(Ax_soapstream* soap);
  +private:
        int Invoke(MessageData* pMsg);
        void OnFault(MessageData* pMsg);
  -
  -     static AxisEngine* GetAxisEngine();
  -     int Process(soapstream* soap);
  -     WSDDDeployment* getWSDDDeployment();
  +     int Initialize();
  +     int InitializeHandlers(string& sSessionId, AXIS_PROTOCOL_TYPE protocol);
  +     void UnInitialize();
   };
   
   #endif
  
  
  
  1.14      +238 -349  xml-axis/c/src/engine/AxisEngine.cpp
  
  Index: AxisEngine.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/AxisEngine.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AxisEngine.cpp    1 Aug 2003 07:05:02 -0000       1.13
  +++ AxisEngine.cpp    13 Aug 2003 14:07:47 -0000      1.14
  @@ -64,21 +64,12 @@
   #include <stdio.h>
   #include "AxisEngine.h"
   #include "../common/AxisException.h"
  -#include "../common/MessageData.h"
  -#include "../soap/SoapSerializer.h"
  -#include "../soap/SoapDeSerializer.h"
  -#include "../soap/SoapFaults.h"
  -#include "../soap/URIMapping.h"
   #include "../common/Debug.h"
   #include "../common/Packet.h"
  -
  -
  -#ifdef WIN32
  -//#define WSDDFILEPATH "./Axis/conf/server.wsdd"
  -#define WSDDFILEPATH "C:/Apache/Axis/server.wsdd"
  -#else //For linux
  -#define WSDDFILEPATH "/usr/local/axiscpp/axis/server.wsdd"
  -#endif
  +#include "../wsdd/WSDDDeployment.h"
  +#include "HandlerPool.h"
  +#include "DeserializerPool.h"
  +#include "SerializerPool.h"
   
   //extern int send_response_bytes(char * res);
   
  @@ -86,344 +77,253 @@
   
   //extern int send_transport_information(soapstream *);
   
  -
  -AxisEngine* AxisEngine::m_pObject = NULL;
  +extern DeserializerPool g_DeserializerPool;
  +extern SerializerPool g_SerializerPool;
  +extern HandlerPool g_HandlerPool;
  +extern WSDDDeployment g_WSDDDeployment;
   
   AxisEngine::AxisEngine()
   {
  -     //Create Serializer and Deserializer
  -     m_pSZ = new SoapSerializer();
  -     m_pDZ = new SoapDeSerializer();  
  -     m_pWSDD = new WSDDDeployment();
  -     m_pHandlerPool = new HandlerPool();
  +     m_pSZ = NULL;
  +     m_pDZ = NULL;  
  +     m_pGReqFChain = NULL;
  +     m_pGResFChain = NULL;
  +     m_pTReqFChain = NULL;
  +     m_pTResFChain = NULL;
  +     m_pSReqFChain = NULL;
  +     m_pSResFChain = NULL;
        m_pWebService = NULL;
  -  
  -  //printf("Done WSDD\n");
   }
   
   AxisEngine::~AxisEngine()
   {
  -     delete m_pSZ;
  -     delete m_pDZ;
  -     delete m_pWSDD;
  -     delete m_pHandlerPool;
  -     //unload xerces DLL
  -     XMLPlatformUtils::Terminate();
  -}
  -
  -WSDDDeployment * AxisEngine::getWSDDDeployment()
  -{
  -     if(m_pWSDD)
  -     {
  -             return m_pWSDD; 
  -     }
  -     return NULL;
   }
   
  -AxisEngine* AxisEngine::GetAxisEngine()
  +int AxisEngine::Process(Ax_soapstream* soap) 
   {
  -     if (!m_pObject)
  -     {
  -             try
  -             {
  -      DEBUG1("AxisEngine::GetAxisEngine()");
  -                     XMLPlatformUtils::Initialize();
  -                     m_pObject = new AxisEngine();
  -                     if (!m_pObject) return NULL;
  -                     if(SUCCESS != m_pObject->Initialize())
  -                     {
  -                             m_pObject->UnInitialize();
  -                             delete m_pObject;
  -                             m_pObject = NULL;
  -                             return NULL;
  +     int Status;
  +     AXIS_TRY
  +             DEBUG1("AxisEngine::Process");
  +             MessageData* pMsg = NULL;
  +             const WSDDService* pService = NULL;
  +             string sSessionId = soap->sessionid;
  +             int nSoapVersion;
  +
  +             do {
  +                     //create and populate MessageData
  +                     if (SUCCESS != Initialize())
  +                     {
  +                             nSoapVersion = m_pDZ->GetVersion();
  +                             nSoapVersion = (nSoapVersion == VERSION_LAST) ? 
SOAP_VER_1_2 : nSoapVersion;
  +                             m_pSZ->setSoapVersion((SOAP_VERSION)nSoapVersion);
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_COULDNOTLOADSRV));
  +                             break; //do .. while(0)
  +                     }
  +                     pMsg = new MessageData();
  +                     pMsg->m_Protocol = soap->trtype;
  +                     pMsg->SetSerializer(m_pSZ);
  +                     pMsg->SetDeSerializer(m_pDZ);
  +    
  +                     if (SUCCESS != m_pDZ->SetInputStream(soap->str.ip_stream))
  +                     {
  +                             nSoapVersion = m_pDZ->GetVersion();
  +                             nSoapVersion = (nSoapVersion == VERSION_LAST) ? 
SOAP_VER_1_2 : nSoapVersion;
  +                             m_pSZ->setSoapVersion((SOAP_VERSION)nSoapVersion);
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_SOAPCONTENTERROR));
  +                             break; //do .. while(0)
                        }
  -             }
  -             catch (...)
  -             {
  -                     return NULL;
  -             }       
  -     }
  -     return m_pObject;
  -}
   
  -int AxisEngine::Process(soapstream* soap) 
  -{
  +                     char* cService= getheader(soap, SOAPACTIONHEADER);
  +                     string service = (cService == NULL)? "" : cService;
  +               
  +                     DEBUG2("string service = ",service.c_str());
  +     
  +                     if (service.empty()) 
  +                     {
  +                             nSoapVersion = pMsg->m_pDZ->GetVersion();
  +                             nSoapVersion = (nSoapVersion == VERSION_LAST) ? 
SOAP_VER_1_2 : nSoapVersion;
  +                             m_pSZ->setSoapVersion((SOAP_VERSION)nSoapVersion);
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_SOAPACTIONEMPTY));
  +                             break; //do .. while(0)
  +                     }
  +                     if (service.find('\"') != string::npos) //if there are quotes 
remove them.
  +                     {
  +                             service = service.substr(1, service.length() - 2);
  +                     }
   
  -  try
  -  {
  -    DEBUG1("AxisEngine::Process");
  - 
  -       MessageData* pMsg = NULL;
  -       MemBufInputSource* pSoapInput = NULL;
  -       WSDDHandlerList* pHandlerList = NULL;
  -       WSDDService* pService = NULL;
  -       do {
  -               //Initialize Serializer and Deserializer objects
  -               m_pSZ->init();
  -               m_pDZ->Init();
  -               //create and populate MessageData
  -               pMsg = new MessageData();
  -               pMsg->m_Protocol = soap->trtype;
  -               pMsg->SetSerializer(m_pSZ);
  -               pMsg->SetDeSerializer(m_pDZ);
  -    
  -               //Adding SoapEnvelop and SoapBody to Serializer
  -               SoapEnvelope* pEnv = new SoapEnvelope();
  -               pMsg->m_pSZ->setSoapEnvelope(pEnv);
  -               pMsg->m_pSZ->setSoapBody(new SoapBody());
  -
  -               //---------------------start--------------------------
  -
  -               //Deserialize
  -               //---------START XERCES SAX2 SPCIFIC CODE---------//
  -          //a huge buffer to store the whole soap request stream
  -               char hugebuffer[10000];
  -         //to store the number of chars returned by get_request_bytes
  -               int nChars = 0;
  -          //request a huge number of bytes to get the whole soap request
  -          //when pull parsing is used this should change
  -               get_request_bytes(hugebuffer, 10000, &nChars);
  -               DEBUG1(hugebuffer);      
  -          //if no soap then quit
  -               if (nChars <= 0) break;
  -               pSoapInput = new MemBufInputSource((const unsigned char*)hugebuffer, 
nChars ,"bufferid",false);
  -
  -               if (SUCCESS != m_pDZ->SetStream(pSoapInput)) //this parses the full 
soap request.
  -               {
  -                       
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_SOAPCONTENTERROR));
  -                       break; //do .. while(0)
  -               }
  -               //---------END XERCES SAX2 SPCIFIC CODE---------//
  +                     //get service description object from the WSDD
  +                     pService = g_WSDDDeployment.GetService(service);
  +                     if (!pService) 
  +                     {
  +                             nSoapVersion = pMsg->m_pDZ->GetVersion();
  +                             nSoapVersion = (nSoapVersion == VERSION_LAST) ? 
SOAP_VER_1_2 : nSoapVersion;
  +                             m_pSZ->setSoapVersion((SOAP_VERSION)nSoapVersion);
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_SERVICENOTFOUND));
  +                             break; //do .. while(0)
  +                     }
   
  -               int nSoapVersion = pMsg->m_pDZ->GetVersion();
  +                     pMsg->SetService(pService);
  +                     
  +                     //check for soap version in the request and decide whether we 
support it or not
  +                     //if we do not support send a soapfault with version mismatch. 
           
  +                     nSoapVersion = pMsg->m_pDZ->GetVersion();
  +                     if (nSoapVersion == VERSION_LAST) //version not supported
  +                     {
  +                             m_pSZ->setSoapVersion(SOAP_VER_1_2);
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_VERSION_MISMATCH));
  +                             break; //do .. while(0)         
  +                     }                 
   
  -               //Set Soap version in the Serializer
  -               pMsg->m_pSZ->setSoapVersion((SOAP_VERSION)nSoapVersion);
   
  -               //---------------------end--------------------------
  -               
  +                     //Set Soap version in the Serializer and the envelope
  +                     if (SUCCESS != 
m_pSZ->setSoapVersion((SOAP_VERSION)nSoapVersion))
  +                     {
  +                       
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_SOAPCONTENTERROR));
  +                       break; //do .. while(0)
  +                     }
   
  -               char* cService= getheader(soap, SOAPACTIONHEADER);
  -                     string service;
  -               if(cService==NULL) {
  -                             service="";
  -               }else {
  -                             service= cService;
  -               }
  -               
  -               DEBUG2("string service = Maths :",service.c_str());
  -     
  -               if (service.empty()) 
  -               {
  -                       
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_SOAPACTIONEMPTY));
  +                     SoapMethod* pSm = m_pDZ->GetMethod();
  +                     if (pSm) 
  +                     {
  +                             string method = pSm->getMethodName();
  +                             DEBUG2("pSm->getMethodName(); :", method.c_str());
  +                             if (!method.empty())
  +                             {
  +                                     if (pService->IsAllowedMethod(method))
  +                                     {          
  +                                             //load actual web service handler
  +                                             if (SUCCESS != 
g_HandlerPool.GetWebService(&m_pWebService, sSessionId, pService))
  +                                             {
  +                                     
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_COULDNOTLOADSRV));
  +                                                     //Error couldnot load web 
service
  +                                                     break; //do .. while(0)
  +                                             }
  +                                     }
  +                                     else
  +                                     {
  +                                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_METHODNOTALLOWED));
  +                                             //method is not an exposed allowed 
method
  +                                             break; //do .. while(0)
  +                                     }
  +                             }
  +                             else
  +                             {
  +                                     
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_NOSOAPMETHOD));
  +                                     //no method to be invoked
  +                                     break; //do .. while(0)
  +                             }
  +                     }
  +                     //Get Global and Transport Handlers
  +                     if(SUCCESS != (Status = InitializeHandlers(sSessionId, 
soap->trtype)))
  +                     {
  +                       
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_COULDNOTLOADHDL));
                          break; //do .. while(0)
  -               }
  -               service = service.substr(1, service.length() - 2);
  -               pService = m_pWSDD->GetService(service);
  -               if (!pService) {
  -                       
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_SERVICENOTFOUND));
  +                     }
  +             //Get Service specific Handlers from the pool if configured any
  +                     if(SUCCESS != (Status = 
g_HandlerPool.GetRequestFlowHandlerChain(&m_pSReqFChain, sSessionId, pService)))
  +                     {        
  +                       
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_COULDNOTLOADHDL));
                          break; //do .. while(0)
  -               }
  -
  -      pMsg->SetService(pService);
  -
  -                     
  -               //check for soap version in the request and decide whether we 
support it or not
  -               //if we do not support send a soapfault with version mismatch.       
           
  -               if (nSoapVersion == VERSION_LAST) //version not supported
  -               {
  -                       
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_VERSION_MISMATCH));
  -                       break; //do .. while(0)               
  -               }               
  -
  -               //add namespace URIs of the SoapEnvelope of the response 
corresponding to the soap version.
  -               Attribute* pNS = new 
Attribute(g_sObjSoapEnvVersionsStruct[nSoapVersion].pchEnvelopePrefix,
  -                       
"xmlns","",g_sObjSoapEnvVersionsStruct[nSoapVersion].pchEnvelopeNamespaceUri);
  -               pEnv->addNamespaceDecl(pNS);
  -               //add namespace URIs for xsd and xsi
  -               pNS = new 
Attribute("xsd","xmlns","","http://www.w3.org/2001/XMLSchema";);
  -               pEnv->addNamespaceDecl(pNS);
  -               pNS = new 
Attribute("xsi","xmlns","","http://www.w3.org/2001/XMLSchema-instance";);
  -               pEnv->addNamespaceDecl(pNS);
  -
  -               SoapMethod* pSm = m_pDZ->GetMethod();
  -               if (pSm) 
  -               {
  -                       string method = pSm->getMethodName();
  -      
  -        DEBUG2("pSm->getMethodName(); :", method.c_str());
  -          
  -                       if (!method.empty())
  -                       {
  -                               //this is done here when we use SAX parser
  -                               //if we use XML pull parser this check is done 
within the invoke method of the wrapper class
  -                               if (pService->IsAllowedMethod(method))
  -                               {          
  -                                       //load actual web service handler
  -         
  -                                       m_pWebService = 
m_pHandlerPool->LoadWebService(pService);
  -
  -                    
  -                                       if (!m_pWebService)
  -                                       {
  -            
  -                                               
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_COULDNOTLOADSRV));
  -                                               //Error couldnot load web service
  -                                               break; //do .. while(0)
  -                                       }
  -                               }
  -                               else
  -                               {
  -                                       
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_METHODNOTALLOWED));
  -                                       //method is not an exposed allowed method
  -                                       break; //do .. while(0)
  -                               }
  -                       }
  -                       else
  -                       {
  -                               
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_NOSOAPMETHOD));
  -                               //no method to be invoked
  -                               break; //do .. while(0)
  -                       }
  -               }
  -               //create any service specific handlers
  -    
  -               pHandlerList = pService->GetRequestFlowHandlers();
  +                     }
  +                     if(SUCCESS != (Status = 
g_HandlerPool.GetResponseFlowHandlerChain(&m_pSResFChain, sSessionId, pService)))
  +                     {        
  +                       
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_COULDNOTLOADHDL));
  +                       break; //do .. while(0)
  +                     }
   
  -      DEBUG1("after pService->GetRequestFlowHandlers();");
  -       
  -               if (pHandlerList)
  -               {
  -
  -                       if(SUCCESS != 
m_pHandlerPool->LoadServiceRequestFlowHandlers(pHandlerList))
  -                       {        
  -                               
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_COULDNOTLOADHDL));
  -                               break; //do .. while(0)
  -                       }
  -               }
  -    
  -               pHandlerList = pService->GetResponseFlowHandlers();
  -    
  -               if (pHandlerList)
  -               {
  -                       if(SUCCESS != 
m_pHandlerPool->LoadServiceResponseFlowHandlers(pHandlerList))
  -                       {
  -                               
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_COULDNOTLOADHDL));
  -                               break; //do .. while(0)
  -                       }
  -               }
  -               Invoke(pMsg); //we generate response in the same way even if this 
has failed
  -       }
  -       while(0);
  -       //and handlers may add headers to the Serializer.
  -       //Invoke all handlers including the webservice
  -       //in case of failure coresponding soap fault message will be sent
  -       if (pMsg) delete pMsg; //MessageData is no longer needed
  -       if (pSoapInput) delete pSoapInput; //this should not be done if we use 
progressive parsing
  -       //set soap version to the serializer.
  -       //Serialize
  -       send_transport_information(soap);
  -       int iStatus= m_pSZ->getStream();
  -      
  -       //soap->so.http.op_soap = new char(sResponse.length() + 1); 
  -       //strcpy(soap->so.http.op_soap, sResponse.c_str());
  -  #ifndef _DEBUG //this caused program to crash in debug mode
  -       m_pSZ->init();
  -  #endif 
  -     //unload webservice handler
  -  #ifndef WIN32 //this crashes in Win32 at stl map::find(..) function - I cannot 
find what is wrong.
  -       if (m_pWebService) m_pHandlerPool->UnloadWebService(pService);
  -       //Unload service specific handlers
  -       pHandlerList = pService->GetRequestFlowHandlers();
  -       if (pHandlerList)
  -               m_pHandlerPool->UnLoadServiceRequestFlowHandlers(pHandlerList);
  -       pHandlerList = pService->GetResponseFlowHandlers();
  -       if (pHandlerList)
  -               m_pHandlerPool->UnLoadServiceResponseFlowHandlers(pHandlerList);
  -  #endif
  -       return SUCCESS;
  - }
  - catch(exception* e)
  - {
  -   //todo
  -   /*
  -    An exception derived from exception which is not handled will be handled here.
  -    You can call a method in AxisModule which may unload the AxisEngine
  -    from the webserver and report the error. You can also write this
  -    in a logfile specific to axis.
  -   */
  -   DEBUG1(e->what());   
  -   delete(e);
  - }
  - catch(...)
  - {
  -   //todo
  -   /*
  -    An unknown exception which is not handled will be handled here.
  -    You can call a method in AxisModule which may unload the AxisEngine
  -    from the webserver and report the error. You can also write this
  -    in a logfile specific to axis.
  -   */
  -   DEBUG1("UNKNOWN EXCEPTION");
  - }
  +                     //and handlers may add headers to the Serializer.
  +                     //Invoke all handlers including the webservice
  +                     //in case of failure coresponding soap fault message will be 
set
  +                     Status = Invoke(pMsg); //we generate response in the same way 
even if this has failed
  +             }
  +             while(0);
  +             if (pMsg) delete pMsg; //MessageData is no longer needed
  +             //send any transoport information like http headers first
  +             send_transport_information(soap);
  +             //Serialize
  +             m_pSZ->SetOutputStream(soap->str.ip_stream);
  +
  +             //Pool back the Service specific handlers
  +             if (m_pSReqFChain) g_HandlerPool.PoolHandlerChain(m_pSReqFChain, 
sSessionId);
  +             if (m_pSResFChain) g_HandlerPool.PoolHandlerChain(m_pSResFChain, 
sSessionId);
  +             //Pool back the webservice
  +             if (m_pWebService) g_HandlerPool.PoolWebService(sSessionId, 
m_pWebService, pService); 
  +             return Status;
  +     AXIS_CATCH(exception* e)
  +             //todo
  +             /*
  +             An exception derived from exception which is not handled will be 
handled here.
  +             You can call a method in AxisModule which may unload the AxisEngine
  +             from the webserver and report the error. You can also write this
  +             in a logfile specific to axis.
  +             */
  +             #ifdef _DEBUG
  +             DEBUG1(e->what());   
  +             delete(e);
  +             #endif
  +     AXIS_CATCH(...)
  +             //todo
  +             /*
  +             An unknown exception which is not handled will be handled here.
  +             You can call a method in AxisModule which may unload the AxisEngine
  +             from the webserver and report the error. You can also write this
  +             in a logfile specific to axis.
  +             */
  +             DEBUG1("UNKNOWN EXCEPTION");
  +     AXIS_ENDCATCH
  +     return Status;
   }
   
   int AxisEngine::Invoke(MessageData* pMsg)
   {
        enum AE_LEVEL {AE_START=1, AE_TRH, AE_GLH, AE_SERH, AE_SERV};
  -     HandlerChain* pChain;
  -     int ret = FAIL;
  +     int Status = FAIL;
        int level = AE_START;
        do
        {
                //invoke transport request handlers
  -             pChain = 
m_pHandlerPool->GetTransportRequestFlowHandlerChain(pMsg->m_Protocol);
  -             if (pChain) {
  -                     if(SUCCESS != pChain->Invoke(pMsg))
  +             if (m_pTReqFChain) {
  +                     if(SUCCESS != (Status = m_pTReqFChain->Invoke(pMsg)))
                        {
  -                             
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_HANDLERFAILED));
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_HANDLERFAILED));
                                break; //do .. while (0)
                        }
   
                }
  -    DEBUG1("AFTER pChain = m_pHandlerPool->GetTransportRequestFlowHandlerChain");
  +             DEBUG1("AFTER invoke transport request handlers");
                level++; // AE_TRH
                //invoke global request handlers
  -             pChain = m_pHandlerPool->GetGlobalRequestFlowHandlerChain();
  -             if (pChain)
  +             if (m_pGReqFChain)
                {
  -                     if(SUCCESS != pChain->Invoke(pMsg))
  +                     if(SUCCESS != (Status = m_pGReqFChain->Invoke(pMsg)))
                        {
  -                             
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_HANDLERFAILED));
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_HANDLERFAILED));
                                break; //do .. while (0)
                        }               
                }
  -    DEBUG1("AFTER pChain = m_pHandlerPool->GetGlobalRequestFlowHandlerChain();");
  +             DEBUG1("AFTER invoke global request handlers");
                level++; //AE_GLH
                //invoke service specific request handlers
  -             pChain = m_pHandlerPool->GetServiceRequestFlowHandlerChain();
  -             if (pChain)
  +             if (m_pSReqFChain)
                {
  -                     if(SUCCESS != pChain->Invoke(pMsg))
  +                     if(SUCCESS != (Status = m_pSReqFChain->Invoke(pMsg)))
                        {
  -                             
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_HANDLERFAILED));
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_HANDLERFAILED));
                                break; //do .. while (0)
                        }
  -      DEBUG1("if(SUCCESS == pChain->Invoke(pMsg))");
                }
  -    DEBUG1("AFTER pChain = m_pHandlerPool->GetServiceRequestFlowHandlerChain();");
  +             DEBUG1("AFTER invoke service specific request handlers");
                level++; //AE_SERH
                //call actual web service handler
  -
                if (m_pWebService)
  -                     if (SUCCESS != m_pWebService->Invoke(pMsg))
  +             {
  +                     if (SUCCESS != (Status = m_pWebService->Invoke(pMsg)))
                        {
  -                             
pMsg->m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_WEBSERVICEFAILED));
  +                             
m_pSZ->setSoapFault(SoapFault::getSoapFault(SF_WEBSERVICEFAILED));
                                break;
  -                     }
  -
  -    DEBUG1("if (m_pWebService)");      
  -         
  +                     }        
  +             }
  +             DEBUG1("AFTER call actual web service handler");
                level++; //AE_SERV
        }
        while(0);
  @@ -433,37 +333,32 @@
        switch (level)
        {
        case AE_SERV: //everything success
  -    ret = SUCCESS;
  -             //invoke service specific response handlers
  +             Status = SUCCESS;
                //no break;
        case AE_SERH: //actual web service handler has failed
                //invoke web service specific response handlers
  -    pChain = m_pHandlerPool->GetServiceResponseFlowHandlerChain();
  -             if (pChain)
  +             if (m_pSResFChain)
                {
  -                     pChain->Invoke(pMsg);
  -      
  +                     m_pSResFChain->Invoke(pMsg);
                }
                //no break;
        case AE_GLH: //web service specific handlers have failed
                //invoke global response handlers
  -             pChain = m_pHandlerPool->GetGlobalResponseFlowHandlerChain();
  -             if (pChain)
  +             if (m_pGResFChain)
                {
  -                     pChain->Invoke(pMsg);
  +                     m_pGResFChain->Invoke(pMsg);
                }
                //no break;
        case AE_TRH: //global handlers have failed
  -             pChain = 
m_pHandlerPool->GetTransportResponseFlowHandlerChain(pMsg->m_Protocol);
  -             if (pChain) 
  +             if (m_pTResFChain) 
                {
  -                     pChain->Invoke(pMsg);
  +                     m_pTResFChain->Invoke(pMsg);
                }
                //no break;
        case AE_START:;//transport handlers have failed
        };
  -  DEBUG1("end axisengine process()");
  -     return ret;
  +     DEBUG1("end axisengine process()");
  +     return Status;
   }
   
   void AxisEngine::OnFault(MessageData* pMsg)
  @@ -473,44 +368,21 @@
   
   int AxisEngine::Initialize()
   {
  -     string str(WSDDFILEPATH);
  -     TypeMapping::Initialize();
  -     URIMapping::Initialize();
  -     SoapFault::initialize();
  -  
  -  DEBUG1("AxisEngine::Initialize()");
  -      
  -     if (SUCCESS != m_pWSDD->LoadWSDD(str)) return FAIL;
  -  
  -     //Load Global Handlers to the pool if configured any
  -     WSDDHandlerList* pHandlerList = m_pWSDD->GetGlobalRequestFlowHandlers();
  -     if (pHandlerList)
  -             if(SUCCESS != 
m_pHandlerPool->LoadGlobalRequestFlowHandlers(pHandlerList))
  -                     return FAIL;
  -     pHandlerList = m_pWSDD->GetGlobalResponseFlowHandlers();
  -     if (pHandlerList)
  -             if(SUCCESS != 
m_pHandlerPool->LoadGlobalResponseFlowHandlers(pHandlerList))
  -                     return FAIL;
  -
  -     //Load Transport Handlers to the pool if configured any
  -     WSDDTransport* pTransport = m_pWSDD->GetTransport();
  -     if (pTransport) {
  -             //HTTP
  -             pHandlerList = pTransport->GetRequestFlowHandlers(APTHTTP);
  -             if (pHandlerList)
  -                     if(SUCCESS != 
m_pHandlerPool->LoadTransportRequestFlowHandlers(APTHTTP, pHandlerList))
  -                             return FAIL;
  -             //FTP
  -             pHandlerList = pTransport->GetRequestFlowHandlers(APTFTP);
  -             if (pHandlerList)
  -                     if(SUCCESS != 
m_pHandlerPool->LoadTransportRequestFlowHandlers(APTFTP, pHandlerList))
  -                             return FAIL;
  -             //SMTP
  -             pHandlerList = pTransport->GetRequestFlowHandlers(APTSMTP);
  -             if (pHandlerList)
  -                     if(SUCCESS != 
m_pHandlerPool->LoadTransportRequestFlowHandlers(APTSMTP, pHandlerList))
  -                             return FAIL;
  +     int Status;
  +     //Create and initialize Serializer and Deserializer objects
  +     if (SUCCESS != (Status = g_SerializerPool.GetInstance(&m_pSZ))) return Status;
  +     if (SUCCESS != (Status = m_pSZ->Init()))
  +     {
  +             g_SerializerPool.PutInstance(m_pSZ);
  +             return Status;
  +     }
  +     if (SUCCESS != (Status = g_DeserializerPool.GetInstance(&m_pDZ))) return 
Status;
  +     if (SUCCESS != (Status = m_pDZ->Init()))
  +     {
  +             g_DeserializerPool.PutInstance(m_pDZ);
  +             return Status;
        }
  +
        return SUCCESS;
   }
   
  @@ -518,4 +390,21 @@
   {
        //nothing to do with m_pWSDD because its destructor deletes its objects
        //nothing to do with m_pHandlerPool because its destructor deletes its objects
  -}
  \ No newline at end of file
  +}
  +
  +int AxisEngine::InitializeHandlers(string &sSessionId, AXIS_PROTOCOL_TYPE protocol)
  +{
  +     int Status = SUCCESS;  
  +     //Get Global Handlers from the pool if configured any
  +     if(SUCCESS != (Status = 
g_HandlerPool.GetGlobalRequestFlowHandlerChain(&m_pGReqFChain, sSessionId)))
  +             return Status;
  +     if(SUCCESS != (Status = 
g_HandlerPool.GetGlobalResponseFlowHandlerChain(&m_pGResFChain, sSessionId)))
  +             return Status;
  +
  +     //Get Transport Handlers from the pool if configured any
  +     if(SUCCESS != (Status = 
g_HandlerPool.GetTransportRequestFlowHandlerChain(&m_pTReqFChain, sSessionId, 
protocol)))
  +             return Status;
  +     if(SUCCESS != (Status = 
g_HandlerPool.GetTransportResponseFlowHandlerChain(&m_pTResFChain, sSessionId, 
protocol)))
  +             return Status;
  +     return Status;
  +}
  
  
  
  1.6       +95 -57    xml-axis/c/src/engine/Axis.cpp
  
  Index: Axis.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/engine/Axis.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Axis.cpp  27 Jul 2003 10:03:33 -0000      1.5
  +++ Axis.cpp  13 Aug 2003 14:07:47 -0000      1.6
  @@ -1,3 +1,5 @@
  +#pragma warning (disable : 4503)
  +
   #include "AxisEngine.h"
   #include "../common/Debug.h"
   #include <stdio.h>
  @@ -7,51 +9,81 @@
   #include <string>
   #include <map>
   
  -#define res(X); send_response_bytes(X);
  +#include "../soap/SoapFaults.h"
  +#include "../soap/URIMapping.h"
  +#include "HandlerLoader.h"
  +#include "AppScopeHandlerPool.h"
  +#include "RequestScopeHandlerPool.h"
  +#include "SessionScopeHandlerPool.h"
  +#include "HandlerPool.h"
  +#include "SerializerPool.h"
  +#include "DeserializerPool.h"
  +#include "../wsdd/WSDDDeployment.h"
  +
  +#define BYTESTOREAD 64
  +//the relative location of the wsdl files hardcoded
  +#define WSDLDIRECTORY        "./Axis/wsdl/"
  +
  +#ifdef WIN32
  +#ifdef AXIS_APACHE1_3
  +#define WSDDFILEPATH "./Axis/conf/server.wsdd"
  +#else
  +#define WSDDFILEPATH "C:/Axis/conf/server.wsdd"
  +#endif
  +#else //For linux
  +#ifdef AXIS_APACHE1_3
  +#define WSDDFILEPATH "./Axis/conf/server.wsdd"
  +#else
  +#define WSDDFILEPATH "/usr/local/axiscpp/axis/server.wsdd"
  +#endif
  +#endif
   
  +//define all global variables of the axisengine
  +#ifdef _DEBUG
   unsigned char chEBuf[1024];
  +#endif
   
  -extern "C" int process_request(soapstream *str)
  -{
  -DEBUG1("in axis.cpp");       
  -     AxisEngine* engine = AxisEngine::GetAxisEngine();       
  -     int ret = FAIL;
  -     char * wsdlloc = NULL;
  -     char * uri = NULL;
  -     int pos=0;
  -     int slashcount=0;
  -     int len = 0;
  -
  -     FILE * outfile;
  -     const int bytestoread = 6;
  -     char oneword [bytestoread];
  -     oneword[bytestoread-1] = '\0';
  +//synchronized global variables.
  +HandlerLoader g_HandlerLoader;
  +AppScopeHandlerPool g_AppScopeHandlerPool;
  +RequestScopeHandlerPool g_RequestScopeHandlerPool;
  +SessionScopeHandlerPool g_SessionScopeHandlerPool;
  +DeserializerPool g_DeserializerPool;
  +SerializerPool g_SerializerPool;
  +HandlerPool g_HandlerPool;
  +//un synchronized read-only global variables.
  +WSDDDeployment g_WSDDDeployment;
   
  +extern "C" int process_request(Ax_soapstream *str)
  +{
  +     DEBUG1("in axis.cpp");  
  +     int Status = FAIL;
  +     FILE * WsddFile;
  +     char ReadBuffer[BYTESTOREAD];
  +     ReadBuffer[0] = '\0';
   
  -     const WSDDServiceMap * svsmap = NULL;
  +     const WSDDServiceMap* pSrvMap = NULL;
        WSDDServiceMap::const_iterator iter;
  -     WSDDService * svs = NULL;
  -     //the location of the wsdl files hardcoded
  -     string svr("./Axis/wsdl/");
  +     WSDDService* pService = NULL;
   
  -     switch(str->trtype)
  +     switch (str->trtype)
        {
                case APTHTTP:
                        //Handle the POST method
  -                     if(str->so.http.ip_method==POST)
  +                     if (str->so.http.ip_method == AXIS_HTTP_POST)
                        {
  -DEBUG1("method is POST");                
  +                             DEBUG1("method is POST");
  +                             AxisEngine* engine = new AxisEngine();  
                                if (engine)
                                {
  -                                     ret = engine->Process(str);
  -                                     DEBUG1("ret = engine->Process(str);");
  +                                     Status = engine->Process(str);
  +                                     DEBUG1("Status = engine->Process(str);");
                                    DEBUG1("are we successful?");            
  -                                     ret = SUCCESS;
  +                                     Status = SUCCESS;
                                }
                        }
  -
                        //Handler the GET method
  -                     if(str->so.http.ip_method==GET)
  +                     if (str->so.http.ip_method == AXIS_HTTP_GET)
                        {
                                //get the uri path
                                //i.e "/abc/xyz/" part of http://somehost/abc/xyz/
  @@ -68,64 +100,70 @@
                                {       
                                        bNoSlash = true;
                                }
  +
                                if (sUriWOAxis.empty())
                                {
  -                                     svsmap = 
engine->getWSDDDeployment()->GetWSDDServiceMap();
  -                                     //dep = engine->getWSDDDeployment();
  -                                     //svsmap = depGetWSDDServiceMap();
  -                                     res("<html><body>\
  +                                     pSrvMap = g_WSDDDeployment.GetWSDDServiceMap();
  +                                     send_response_bytes("<html><body>\
                                                <h1 align=\"center\">Welcome to Axis 
C++</h1>\
                                                <br>\
                                                <h2>List of Deployed Web 
services<br></h2>\
                                                <h3>click on the links to view the 
WSDL</h3>\
                                                <br>\
  -                                             <table width=\"400\">");
  +                                             <table width=\"400\">", 
str->str.op_stream);
   
  -                                     for 
(iter=svsmap->begin();iter!=svsmap->end();iter++)
  +                                     for (iter = pSrvMap->begin();iter != 
pSrvMap->end();iter++)
                                        {
  -                                             svs = iter->second;
  -                                             res("<tr><td width=\"200\">");
  -                                             res((char 
*)svs->GetServiceName().c_str());
  -                                             res("</td><td width=\"200\"><a 
href=\"./");
  -                                             if (bNoSlash) 
send_response_bytes("axis/"); 
  -                                             send_response_bytes((char 
*)svs->GetServiceName().c_str());
  -                                             send_response_bytes("?wsdl");
  -                                             
send_response_bytes("\">wsdl</a></td>");
  -                                             res("</tr>");
  +                                             pService = iter->second;
  +                                             send_response_bytes("<tr><td 
width=\"200\">", str->str.op_stream);
  +                                             send_response_bytes((char 
*)pService->GetServiceName().c_str(), str->str.op_stream);
  +                                             send_response_bytes("</td><td 
width=\"200\"><a href=\"./", str->str.op_stream);
  +                                             if (bNoSlash) 
send_response_bytes("axis/", str->str.op_stream); 
  +                                             send_response_bytes((char 
*)pService->GetServiceName().c_str(), str->str.op_stream);
  +                                             send_response_bytes("?wsdl", 
str->str.op_stream);
  +                                             
send_response_bytes("\">wsdl</a></td>", str->str.op_stream);
  +                                             send_response_bytes("</tr>", 
str->str.op_stream);
                                        }
  -                                     res("</table></body></html>");
  +                                     send_response_bytes("</table></body></html>", 
str->str.op_stream);
                                }
                                else 
                                {
  -                                     sServiceName = "./Axis/wsdl/" + sUriWOAxis + 
".wsdl";
  +                                     sServiceName = WSDLDIRECTORY + sUriWOAxis + 
".wsdl";
                                        //check whether wsdl file is available
  -                                     if((outfile = 
fopen(sServiceName.c_str(),"r"))==NULL)
  +                                     if((WsddFile = 
fopen(sServiceName.c_str(),"r"))==NULL)
                                        {
  -                                             send_response_bytes("<h3>Url not 
available</h3>");
  +                                             send_response_bytes("<h3>Url not 
available</h3>", str->str.op_stream);
                                                //handle the error
                                        }
                                        else
                                        {
                                                int charcount = 0;
  -                                             int acc = 0;    
  -                                             
while((charcount=fread(oneword,1,bytestoread-1, outfile)) != 0)
  +                                             while((charcount = fread(ReadBuffer, 
1, BYTESTOREAD-1, WsddFile)) != 0)
                                                {
  -                                                     *(oneword+charcount) = '\0';
  -                                                     send_response_bytes(oneword);
  +                                                     *(ReadBuffer + charcount) = 
'\0';
  +                                                     
send_response_bytes(ReadBuffer, str->str.op_stream);
                                                }
  -                                             ret = SUCCESS;
  -                                             fclose(outfile);
  +                                             Status = SUCCESS;
  +                                             fclose(WsddFile);
                                        }
                                }
                        }
                break;
   
                default:
  -                     send_response_bytes("Unknown Protocol");
  +                     send_response_bytes("Unknown Protocol", str->str.op_stream);
                break;
        }
  -     svsmap = NULL;
  -     svs =NULL;
  -     return ret;
  +     return Status;
   }
   
  +extern "C" int initialize_module()
  +{
  +     TypeMapping::Initialize();
  +     URIMapping::Initialize();
  +     SoapFault::initialize();
  +     XMLPlatformUtils::Initialize();
  +     string ConfFile = WSDDFILEPATH;
  +     if (SUCCESS != g_WSDDDeployment.LoadWSDD(ConfFile)) return FAIL;
  +     return SUCCESS;
  +}
  
  
  
  1.1                  xml-axis/c/src/engine/SharedObject.h
  
  Index: SharedObject.h
  ===================================================================
  // SharedObject.h: interface for the SharedObject class.
  //
  //////////////////////////////////////////////////////////////////////
  #pragma warning (disable : 4786)
  
  #if !defined(AFX_SHAREDOBJECT_H__0805D25C_2F7E_4B19_BECE_0A8BFE9F0830__INCLUDED_)
  #define AFX_SHAREDOBJECT_H__0805D25C_2F7E_4B19_BECE_0A8BFE9F0830__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  class SharedObject  
  {
  public:
        SharedObject();
        virtual ~SharedObject();
  protected:
        int unlock();
        int lock();
  private:
        volatile bool m_bLocked;
  };
  
  #endif // 
!defined(AFX_SHAREDOBJECT_H__0805D25C_2F7E_4B19_BECE_0A8BFE9F0830__INCLUDED_)
  
  
  
  1.1                  xml-axis/c/src/engine/SharedObject.cpp
  
  Index: SharedObject.cpp
  ===================================================================
  // SharedObject.cpp: implementation of the SharedObject class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #include "SharedObject.h"
  #ifdef WIN32
  #include <Windows.h>
  #else
  
  #endif
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  
  SharedObject::SharedObject()
  {
        m_bLocked = false;
  }
  
  SharedObject::~SharedObject()
  {
  
  }
  //Following functions should be improved to avoid chances of failure
  //using platform specific mechanisms
  int SharedObject::lock()
  {
        while (m_bLocked)
        {
  #ifdef WIN32
                Sleep(0);
  #else
                sleep(0);
  #endif
        }
        m_bLocked = true;
        return 0;
  }
  
  int SharedObject::unlock()
  {
        m_bLocked = false;
        return 0;
  }
  
  
  
  1.1                  xml-axis/c/src/engine/SessionScopeHandlerPool.h
  
  Index: SessionScopeHandlerPool.h
  ===================================================================
  // SessionScopeHandlerPool.h: interface for the SessionScopeHandlerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #if 
!defined(AFX_SESSIONSCOPEHANDLERPOOL_H__8F0188D8_B30B_43F9_8F06_8E209D7B8ABE__INCLUDED_)
  #define 
AFX_SESSIONSCOPEHANDLERPOOL_H__8F0188D8_B30B_43F9_8F06_8E209D7B8ABE__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #define SESSIONLESSHANDLERS   "0aaaaa"
  
  #include "SharedObject.h"
  #include "../common/BasicHandler.h"
  
  #include <map>
  #include <list>
  #include <string>
  
  using namespace std;
  
  class SessionScopeHandlerPool : protected SharedObject  
  {
  public:
        SessionScopeHandlerPool();
        virtual ~SessionScopeHandlerPool();
  private:
        typedef map<string, list<BasicHandler*> > SessionHandlers;
        map<int, SessionHandlers*> m_Handlers;
  public:
        int GetInstance(string& sSessionId, BasicHandler** pHandler, int nLibId);
        int PutInstance(string& sSessionId, BasicHandler* pHandler, int nLibId);
        void EndSession(string& sSessionId);
  };
  
  #endif // 
!defined(AFX_SESSIONSCOPEHANDLERPOOL_H__8F0188D8_B30B_43F9_8F06_8E209D7B8ABE__INCLUDED_)
  
  
  
  1.1                  xml-axis/c/src/engine/SessionScopeHandlerPool.cpp
  
  Index: SessionScopeHandlerPool.cpp
  ===================================================================
  // SessionScopeHandlerPool.cpp: implementation of the SessionScopeHandlerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  #pragma warning (disable : 4503)
  
  #include "SessionScopeHandlerPool.h"
  #include "HandlerLoader.h"
  
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  extern HandlerLoader g_HandlerLoader;
  
  SessionScopeHandlerPool::SessionScopeHandlerPool()
  {
  
  }
  
  SessionScopeHandlerPool::~SessionScopeHandlerPool()
  {
  
  }
  
  int SessionScopeHandlerPool::GetInstance(string& sSessionId, BasicHandler** 
pHandler, int nLibId)
  {
        lock();
        int Status;
        if (m_Handlers.find(nLibId) != m_Handlers.end()) 
        {
                SessionHandlers* pSesHandlers = m_Handlers[nLibId];
                if (pSesHandlers->find(sSessionId) != pSesHandlers->end())
                {
                        list<BasicHandler*> &HandlerList = 
((*pSesHandlers)[sSessionId]);
                        if (HandlerList.empty())
                        {
                                //check in the store for reuse
                                if ((*pSesHandlers)[SESSIONLESSHANDLERS].empty())
                                {
                                        unlock();
                                        return g_HandlerLoader.CreateHandler(pHandler, 
nLibId);
                                }
                                else
                                {
                                        *pHandler = 
(*pSesHandlers)[SESSIONLESSHANDLERS].front();
                                        
(*pSesHandlers)[SESSIONLESSHANDLERS].pop_front();
                                        unlock();
                                        return SUCCESS;
                                }
                        }
                        else
                        {
                                *pHandler = HandlerList.front();
                                HandlerList.pop_front();
                                unlock();
                                return SUCCESS;
                        }
                        unlock();
                        return g_HandlerLoader.CreateHandler(pHandler, nLibId);
                }
                else //no handler list for this session id
                {
                        //check in the store for reuse
                        if ((*pSesHandlers)[SESSIONLESSHANDLERS].empty())
                        {
                                unlock();
                                return g_HandlerLoader.CreateHandler(pHandler, nLibId);
                        }
                        else
                        {
                                *pHandler = 
(*pSesHandlers)[SESSIONLESSHANDLERS].front();
                                (*pSesHandlers)[SESSIONLESSHANDLERS].pop_front();
                                unlock();
                                return SUCCESS;
                        }
                }
        }
        else //not even the handler DLL loaded
        {
                Status = g_HandlerLoader.CreateHandler(pHandler, nLibId);
                if (SUCCESS == Status)
                {
                        //this just creates the entry in m_Handlers so that next time 
we know that the DLL is loaded
                        SessionHandlers* pNewSH = new SessionHandlers;
                        pNewSH->clear();
                        m_Handlers[nLibId] = pNewSH;    
                }
                unlock();
                return Status;
        }
  }
  
  int SessionScopeHandlerPool::PutInstance(string& sSessionId, BasicHandler* pHandler, 
int nLibId)
  {
        lock();
        SessionHandlers* pSesHandlers;
        if (m_Handlers.find(nLibId) != m_Handlers.end())
        {
                pSesHandlers = m_Handlers[nLibId];
        }
        else // this is unexpected situation. anyway do it
        {
                pSesHandlers = new SessionHandlers;
                pSesHandlers->clear();
                m_Handlers[nLibId] = pSesHandlers;      
        }
        list<BasicHandler*> &HandlerList = ((*pSesHandlers)[sSessionId]);
        HandlerList.push_back(pHandler);
        unlock();
        return SUCCESS;
  }
  
  void SessionScopeHandlerPool::EndSession(string& sSessionId)
  {
        //traverse all the lists and remove corresponding handlers if any and put to 
SESSIONLESSHANDLERS        
  }
  
  
  
  1.1                  xml-axis/c/src/engine/SerializerPool.h
  
  Index: SerializerPool.h
  ===================================================================
  // SerializerPool.h: interface for the SerializerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #if !defined(AFX_SERIALIZERPOOL_H__45283A27_9196_4ACF_952F_88C564A4BD40__INCLUDED_)
  #define AFX_SERIALIZERPOOL_H__45283A27_9196_4ACF_952F_88C564A4BD40__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #include "SharedObject.h"
  #include "../soap/SoapSerializer.h"
  #include "../common/GDefine.h"
  #include <list>
  
  using namespace std;
  
  class SerializerPool : protected SharedObject  
  {
  public:
        SerializerPool();
        virtual ~SerializerPool();
  private:
        list<SoapSerializer*> m_SZList;
  public:
        int GetInstance(SoapSerializer** ppSZ);
        int PutInstance(SoapSerializer* pSZ);
  };
  
  #endif // 
!defined(AFX_SERIALIZERPOOL_H__45283A27_9196_4ACF_952F_88C564A4BD40__INCLUDED_)
  
  
  
  1.1                  xml-axis/c/src/engine/SerializerPool.cpp
  
  Index: SerializerPool.cpp
  ===================================================================
  // SerializerPool.cpp: implementation of the SerializerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #include "SerializerPool.h"
  
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  
  SerializerPool::SerializerPool()
  {
  
  }
  
  SerializerPool::~SerializerPool()
  {
  
  }
  
  //pooling should be implemented
  int SerializerPool::GetInstance(SoapSerializer** ppSZ)
  {
        //TODO
        *ppSZ = new SoapSerializer();
        return SUCCESS;
  }
  
  int SerializerPool::PutInstance(SoapSerializer* pSZ)
  {
        //TODO
        delete pSZ;
        return SUCCESS;
  }
  
  
  
  1.1                  xml-axis/c/src/engine/RequestScopeHandlerPool.h
  
  Index: RequestScopeHandlerPool.h
  ===================================================================
  // RequestScopeHandlerPool.h: interface for the RequestScopeHandlerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #if 
!defined(AFX_REQUESTSCOPEHANDLERPOOL_H__310FD607_517E_4644_8922_0B1CFDE9E5BE__INCLUDED_)
  #define 
AFX_REQUESTSCOPEHANDLERPOOL_H__310FD607_517E_4644_8922_0B1CFDE9E5BE__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #include "SharedObject.h"
  #include "../common/BasicHandler.h"
  
  #include <map>
  #include <list>
  #include <string>
  
  using namespace std;
  
  class RequestScopeHandlerPool : protected SharedObject  
  {
  public:
        RequestScopeHandlerPool();
        virtual ~RequestScopeHandlerPool();
  private:
        map<int, list<BasicHandler*> > m_Handlers;
  public:
        int GetInstance(BasicHandler** pHandler, int nLibId);
        int PutInstance(BasicHandler* pHandler, int nLibId);
  };
  
  #endif // 
!defined(AFX_REQUESTSCOPEHANDLERPOOL_H__310FD607_517E_4644_8922_0B1CFDE9E5BE__INCLUDED_)
  
  
  
  1.1                  xml-axis/c/src/engine/RequestScopeHandlerPool.cpp
  
  Index: RequestScopeHandlerPool.cpp
  ===================================================================
  // RequestScopeHandlerPool.cpp: implementation of the RequestScopeHandlerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #include "RequestScopeHandlerPool.h"
  #include "HandlerLoader.h"
  
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  extern HandlerLoader g_HandlerLoader;
  
  RequestScopeHandlerPool::RequestScopeHandlerPool()
  {
  
  }
  
  RequestScopeHandlerPool::~RequestScopeHandlerPool()
  {
  
  }
  
  int RequestScopeHandlerPool::GetInstance(BasicHandler** pHandler, int nLibId)
  {
        lock();
        int Status;
        if (m_Handlers.find(nLibId) != m_Handlers.end()) 
        {
                if (m_Handlers[nLibId].empty())
                {
                        Status = g_HandlerLoader.CreateHandler(pHandler, nLibId);
                        if (SUCCESS == Status)
                        {
                                //this just creates the entry in m_Handlers so that 
next time we know that the DLL is loaded
                                m_Handlers[nLibId].clear();     
                        }
                        unlock();
                        return Status;
                }
                else
                {
                        *pHandler = m_Handlers[nLibId].front();
                        m_Handlers[nLibId].pop_front();
                        unlock();
                        return SUCCESS;
                }
        }
        else //not even the handler DLL loaded
        {
                Status = g_HandlerLoader.CreateHandler(pHandler, nLibId);
                if (SUCCESS == Status)
                {
                        //this just creates the entry in m_Handlers so that next time 
we know that the DLL is loaded
                        m_Handlers[nLibId].clear();     
                }
                unlock();
                return Status;
        }
  }
  
  int RequestScopeHandlerPool::PutInstance(BasicHandler* pHandler, int nLibId)
  {
        lock();
        m_Handlers[nLibId].push_back(pHandler);
        unlock();
        return SUCCESS;
  }
  
  
  
  1.1                  xml-axis/c/src/engine/DeserializerPool.h
  
  Index: DeserializerPool.h
  ===================================================================
  // DeserializerPool.h: interface for the DeserializerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #if !defined(AFX_DESERIALIZERPOOL_H__702116EF_3134_4ED4_8252_BEC1FC30E825__INCLUDED_)
  #define AFX_DESERIALIZERPOOL_H__702116EF_3134_4ED4_8252_BEC1FC30E825__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #include "SharedObject.h"
  #include "../soap/SoapDeSerializer.h"
  #include "../common/GDefine.h"
  #include <list>
  
  using namespace std;
  
  class DeserializerPool : protected SharedObject  
  {
  public:
        DeserializerPool();
        virtual ~DeserializerPool();
  private:
        list<SoapDeSerializer*> m_DZList;
  public:
        int GetInstance(SoapDeSerializer** ppDZ);
        int PutInstance(SoapDeSerializer* pDZ);
  };
  
  #endif // 
!defined(AFX_DESERIALIZERPOOL_H__702116EF_3134_4ED4_8252_BEC1FC30E825__INCLUDED_)
  
  
  
  1.1                  xml-axis/c/src/engine/DeserializerPool.cpp
  
  Index: DeserializerPool.cpp
  ===================================================================
  // DeserializerPool.cpp: implementation of the DeserializerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #include "DeserializerPool.h"
  
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  
  DeserializerPool::DeserializerPool()
  {
  
  }
  
  DeserializerPool::~DeserializerPool()
  {
  
  }
  
  int DeserializerPool::GetInstance(SoapDeSerializer** ppSZ)
  {
        //TODO
        *ppSZ = new SoapDeSerializer();
        return SUCCESS;
  }
  
  int DeserializerPool::PutInstance(SoapDeSerializer* pSZ)
  {
        //TODO
        delete pSZ;
        return SUCCESS;
  }
  
  
  
  1.1                  xml-axis/c/src/engine/AppScopeHandlerPool.h
  
  Index: AppScopeHandlerPool.h
  ===================================================================
  // AppScopeHandlerPool.h: interface for the AppScopeHandlerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #if 
!defined(AFX_APPSCOPEHANDLERPOOL_H__A94BE166_F35A_40B9_8B17_9ED3D1886503__INCLUDED_)
  #define AFX_APPSCOPEHANDLERPOOL_H__A94BE166_F35A_40B9_8B17_9ED3D1886503__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #include "SharedObject.h"
  #include "../common/BasicHandler.h"
  
  #include <map>
  #include <list>
  #include <string>
  
  using namespace std;
  
  class AppScopeHandlerPool : protected SharedObject 
  {
  public:
        AppScopeHandlerPool();
        virtual ~AppScopeHandlerPool();
  private:
        map<int, list<BasicHandler*> > m_Handlers;
  public:
        int GetInstance(BasicHandler** pHandler, int nLibId);
        int PutInstance(BasicHandler* pHandler, int nLibId);
  };
  
  #endif // 
!defined(AFX_APPSCOPEHANDLERPOOL_H__A94BE166_F35A_40B9_8B17_9ED3D1886503__INCLUDED_)
  
  
  
  1.1                  xml-axis/c/src/engine/AppScopeHandlerPool.cpp
  
  Index: AppScopeHandlerPool.cpp
  ===================================================================
  // AppScopeHandlerPool.cpp: implementation of the AppScopeHandlerPool class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #include "AppScopeHandlerPool.h"
  #include "HandlerLoader.h"
  
  //////////////////////////////////////////////////////////////////////
  // Construction/Destruction
  //////////////////////////////////////////////////////////////////////
  extern HandlerLoader g_HandlerLoader;
  
  //this class does not do the object level blocking. Instead expects the 
  //thread level blocking and waiting by the caller thread.
  AppScopeHandlerPool::AppScopeHandlerPool()
  {
  
  }
  
  AppScopeHandlerPool::~AppScopeHandlerPool()
  {
  
  }
  
  //this method does not block the object. Instead expects that the calling thread 
  //MUST block itself and wait if the requested handler is not found.
  int AppScopeHandlerPool::GetInstance(BasicHandler** pHandler, int nLibId)
  {
        lock();
        int Status;
        if (m_Handlers.find(nLibId) != m_Handlers.end()) 
        {
                if (m_Handlers[nLibId].empty()) 
                // this means that the object is being used by some other thread
                // but we cannot create any more objects because this is an application
                // scope object. So just return HANDLER_BEING_USED
                {
                        unlock();
                        return HANDLER_BEING_USED;
                }
                else
                {
                        *pHandler = m_Handlers[nLibId].front();
                        m_Handlers[nLibId].pop_front();
                        unlock();
                        return SUCCESS;
                }
        }
        else //not even the handler DLL loaded
        {
                Status = g_HandlerLoader.CreateHandler(pHandler, nLibId);
                if (SUCCESS == Status)
                {
                        //this just creates the entry in m_Handlers so that next time 
we know that the DLL is loaded
                        m_Handlers[nLibId].clear();     
                }
                unlock();
                return Status;
        }
  }
  
  int AppScopeHandlerPool::PutInstance(BasicHandler* pHandler, int nLibId)
  {
        lock();
        m_Handlers[nLibId].push_back(pHandler);
        unlock();
        return SUCCESS;
  }
  
  
  

Reply via email to