BESDapModule.cc

Go to the documentation of this file.
00001 // BESDapModule.cc
00002 
00003 // This file is part of bes, A C++ back-end server implementation framework
00004 // for the OPeNDAP Data Access Protocol.
00005 
00006 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
00007 // Author: Patrick West <pwest@ucar.edu>
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 // 
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 // 
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // You can contact University Corporation for Atmospheric Research at
00024 // 3080 Center Green Drive, Boulder, CO 80301
00025  
00026 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
00027 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
00028 //
00029 // Authors:
00030 //      pwest       Patrick West <pwest@ucar.edu>
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 
Generated by  doxygen 1.6.2-20100208