axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject cvs commit: xml-axis/c/src/server/handlers LogAccessCount.cpp LogHandler.cpp LogHandler.h
Date Tue, 01 Jul 2003 07:32:15 GMT
damitha     2003/07/01 00:32:15

  Modified:    c/src/server/handlers LogHandler.cpp LogHandler.h
  Added:       c/src/server/handlers LogAccessCount.cpp
  Log:
  
  
  Revision  Changes    Path
  1.2       +50 -23    xml-axis/c/src/server/handlers/LogHandler.cpp
  
  Index: LogHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/server/handlers/LogHandler.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogHandler.cpp	27 Jun 2003 09:17:00 -0000	1.1
  +++ LogHandler.cpp	1 Jul 2003 07:32:15 -0000	1.2
  @@ -1,10 +1,11 @@
   //////////////////////////////////////////////////////////////////////
   
   #include "LogHandler.h"
  -#include "../soap/SoapDeSerializer.h"
  -#include "../soap/SoapSerializer.h"
  +#include "../../soap/SoapDeSerializer.h"
  +#include "../../soap/SoapSerializer.h"
   #include <fstream>
   #include <string>
  +#include "../../common/Debug.h"
   
   using namespace std;
   
  @@ -14,52 +15,64 @@
   
   LogHandler::LogHandler()
   {
  +  m_Option = new map<string, string>;
   
   }
   
   LogHandler::~LogHandler()
   {
  +  delete(m_Option);
  +  m_Option = NULL;
   
   }
   // Implementation of BasicHandler interface.
   int LogHandler::Invoke(MessageData* md)
   {
  -  int iNumAccess = 0;
  -  WSDDService* oService =  md->GetService();
  -  if(oService)
  -  {
  -    string sFileName = oService->GetOption("logAccessCountFile");
  +#if defined( DEBUG)
  +  debugger.debug("LogHandler::Invoke(MessageData* md)");
  +#endif
  +    m_iNumAccess = 0;
  +    string sNumAccess = "";
  +    string s = "logAccessCountFile";
  +    string sFileName = GetOption(s);
  +
       if(!sFileName.empty())
  -    {   
  -      string sNumAccess = oService->GetOption("num_access");      
  +    {
  +#if defined( DEBUG)
  +  debugger.debug("if(!sFileName.empty())");
  +#endif
  +
  +      ifstream fin(sFileName.c_str());    // open for reading
  +       char ch;
  +
  +       while (fin.get(ch))
  +       {
  +         sNumAccess += ch;
  +
  +       }
  +
         if(sNumAccess.empty())
         {
  -        iNumAccess = 0;
  +        m_iNumAccess = 0;
         }
         else
         {
  -        iNumAccess = atoi(sNumAccess.c_str());
  +        m_iNumAccess = atoi(sNumAccess.c_str());
         }
  -      
  -      iNumAccess++;
  -      sNumAccess = iNumAccess;
  -    
  +
  +      m_iNumAccess++;
  +      sNumAccess = m_iNumAccess;
  +
         const char * FileName = sFileName.c_str();
         ofstream fout(FileName);  // open for writing
  -      fout << "service accessed " << iNumAccess << "times";
  -  
  -      oService->SetOption("num_access", sNumAccess);
  +      fout << m_iNumAccess;
  +
         return SUCCESS;
       }
       else
       {
         return FAIL;
       }
  -  }
  -  else
  -  {
  -    return FAIL;
  -  }
   }
   
   void LogHandler::OnFault(MessageData* mc)
  @@ -68,3 +81,17 @@
   }
   
   
  +string LogHandler::GetOption(string sArg)
  +{
  +  return (*m_Option)[sArg];
  +}
  +
  +void LogHandler::SetOption(string sOption, string sValue)
  +{
  +  (*m_Option)[sOption] = sValue;
  +}
  +
  +void LogHandler::SetOptionList(map<string, string>* OptionList)
  +{
  +   m_Option = OptionList;
  +}
  
  
  
  1.2       +15 -8     xml-axis/c/src/server/handlers/LogHandler.h
  
  Index: LogHandler.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/server/handlers/LogHandler.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogHandler.h	27 Jun 2003 09:17:00 -0000	1.1
  +++ LogHandler.h	1 Jul 2003 07:32:15 -0000	1.2
  @@ -1,16 +1,23 @@
  -#include "../common/MessageData.h"
  -#include "../wsdd/WSDDHandler.h"
  -#include "../wsdd/WSDDService.h"
  -#include "../common/BasicHandler.h"
  +#include "../../common/MessageData.h"
  +#include "../../wsdd/WSDDHandler.h"
  +#include "../../wsdd/WSDDService.h"
  +#include "../../common/Handler.h"
  +
   #include <list>
   
  -class LogHandler : public BasicHandler, WSDDHandler
  +class LogHandler : public Handler
   {
   public:
   	LogHandler();
   	virtual ~LogHandler();
  +  int Invoke(MessageData* pMsg);
  +  void OnFault(MessageData* pMsg);
  +
  +  string GetOption(string sArg);
  +  void SetOption(string sOption, string Value);
  +  void SetOptionList(map<string, string>* OptionList);
  +
  +protected:
  +  int m_iNumAccess;
   
  -	int Invoke(MessageData* pMsg);
  -	void OnFault(MessageData* pMsg);
  -  
   };
  
  
  
  1.1                  xml-axis/c/src/server/handlers/LogAccessCount.cpp
  
  Index: LogAccessCount.cpp
  ===================================================================
  // WsService.cpp : Defines the entry point for the DLL application.
  //
  #ifdef WIN32
  #define STORAGE_CLASS_INFO __declspec(dllexport)
  #else
  #define STORAGE_CLASS_INFO
  #endif
  
  #include "LogHandler.h"
  
  extern "C" {
  //the two export functions////////////////////////////////////////////
  
  //Following describes how the export function of the handler DLLs (or .so s)
  
  STORAGE_CLASS_INFO
  int GetClassInstance(Handler **inst)
  {
  	*inst = new LogHandler();
  	if (*inst)
  	{
  		return SUCCESS;
  	}
  	return FAIL;
  }
  STORAGE_CLASS_INFO
  int DestroyInstance(Handler *inst)
  {
  	if (inst)
  	{
  		delete inst;
  		return SUCCESS;
  	}
  	return FAIL;
  }
  
  }
  
  

Mime
View raw message