OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
DapModule.cc
Go to the documentation of this file.
00001 // DapModule.cc
00002 
00003 #include <iostream>
00004 
00005 using std::endl ;
00006 
00007 #include "DapModule.h"
00008 #include "DapRequestHandler.h"
00009 #include "DapResponseNames.h"
00010 
00011 #include <BESRequestHandlerList.h>
00012 #include <BESDebug.h>
00013 #include <BESResponseHandlerList.h>
00014 #include <BESResponseNames.h>
00015 #include <BESContainerStorageList.h>
00016 #include <BESContainerStorageCatalog.h>
00017 #include <BESCatalogDirectory.h>
00018 #include <BESCatalogList.h>
00019 
00020 #define DAP_CATALOG "catalog"
00021 
00022 void
00023 DapModule::initialize( const string &modname )
00024 {
00025     BESDEBUG( modname, "Initializing Dap Module "
00026                        << modname << endl ) ;
00027 
00028     BESDEBUG( modname, "    adding dap request handler" << endl ) ;
00029     BESRequestHandlerList::TheList()->add_handler( modname, new DapRequestHandler( modname ) ) ;
00030 
00031     BESDEBUG( "nc", "    adding " << DAP_CATALOG << " catalog" << endl ) ;
00032     if( !BESCatalogList::TheCatalogList()->ref_catalog( DAP_CATALOG ) )
00033     {
00034         BESCatalogList::TheCatalogList()->
00035             add_catalog( new BESCatalogDirectory( DAP_CATALOG ) ) ;
00036     }
00037     else
00038     {
00039         BESDEBUG( "nc", "    catalog already exists, skipping" << endl ) ;
00040     }
00041 
00042     BESDEBUG( "nc", "    adding catalog container storage " << DAP_CATALOG
00043                     << endl ) ;
00044     if( !BESContainerStorageList::TheList()->ref_persistence( DAP_CATALOG ) )
00045     {
00046         BESContainerStorageCatalog *csc =
00047             new BESContainerStorageCatalog( DAP_CATALOG ) ;
00048         BESContainerStorageList::TheList()->add_persistence( csc ) ;
00049     }
00050     else
00051     {
00052         BESDEBUG( "nc", "    storage already exists, skipping" << endl ) ;
00053     }
00054 
00055     BESDEBUG( modname, "    adding Dap debug context" << endl ) ;
00056     BESDebug::Register( modname ) ;
00057 
00058     BESDEBUG( modname, "Done Initializing Dap Module "
00059                        << modname << endl ) ;
00060 }
00061 
00062 void
00063 DapModule::terminate( const string &modname )
00064 {
00065     BESDEBUG( modname, "Cleaning Dap module " << modname << endl ) ;
00066 
00067     BESRequestHandler *rh = 0 ;
00068 
00069     BESDEBUG( modname, "    removing dap request handler" << endl ) ;
00070     rh = BESRequestHandlerList::TheList()->remove_handler( modname ) ;
00071     if( rh ) delete rh ; rh = 0 ;
00072 
00073     BESDEBUG( "nc", "    removing catalog container storage"
00074                     << DAP_CATALOG << endl ) ;
00075     BESContainerStorageList::TheList()->deref_persistence( DAP_CATALOG ) ;
00076 
00077     BESDEBUG( "nc", "    removing " << DAP_CATALOG << " catalog" << endl ) ;
00078     BESCatalogList::TheCatalogList()->deref_catalog( DAP_CATALOG ) ;
00079 
00080     BESDEBUG( modname, "Done Cleaning Dap module "
00081                        << modname << endl ) ;
00082 }
00083 
00084 extern "C"
00085 {
00086     BESAbstractModule *maker()
00087     {
00088         return new DapModule ;
00089     }
00090 }
00091 
00092 void
00093 DapModule::dump( ostream &strm ) const
00094 {
00095     strm << BESIndent::LMarg << "DapModule::dump - ("
00096                              << (void *)this << ")" << endl ;
00097 }
00098