BESDapModule.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <iostream>
00033
00034 using std::endl ;
00035
00036 #include "BESDapModule.h"
00037
00038 #include "BESDapRequestHandler.h"
00039 #include "BESRequestHandlerList.h"
00040
00041 #include "BESDapNames.h"
00042 #include "BESResponseHandlerList.h"
00043
00044 #include "BESDASResponseHandler.h"
00045 #include "BESDDSResponseHandler.h"
00046 #include "BESDataResponseHandler.h"
00047 #include "BESDDXResponseHandler.h"
00048 #include "BESDataDDXResponseHandler.h"
00049
00050 #include "BESCatalogResponseHandler.h"
00051
00052 #include "BESServiceRegistry.h"
00053
00054 #include "BESDapTransmit.h"
00055 #include "BESTransmitter.h"
00056 #include "BESReturnManager.h"
00057 #include "BESTransmitterNames.h"
00058
00059 #include "BESDebug.h"
00060 #include "BESInternalFatalError.h"
00061 #include "BESExceptionManager.h"
00062 #include "BESDapError.h"
00063
00064 void
00065 BESDapModule::initialize( const string &modname )
00066 {
00067 BESDEBUG( "dap", "Initializing DAP Modules:" << endl ) ;
00068
00069 BESDEBUG( "dap", " adding " << modname << " request handler" << endl ) ;
00070 BESRequestHandlerList::TheList()->add_handler( modname, new BESDapRequestHandler( modname ) ) ;
00071
00072 BESDEBUG( "dap", " adding " << DAS_RESPONSE << " response handler" << endl ) ;
00073 BESResponseHandlerList::TheList()->add_handler( DAS_RESPONSE, BESDASResponseHandler::DASResponseBuilder ) ;
00074
00075 BESDEBUG( "dap", " adding " << DDS_RESPONSE << " response handler" << endl ) ;
00076 BESResponseHandlerList::TheList()->add_handler( DDS_RESPONSE, BESDDSResponseHandler::DDSResponseBuilder ) ;
00077
00078 BESDEBUG( "dap", " adding " << DDX_RESPONSE << " response handler" << endl ) ;
00079 BESResponseHandlerList::TheList()->add_handler( DDX_RESPONSE, BESDDXResponseHandler::DDXResponseBuilder ) ;
00080
00081 BESDEBUG( "dap", " adding " << DATA_RESPONSE << " response handler" << endl ) ;
00082 BESResponseHandlerList::TheList()->add_handler( DATA_RESPONSE, BESDataResponseHandler::DataResponseBuilder ) ;
00083
00084 BESDEBUG( "dap", " adding " << DATADDX_RESPONSE << " response handler" << endl ) ;
00085 BESResponseHandlerList::TheList()->add_handler( DATADDX_RESPONSE, BESDataDDXResponseHandler::DataDDXResponseBuilder ) ;
00086
00087 BESDEBUG( "dap", " adding " << CATALOG_RESPONSE << " response handler" << endl ) ;
00088 BESResponseHandlerList::TheList()->add_handler( CATALOG_RESPONSE, BESCatalogResponseHandler::CatalogResponseBuilder ) ;
00089
00090 BESDEBUG( "dap", "Adding " << OPENDAP_SERVICE << " services:" << endl ) ;
00091 BESServiceRegistry *registry = BESServiceRegistry::TheRegistry() ;
00092 registry->add_service( OPENDAP_SERVICE ) ;
00093 registry->add_to_service( OPENDAP_SERVICE, DAS_SERVICE,
00094 DAS_DESCRIPT, DAP2_FORMAT ) ;
00095 registry->add_to_service( OPENDAP_SERVICE, DDS_SERVICE,
00096 DDS_DESCRIPT, DAP2_FORMAT ) ;
00097 registry->add_to_service( OPENDAP_SERVICE, DDX_SERVICE,
00098 DDX_DESCRIPT, DAP2_FORMAT ) ;
00099 registry->add_to_service( OPENDAP_SERVICE, DATA_SERVICE,
00100 DATA_DESCRIPT, DAP2_FORMAT ) ;
00101 registry->add_to_service( OPENDAP_SERVICE, DATADDX_SERVICE,
00102 DATADDX_DESCRIPT, DAP2_FORMAT ) ;
00103
00104 BESDEBUG( "dap", "Initializing DAP Basic Transmitters:" << endl ) ;
00105 BESReturnManager::TheManager()->add_transmitter( DAP2_FORMAT,
00106 new BESDapTransmit( ) ) ;
00107
00108 BESDEBUG( "dap", " adding dap exception handler" << endl ) ;
00109 BESExceptionManager::TheEHM()->add_ehm_callback( BESDapError::handleException ) ;
00110
00111 BESDEBUG( "dap", " adding dap debug context" << endl ) ;
00112 BESDebug::Register( "dap" ) ;
00113
00114 BESDEBUG( "dap", "Done Initializing DAP Modules:" << endl ) ;
00115 }
00116
00117 void
00118 BESDapModule::terminate( const string &modname )
00119 {
00120 BESDEBUG( "dap", "Removing DAP Modules:" << endl ) ;
00121
00122 BESDEBUG( "dap", " removing dap Response handlers " << modname << endl ) ;
00123 BESResponseHandlerList::TheList()->remove_handler( DAS_RESPONSE ) ;
00124 BESResponseHandlerList::TheList()->remove_handler( DDS_RESPONSE ) ;
00125 BESResponseHandlerList::TheList()->remove_handler( DDX_RESPONSE ) ;
00126 BESResponseHandlerList::TheList()->remove_handler( DATA_RESPONSE ) ;
00127 BESResponseHandlerList::TheList()->remove_handler( DATADDX_RESPONSE ) ;
00128 BESResponseHandlerList::TheList()->remove_handler( CATALOG_RESPONSE ) ;
00129
00130 BESDEBUG( "dap", " removing " << OPENDAP_SERVICE << " services" << endl ) ;
00131 BESServiceRegistry::TheRegistry()->remove_service( OPENDAP_SERVICE ) ;
00132
00133 BESDEBUG( "dap", " removing dap Request Handler " << modname << endl ) ;
00134 BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler( modname ) ;
00135 if( rh ) delete rh ;
00136
00137 BESDEBUG( "dap", "Done Removing DAP Modules:" << endl ) ;
00138 }
00139
00146 void
00147 BESDapModule::dump( ostream &strm ) const
00148 {
00149 strm << BESIndent::LMarg << "BESDapModule::dump - ("
00150 << (void *)this << ")" << endl ;
00151 }
00152
00153 extern "C"
00154 {
00155 BESAbstractModule *maker()
00156 {
00157 return new BESDapModule ;
00158 }
00159 }
00160