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 "BESResponseNames.h"
00042 #include "BESResponseHandlerList.h"
00043 
00044 #include "BESDASResponseHandler.h"
00045 #include "BESDDSResponseHandler.h"
00046 #include "BESDataResponseHandler.h"
00047 #include "BESDDXResponseHandler.h"
00048 
00049 #include "BESCatalogResponseHandler.h"
00050 
00051 #include "BESServiceRegistry.h"
00052 
00053 #include "BESDapTransmit.h"
00054 #include "BESTransmitter.h"
00055 #include "BESReturnManager.h"
00056 #include "BESTransmitterNames.h"
00057 
00058 #include "BESDebug.h"
00059 #include "BESInternalFatalError.h"
00060 #include "BESExceptionManager.h"
00061 #include "BESDapError.h"
00062 
00063 void
00064 BESDapModule::initialize( const string &modname )
00065 {
00066     BESDEBUG( "dap", "Initializing DAP Modules:" << endl )
00067 
00068     BESDEBUG( "dap", "    adding " << modname << " request handler" << endl )
00069     BESRequestHandlerList::TheList()->add_handler( modname, new BESDapRequestHandler( modname ) ) ;
00070 
00071     BESDEBUG( "dap", "    adding " << DAS_RESPONSE << " response handler" << endl )
00072     BESResponseHandlerList::TheList()->add_handler( DAS_RESPONSE, BESDASResponseHandler::DASResponseBuilder ) ;
00073 
00074     BESDEBUG( "dap", "    adding " << DDS_RESPONSE << " response handler" << endl )
00075     BESResponseHandlerList::TheList()->add_handler( DDS_RESPONSE, BESDDSResponseHandler::DDSResponseBuilder ) ;
00076 
00077     BESDEBUG( "dap", "    adding " << DDX_RESPONSE << " response handler" << endl )
00078     BESResponseHandlerList::TheList()->add_handler( DDX_RESPONSE, BESDDXResponseHandler::DDXResponseBuilder ) ;
00079 
00080     BESDEBUG( "dap", "    adding " << DATA_RESPONSE << " response handler" << endl )
00081     BESResponseHandlerList::TheList()->add_handler( DATA_RESPONSE, BESDataResponseHandler::DataResponseBuilder ) ;
00082 
00083     BESDEBUG( "dap", "    adding " << CATALOG_RESPONSE << " response handler" << endl )
00084     BESResponseHandlerList::TheList()->add_handler( CATALOG_RESPONSE, BESCatalogResponseHandler::CatalogResponseBuilder ) ;
00085 
00086     BESDEBUG( "dap", "Adding " << OPENDAP_SERVICE << " services:" << endl )
00087     BESServiceRegistry *registry = BESServiceRegistry::TheRegistry() ;
00088     registry->add_service( OPENDAP_SERVICE ) ;
00089     registry->add_to_service( OPENDAP_SERVICE, DAS_SERVICE,
00090                               DAS_DESCRIPT, DAP2_FORMAT ) ;
00091     registry->add_to_service( OPENDAP_SERVICE, DDS_SERVICE,
00092                               DDS_DESCRIPT, DAP2_FORMAT ) ;
00093     registry->add_to_service( OPENDAP_SERVICE, DDX_SERVICE,
00094                               DDX_DESCRIPT, DAP2_FORMAT ) ;
00095     registry->add_to_service( OPENDAP_SERVICE, DATA_SERVICE,
00096                               DATA_DESCRIPT, DAP2_FORMAT ) ;
00097 
00098     BESDEBUG( "dap", "Initializing DAP Basic Transmitters:" << endl )
00099     BESReturnManager::TheManager()->add_transmitter( DAP2_FORMAT,
00100                                                      new BESDapTransmit( ) ) ;
00101 
00102     BESDEBUG( "dap", "    adding dap exception handler" << endl )
00103     BESExceptionManager::TheEHM()->add_ehm_callback( BESDapError::handleException ) ;
00104 
00105     BESDEBUG( "dap", "    adding dap debug context" << endl )
00106     BESDebug::Register( "dap" ) ;
00107 
00108     BESDEBUG( "dap", "Done Initializing DAP Modules:" << endl )
00109 }
00110 
00111 void
00112 BESDapModule::terminate( const string &modname )
00113 {
00114     BESDEBUG( "dap", "Removing DAP Modules:" << endl )
00115 
00116     BESDEBUG( "dap", "    removing dap Response handlers " << modname << endl )
00117     BESResponseHandlerList::TheList()->remove_handler( DAS_RESPONSE ) ;
00118     BESResponseHandlerList::TheList()->remove_handler( DDS_RESPONSE ) ;
00119     BESResponseHandlerList::TheList()->remove_handler( DDX_RESPONSE ) ;
00120     BESResponseHandlerList::TheList()->remove_handler( DATA_RESPONSE ) ;
00121     BESResponseHandlerList::TheList()->remove_handler( CATALOG_RESPONSE ) ;
00122 
00123     BESDEBUG( "dap", "    removing " << OPENDAP_SERVICE << " services" << endl )
00124     BESServiceRegistry::TheRegistry()->remove_service( OPENDAP_SERVICE ) ;
00125 
00126     BESDEBUG( "dap", "    removing dap Request Handler " << modname << endl )
00127     BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler( modname ) ;
00128     if( rh ) delete rh ;
00129 
00130     BESDEBUG( "dap", "Done Removing DAP Modules:" << endl )
00131 }
00132 
00139 void
00140 BESDapModule::dump( ostream &strm ) const
00141 {
00142     strm << BESIndent::LMarg << "BESDapModule::dump - ("
00143                              << (void *)this << ")" << endl ;
00144 }
00145 
00146 extern "C"
00147 {
00148     BESAbstractModule *maker()
00149     {
00150         return new BESDapModule ;
00151     }
00152 }
00153 

Generated on 19 Feb 2010 for OPeNDAP Hyrax Back End Server (BES) by  doxygen 1.6.1