You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2003/07/07 15:30:10 UTC
cvs commit: xml-axis/c/src/server/handlers/transport/testhandler2 Makefile TestHandler2.cpp TestTransport.cpp TestTransport.h
damitha 2003/07/07 06:30:10
Added: c/src/server/handlers/custom/loghandler LogAccessCount.cpp
LogHandler.cpp LogHandler.h Makefile
c/src/server/handlers/custom/simpleauthhandler Makefile
SimpleAuth.cpp SimpleAuthorizationHandler.cpp
SimpleAuthorizationHandler.h
c/src/server/handlers/global/testhandler1 Makefile
TestGlobal.cpp TestGlobal.h TestHandler1.cpp
c/src/server/handlers/transport/testhandler2 Makefile
TestHandler2.cpp TestTransport.cpp TestTransport.h
Log:
commiting c++ code base
Revision Changes Path
1.1 xml-axis/c/src/server/handlers/custom/loghandler/LogAccessCount.cpp
Index: LogAccessCount.cpp
===================================================================
#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;
}
}
1.1 xml-axis/c/src/server/handlers/custom/loghandler/LogHandler.cpp
Index: LogHandler.cpp
===================================================================
//////////////////////////////////////////////////////////////////////
#include "LogHandler.h"
#include "../../../../soap/SoapDeSerializer.h"
#include "../../../../soap/SoapSerializer.h"
#include <fstream>
#include <string>
#include "../../../../common/Debug.h"
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
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)
{
try
{
DEBUG1("LogHandler::Invoke(MessageData* md)");
m_iNumAccess = 0;
string sNumAccess = "";
string s = "logAccessCountFile";
string sFileName = GetOption(s);
if(!sFileName.empty())
{
DEBUG1("if(!sFileName.empty())");
ifstream fin(sFileName.c_str()); // open for reading
char ch;
while (fin.get(ch))
{
sNumAccess += ch;
}
if(sNumAccess.empty())
{
m_iNumAccess = 0;
}
else
{
m_iNumAccess = atoi(sNumAccess.c_str());
}
m_iNumAccess++;
sNumAccess = m_iNumAccess;
const char * FileName = sFileName.c_str();
ofstream fout(FileName); // open for writing
fout << m_iNumAccess;
DEBUG1("LogHandler Invoke end");
fin.close();
fout.close();
return SUCCESS;
}
else
{
return FAIL;
}
}
catch (...)
{
return FAIL;
}
}
void LogHandler::OnFault(MessageData* mc)
{
}
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.1 xml-axis/c/src/server/handlers/custom/loghandler/LogHandler.h
Index: LogHandler.h
===================================================================
#include "../../../../common/MessageData.h"
#include "../../../../wsdd/WSDDHandler.h"
#include "../../../../wsdd/WSDDService.h"
#include "../../../../common/Handler.h"
#include <list>
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;
};
1.1 xml-axis/c/src/server/handlers/custom/loghandler/Makefile
Index: Makefile
===================================================================
# Makefile for axishandlers
#
#
# Modify the TOPDIR variable to point to the top of the
# directory tree where the Axis_Lib dir may be found.
#
BASE_PATH = ../../../../..
include ../../../../../inc.mk
PACKAGE_SRCS = LogHandler.cpp \
LogAccessCount.cpp
PACKAGE_OBJS = $(PACKAGE_SRCS:%.cpp=$(AX_OBJ_DIR_HANDLERS)/custom/loghandler/%.o)
$(AX_OBJ_DIR_HANDLERS)/custom/loghandler/%.o: %.cpp
$(COMPILE.gcc) -o $@ $<
@touch $(AX_OBJ_DIR_HANDLERS)/custom/loghandler/timestamp
all: MAKE_LIB
MAKE_LIB:OBJS
@echo "making libcount.so shared library" ;
$(AX_SO) $(AX_SO_HANDLERS)/custom/loghandler/libcount.so $(AX_OBJ_DIR_HANDLERS)/custom/loghandler/*.o -ldl -lstdc++
#$(AX_OBJ_DIR_HANDLERS)/timestamp objects:
# @( cd $(AX_SRC_DIR) ; $(MAKE) -$(MAKEFLAGS) )
OBJS: $(PACKAGE_OBJS)
clean:
-@rm -rf $(AX_OBJ_DIR)/server/handlers/custom/loghandler/*
-@rm -rf $(OBJS) *~
1.1 xml-axis/c/src/server/handlers/custom/simpleauthhandler/Makefile
Index: Makefile
===================================================================
# Makefile for axishandlers
#
#
# Modify the TOPDIR variable to point to the top of the
# directory tree where the Axis_Lib dir may be found.
#
BASE_PATH = ../../../../..
include ../../../../../inc.mk
PACKAGE_SRCS = SimpleAuthorizationHandler.cpp \
SimpleAuth.cpp
PACKAGE_OBJS = $(PACKAGE_SRCS:%.cpp=$(AX_OBJ_DIR_HANDLERS)/custom/simpleauthhandler/%.o)
$(AX_OBJ_DIR_HANDLERS)/custom/simpleauthhandler/%.o: %.cpp
$(COMPILE.gcc) -o $@ $<
@touch $(AX_OBJ_DIR_HANDLERS)/custom/simpleauthhandler/timestamp
all: MAKE_LIB
MAKE_LIB:OBJS
@echo "making libsimpleauth.so shared library" ;
$(AX_SO) $(AX_SO_HANDLERS)/custom/simpleauthhandler/libsimpleauthhandler.so $(AX_OBJ_DIR_HANDLERS)/custom/simpleauthhandler/*.o -ldl -lstdc++
#$(AX_OBJ_DIR_HANDLERS)/timestamp objects:
# @( cd $(AX_SRC_DIR) ; $(MAKE) -$(MAKEFLAGS) )
OBJS: $(PACKAGE_OBJS)
clean:
-@rm -rf $(AX_OBJ_DIR)/server/handlers/custom/simpleauthhandler/*
-@rm -rf $(OBJS) *~
1.1 xml-axis/c/src/server/handlers/custom/simpleauthhandler/SimpleAuth.cpp
Index: SimpleAuth.cpp
===================================================================
#ifdef WIN32
#define STORAGE_CLASS_INFO __declspec(dllexport)
#else
#define STORAGE_CLASS_INFO
#endif
#include "SimpleAuthorizationHandler.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 SimpleAuthorizationHandler();
if (*inst)
{
return SUCCESS;
}
return FAIL;
}
STORAGE_CLASS_INFO
int DestroyInstance(Handler *inst)
{
if (inst)
{
delete inst;
return SUCCESS;
}
return FAIL;
}
}
1.1 xml-axis/c/src/server/handlers/custom/simpleauthhandler/SimpleAuthorizationHandler.cpp
Index: SimpleAuthorizationHandler.cpp
===================================================================
//////////////////////////////////////////////////////////////////////
#include "SimpleAuthorizationHandler.h"
#include "../../../../soap/SoapDeSerializer.h"
#include "../../../../soap/SoapSerializer.h"
#include <string.h>
#include <fstream>
#include <string>
#include "../../../../common/Debug.h"
#include "../../../../common/MessageData.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
SimpleAuthorizationHandler::SimpleAuthorizationHandler()
{
}
SimpleAuthorizationHandler::~SimpleAuthorizationHandler()
{
}
// Implementation of BasicHandler interface.
int SimpleAuthorizationHandler::Invoke(MessageData* md)
{
try
{
DEBUG1("SimpleAuthorizationHandler::Invoke(MessageData* md)");
string sValue = GetOption("AllowByDefault");
DEBUG2("sValue :", sValue);
int intIsAllowed = atoi(sValue.c_str());
if(0 == intIsAllowed)
{
return SUCCESS;
}
m_sAuthUser = md->GetUserName();
DEBUG2("m_sAuthUser:",m_sAuthUser);
if(!m_sAuthUser.empty())
{
string sAllowedRolesFileName = GetOption("AllowedRoles");
DEBUG2("sAllowedRolesFileName:",sAllowedRolesFileName);
ifstream fin(sAllowedRolesFileName.c_str()); // open for reading
string sLine = "";
char buff[512];
while (!fin.eof())
{
fin.getline(buff, 512);
sLine = buff;
m_AllowedRoles.push_back(sLine);
DEBUG2("line read is:", sLine);
}
m_itCurrentRole = m_AllowedRoles.begin();
while (m_itCurrentRole != m_AllowedRoles.end())
{
DEBUG2("(*m_itCurrentRole).c_str()", (*m_itCurrentRole).c_str());
if(strcmp(m_sAuthUser.c_str(),(*m_itCurrentRole).c_str()) == 0)
{
DEBUG1("if(strcmp(m_sAuthUser.c_str(),(*m_itCurrentRole).c_str()) == 0)");
return SUCCESS;
}
m_itCurrentRole++;
}
DEBUG1("SimpleAuthorizationHandler invoke end");
fin.close();
}
else
{
return FAIL;
}
}catch(...)
{
return FAIL;
}
}
void SimpleAuthorizationHandler::OnFault(MessageData* mc)
{
}
string SimpleAuthorizationHandler::GetOption(string sArg)
{
return (*m_Option)[sArg];
}
void SimpleAuthorizationHandler::SetOption(string sOption, string sValue)
{
(*m_Option)[sOption] = sValue;
}
void SimpleAuthorizationHandler::SetOptionList(map<string, string>* OptionList)
{
m_Option = OptionList;
}
1.1 xml-axis/c/src/server/handlers/custom/simpleauthhandler/SimpleAuthorizationHandler.h
Index: SimpleAuthorizationHandler.h
===================================================================
#include "../../../../common/MessageData.h"
#include "../../../../wsdd/WSDDHandler.h"
#include "../../../../wsdd/WSDDService.h"
#include "../../../../common/Handler.h"
#include <list>
class SimpleAuthorizationHandler : public Handler
{
public:
SimpleAuthorizationHandler();
virtual ~SimpleAuthorizationHandler();
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:
string m_sAuthUser;
list<string> m_AllowedRoles;
list<string>::iterator m_itCurrentRole;
};
1.1 xml-axis/c/src/server/handlers/global/testhandler1/Makefile
Index: Makefile
===================================================================
# Makefile for axishandlers
#
#
# Modify the TOPDIR variable to point to the top of the
# directory tree where the Axis_Lib dir may be found.
#
BASE_PATH = ../../../../..
include ../../../../../inc.mk
PACKAGE_SRCS = TestHandler1.cpp \
TestGlobal.cpp
PACKAGE_OBJS = $(PACKAGE_SRCS:%.cpp=$(AX_OBJ_DIR_HANDLERS)/global/testhandler1/%.o)
$(AX_OBJ_DIR_HANDLERS)/global/testhandler1/%.o: %.cpp
$(COMPILE.gcc) -o $@ $<
@touch $(AX_OBJ_DIR_HANDLERS)/global/testhandler1/timestamp
all: MAKE_LIB
MAKE_LIB:OBJS
@echo "making libtesthandler1.so shared library" ;
$(AX_SO) $(AX_SO_HANDLERS)/global/testhandler1/libtesthandler1.so $(AX_OBJ_DIR_HANDLERS)/global/testhandler1/*.o -ldl -lstdc++
OBJS: $(PACKAGE_OBJS)
clean:
-@rm -rf $(AX_OBJ_DIR)/server/handlers/global/testhandler1/*
-@rm -rf $(OBJS) *~
1.1 xml-axis/c/src/server/handlers/global/testhandler1/TestGlobal.cpp
Index: TestGlobal.cpp
===================================================================
//////////////////////////////////////////////////////////////////////
#include "TestGlobal.h"
#include "../../../../soap/SoapDeSerializer.h"
#include "../../../../soap/SoapSerializer.h"
#include <fstream>
#include <string>
#include "../../../../common/Debug.h"
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
TestGlobal::TestGlobal()
{
m_Option = new map<string, string>;
}
TestGlobal::~TestGlobal()
{
delete(m_Option);
m_Option = NULL;
}
// Implementation of BasicHandler interface.
int TestGlobal::Invoke(MessageData* md)
{
try
{
DEBUG1("Hi, you successfully invoked TestGlobal handler");
return SUCCESS;
}
catch (...)
{
DEBUG1("inside catch block");
return FAIL;
}
}
void TestGlobal::OnFault(MessageData* mc)
{
}
string TestGlobal::GetOption(string sArg)
{
return (*m_Option)[sArg];
}
void TestGlobal::SetOption(string sOption, string sValue)
{
(*m_Option)[sOption] = sValue;
}
void TestGlobal::SetOptionList(map<string, string>* OptionList)
{
m_Option = OptionList;
}
1.1 xml-axis/c/src/server/handlers/global/testhandler1/TestGlobal.h
Index: TestGlobal.h
===================================================================
#include "../../../../common/MessageData.h"
#include "../../../../wsdd/WSDDHandler.h"
#include "../../../../wsdd/WSDDService.h"
#include "../../../../common/Handler.h"
#include <list>
class TestGlobal : public Handler
{
public:
TestGlobal();
virtual ~TestGlobal();
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;
};
1.1 xml-axis/c/src/server/handlers/global/testhandler1/TestHandler1.cpp
Index: TestHandler1.cpp
===================================================================
#ifdef WIN32
#define STORAGE_CLASS_INFO __declspec(dllexport)
#else
#define STORAGE_CLASS_INFO
#endif
#include "TestGlobal.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 TestGlobal();
if (*inst)
{
return SUCCESS;
}
return FAIL;
}
STORAGE_CLASS_INFO
int DestroyInstance(Handler *inst)
{
if (inst)
{
delete inst;
return SUCCESS;
}
return FAIL;
}
}
1.1 xml-axis/c/src/server/handlers/transport/testhandler2/Makefile
Index: Makefile
===================================================================
# Makefile for axishandlers
#
#
# Modify the TOPDIR variable to point to the top of the
# directory tree where the Axis_Lib dir may be found.
#
BASE_PATH = ../../../../..
include ../../../../../inc.mk
PACKAGE_SRCS = TestHandler2.cpp \
TestTransport.cpp
PACKAGE_OBJS = $(PACKAGE_SRCS:%.cpp=$(AX_OBJ_DIR_HANDLERS)/transport/testhandler2/%.o)
$(AX_OBJ_DIR_HANDLERS)/transport/testhandler2/%.o: %.cpp
$(COMPILE.gcc) -o $@ $<
@touch $(AX_OBJ_DIR_HANDLERS)/transport/testhandler2/timestamp
all: MAKE_LIB
MAKE_LIB:OBJS
@echo "making libtesthandler2.so shared library" ;
$(AX_SO) $(AX_SO_HANDLERS)/transport/testhandler2/libtesthandler2.so $(AX_OBJ_DIR_HANDLERS)/transport/testhandler2/*.o -ldl -lstdc++
OBJS: $(PACKAGE_OBJS)
clean:
-@rm -rf $(AX_OBJ_DIR)/server/handlers/transport/testhandler2/*
-@rm -rf $(OBJS) *~
1.1 xml-axis/c/src/server/handlers/transport/testhandler2/TestHandler2.cpp
Index: TestHandler2.cpp
===================================================================
#ifdef WIN32
#define STORAGE_CLASS_INFO __declspec(dllexport)
#else
#define STORAGE_CLASS_INFO
#endif
#include "TestTransport.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 TestTransport();
if (*inst)
{
return SUCCESS;
}
return FAIL;
}
STORAGE_CLASS_INFO
int DestroyInstance(Handler *inst)
{
if (inst)
{
delete inst;
return SUCCESS;
}
return FAIL;
}
}
1.1 xml-axis/c/src/server/handlers/transport/testhandler2/TestTransport.cpp
Index: TestTransport.cpp
===================================================================
//////////////////////////////////////////////////////////////////////
#include "TestTransport.h"
#include "../../../../soap/SoapDeSerializer.h"
#include "../../../../soap/SoapSerializer.h"
#include <fstream>
#include <string>
#include "../../../../common/Debug.h"
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
TestTransport::TestTransport()
{
m_Option = new map<string, string>;
}
TestTransport::~TestTransport()
{
delete(m_Option);
m_Option = NULL;
}
// Implementation of BasicHandler interface.
int TestTransport::Invoke(MessageData* md)
{
try
{
DEBUG1("Hi, you have successfully invoked the TestTransport handler");
return SUCCESS;
}
catch (...)
{
return FAIL;
}
}
void TestTransport::OnFault(MessageData* mc)
{
}
string TestTransport::GetOption(string sArg)
{
return (*m_Option)[sArg];
}
void TestTransport::SetOption(string sOption, string sValue)
{
(*m_Option)[sOption] = sValue;
}
void TestTransport::SetOptionList(map<string, string>* OptionList)
{
m_Option = OptionList;
}
1.1 xml-axis/c/src/server/handlers/transport/testhandler2/TestTransport.h
Index: TestTransport.h
===================================================================
#include "../../../../common/MessageData.h"
#include "../../../../wsdd/WSDDHandler.h"
#include "../../../../wsdd/WSDDService.h"
#include "../../../../common/Handler.h"
#include <list>
class TestTransport : public Handler
{
public:
TestTransport();
virtual ~TestTransport();
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;
};