DCL 4.0
Loading...
Searching...
No Matches
HttpServlet Class Referenceabstract

#include <HttpServlet.h>

Inheritance diagram for HttpServlet:
Object HttpServletEx EShopServlet

Static Public Member Functions

static bool __initialize (HttpServlet *_servlet, const DCL_HTTP_SERVLET_CONFIG *_config, void *hErrorReport)
static bool __cleanup (HttpServlet *_servlet, void *hErrorReport)
static bool __httpService (HttpServlet *_servlet, const DCL_HTTP_SERVLET_CONTEXT *_context, void *hErrorReport)

Protected Member Functions

virtual void onInitialize () __DCL_THROWS1(Exception *)
virtual void onCleanup () __DCL_THROWS1(Exception *)
virtual void onHttpService (const DCL_HTTP_SERVLET_CONTEXT *pContext)=0__DCL_THROWS1(Exception *)
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Protected Attributes

const wchar_t * __moduleName
const wchar_t * __configPath
const wchar_t * __tempPath
const DCL_HTTP_SERVER_API__SAPI

Additional Inherited Members

Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Detailed Description

Definition at line 82 of file HttpServlet.h.

Member Function Documentation

◆ __cleanup()

bool HttpServlet::__cleanup ( HttpServlet * _servlet,
void * hErrorReport )
static

Definition at line 472 of file HttpServlet.cpp.

476{
477#ifdef __DCL_DEBUG
478 ReportErrorWriter output(
479 _servlet->__SAPI->pfnReportError,
480 hErrorReport,
481 __pDebugFileOut
482 );
483
484 Writer* pOldOutput = pOldOutput =
485 DCLDebugSetThreadReport(
487 &output
488 );
489
490#else
491 ReportErrorWriter output(
492 _servlet->__SAPI->pfnReportError,
493 hErrorReport,
494 NULL
495 );
496#endif
497
498 bool result = TRUE;
499 try {
500 __DCL_TRACE1(L"begin __cleanup [%ls]\n", _servlet->__moduleName);
501 _servlet->onCleanup();
502 __DCL_TRACE1(L"end __cleanup [%ls]\n", _servlet->__moduleName);
503 }
504 catch (Exception* e) {
505 output << e->toStringAll() << endl;
506 e->destroy();
507 result = FALSE;
508 }
509
510#ifdef __DCL_DEBUG
511 pOldOutput = DCLDebugSetThreadReport(
513 pOldOutput
514 );
515
516 if (pOldOutput != &output) {
517 __DCL_TRACE0(L"Assertion Fail! 'pOldOutput == &writer'\n");
518 }
519
520 if (__pDebugFileOut) {
521 delete __pDebugFileOut;
522 __pDebugFileOut = NULL;
523 }
524#endif
525
526 return result;
527}
#define NULL
Definition Config.h:340
#define TRUE
#define FALSE
#define __DCL_TRACE0(psz)
Definition Object.h:375
#define __DCL_TRACE1(fmt, arg1)
Definition Object.h:376
#define endl
return result
virtual void destroy()
Definition Exception.cpp:74
String toStringAll() const
Definition Exception.cpp:45
const DCL_HTTP_SERVER_API * __SAPI
const wchar_t * __moduleName
virtual void onCleanup() __DCL_THROWS1(Exception *)
static unsigned long getCurrentThreadId()
Definition Thread.cpp:173
DCLHttpWriteStream pfnReportError

◆ __httpService()

bool HttpServlet::__httpService ( HttpServlet * _servlet,
const DCL_HTTP_SERVLET_CONTEXT * _context,
void * hErrorReport )
static

Definition at line 529 of file HttpServlet.cpp.

534{
535#ifdef __DCL_DEBUG
536 ReportErrorWriter output(
537 _servlet->__SAPI->pfnReportError,
538 hErrorReport,
539 __pDebugFileOut
540 );
541
542 Writer* pOldOutput =
543 DCLDebugSetThreadReport(
545 &output
546 );
547
548 const void* pLastAllocPosition =
549 DCLDebugGetLastAllocPosition(
551 );
552#else
553 ReportErrorWriter output(
554 _servlet->__SAPI->pfnReportError,
555 hErrorReport,
556 NULL
557 );
558#endif
559
560 bool result = TRUE;
561 try {
562 __DCL_TRACE1(L"begin __httpService [%ls]\n", _servlet->__moduleName);
563 _servlet->onHttpService(_context);
564 __DCL_TRACE1(L"end __httpService [%ls]\n", _servlet->__moduleName);
565 }
566 catch (Exception* e) {
567 String s = e->toStringAll();
568 __DCL_TRACE2(L"catch __httpService [%ls][%ls]\n", _servlet->__moduleName,
569 s.data());
570 output << s << endl;
571 e->destroy();
572 result = FALSE;
573 }
574
575#ifdef __DCL_DEBUG
576 DCLDebugDumpThreadMemoryLeak(
578 pLastAllocPosition,
579 DCL_ALLOC_DUMP_ALL,
580 &output
581 );
582
583 DCLDebugSetThreadReport(
585 pOldOutput
586 );
587#endif
588
589 return result;
590}
#define __DCL_TRACE2(fmt, arg1, arg2)
Definition Object.h:377
virtual void onHttpService(const DCL_HTTP_SERVLET_CONTEXT *pContext)=0__DCL_THROWS1(Exception *)

◆ __initialize()

bool HttpServlet::__initialize ( HttpServlet * _servlet,
const DCL_HTTP_SERVLET_CONFIG * _config,
void * hErrorReport )
static

Definition at line 387 of file HttpServlet.cpp.

392{
393#ifdef __DCL_DEBUG
394 __DCL_ASSERT(_config != NULL
395 && _config->pszModuleName != NULL
396 && *(_config->pszModuleName) != L'\0'
397 );
398 __DCL_ASSERT(_config->pSAPI != NULL);
399#endif
400
401 _servlet->__moduleName = _config->pszModuleName;
402 _servlet->__configPath = _config->pszConfigPath;
403 _servlet->__tempPath = _config->pszTempPath;
404 _servlet->__SAPI = _config->pSAPI;
405
406#ifdef __DCL_DEBUG
407 String filename = _servlet->__moduleName;
408 filename = filename.left(filename.lastIndexOf(L'.')) + L".dump.txt";
409 try {
410 // Mutexted FileWriter
411 __pDebugFileOut =
412 new XFileWriter(filename, false, new UTF8Encoder());
413 }
414 catch(IOException* e) {
416 L"Warning! dump file create fail. [%ls]: [%ls]\n",
417 filename.data(),
418 e->toString().data()
419 );
420 e->destroy();
421 }
422#endif
423
424#ifdef __DCL_DEBUG
425 ReportErrorWriter output(
426 _servlet->__SAPI->pfnReportError,
427 hErrorReport,
428 __pDebugFileOut
429 );
430
431 Writer* pOldOutput =
432 DCLDebugSetThreadReport(
434 &output
435 );
436
437#else
438 ReportErrorWriter output(
439 _servlet->__SAPI->pfnReportError,
440 hErrorReport,
441 NULL
442 );
443#endif
444
445 bool result = TRUE;
446 try {
447 __DCL_TRACE1(L"begin __initialize [%ls]\n", _servlet->__moduleName);
448 _servlet->onInitialize();
449 __DCL_TRACE1(L"end __initialize [%ls]\n", _servlet->__moduleName);
450 }
451 catch (Exception* _e) {
452 output << _e->toStringAll() << endl;
453 _e->destroy();
454 result = FALSE;
455 }
456
457#ifdef __DCL_DEBUG
458 DCLDebugSetThreadReport(
460 pOldOutput
461 );
462
463 if (!result && __pDebugFileOut) {
464 delete __pDebugFileOut;
465 __pDebugFileOut = NULL;
466 }
467#endif
468
469 return result;
470}
#define __DCL_ASSERT(expr)
Definition Object.h:371
virtual void onInitialize() __DCL_THROWS1(Exception *)
const wchar_t * __configPath
const wchar_t * __tempPath
virtual String toString() const
const DCL_HTTP_SERVER_API * pSAPI

◆ onCleanup()

void HttpServlet::onCleanup ( )
protectedvirtual

Reimplemented in EShopServlet.

Definition at line 378 of file HttpServlet.cpp.

380{
381}

◆ onHttpService()

virtual void HttpServlet::onHttpService ( const DCL_HTTP_SERVLET_CONTEXT * pContext)
protectedpure virtual

◆ onInitialize()

void HttpServlet::onInitialize ( )
protectedvirtual

Reimplemented in EShopServlet, and HttpServletEx.

Definition at line 373 of file HttpServlet.cpp.

375{
376}

Member Data Documentation

◆ __configPath

const wchar_t* HttpServlet::__configPath
protected

Definition at line 101 of file HttpServlet.h.

◆ __moduleName

const wchar_t* HttpServlet::__moduleName
protected

Definition at line 100 of file HttpServlet.h.

◆ __SAPI

const DCL_HTTP_SERVER_API* HttpServlet::__SAPI
protected

Definition at line 103 of file HttpServlet.h.

◆ __tempPath

const wchar_t* HttpServlet::__tempPath
protected

Definition at line 102 of file HttpServlet.h.


The documentation for this class was generated from the following files: