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

#include <HttpServlet.h>

Inheritance diagram for HttpServlet:
Object HttpServletEx EShopServlet FastPageServlet ReqDumpServlet SrcToHtmlServlet

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 475 of file HttpServlet.cpp.

479{
480#ifdef __DCL_DEBUG
481 ReportErrorWriter output(
482 _servlet->__SAPI->pfnReportError,
483 hErrorReport,
484 __debugFileOutput
485 );
486
487 Writer* oldOutput = DCLDebugSetThreadReport(
488 Thread::self(),
489 &output
490 );
491#else
492 ReportErrorWriter output(
493 _servlet->__SAPI->pfnReportError,
494 hErrorReport,
495 NULL
496 );
497#endif
498
499 bool result = TRUE;
500 try {
501 __DCL_TRACE1(L"begin __cleanup [%ls]\n", _servlet->__moduleName);
502 _servlet->onCleanup();
503 __DCL_TRACE1(L"end __cleanup [%ls]\n", _servlet->__moduleName);
504 }
505 catch (Exception* e) {
506 output << e->toStringAll() << endl;
507 e->destroy();
508 result = FALSE;
509 }
510
511#ifdef __DCL_DEBUG
512 oldOutput = DCLDebugSetThreadReport(
513 Thread::self(),
514 oldOutput
515 );
516
517 if (oldOutput != &output) {
518 __DCL_TRACE0(L"Assertion Fail! 'oldOutput == &writer'\n");
519 }
520
521 if (__debugFileOutput) {
522 delete __debugFileOutput;
523 __debugFileOutput = NULL;
524 }
525#endif
526
527 return result;
528}
#define NULL
Definition Config.h:312
#define TRUE
#define FALSE
#define __DCL_TRACE0(psz)
Definition Object.h:398
#define __DCL_TRACE1(fmt, arg1)
Definition Object.h:399
DCLCVAR const struct __endl endl
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 thread_t self()
Definition Thread.cpp:175
DCLHttpWriteStream pfnReportError

◆ __httpService()

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

Definition at line 530 of file HttpServlet.cpp.

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

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

Definition at line 381 of file HttpServlet.cpp.

383{
384}

◆ onHttpService()

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

◆ onInitialize()

void HttpServlet::onInitialize ( )
protectedvirtual

Reimplemented in EShopServlet, FastPageServlet, HttpServletEx, and SrcToHtmlServlet.

Definition at line 376 of file HttpServlet.cpp.

378{
379}

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: