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,2005 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 "BESDapTransmit.h"
00052 #include "BESTransmitter.h"
00053 #include "BESReturnManager.h"
00054 #include "BESTransmitterNames.h"
00055 
00056 #include "BESDebug.h"
00057 #include "BESException.h"
00058 #include "BESExceptionManager.h"
00059 #include "BESDapHandlerException.h"
00060 
00061 void
00062 BESDapModule::initialize( const string &modname )
00063 {
00064     BESDEBUG( "dap", "Initializing DAP Modules:" << endl )
00065 
00066     BESDEBUG( "dap", "    adding " << modname << " request handler" << endl )
00067     BESRequestHandlerList::TheList()->add_handler( modname, new BESDapRequestHandler( modname ) ) ;
00068 
00069     BESDEBUG( "dap", "    adding " << DAS_RESPONSE << " response handler" << endl )
00070     BESResponseHandlerList::TheList()->add_handler( DAS_RESPONSE, BESDASResponseHandler::DASResponseBuilder ) ;
00071 
00072     BESDEBUG( "dap", "    adding " << DDS_RESPONSE << " response handler" << endl )
00073     BESResponseHandlerList::TheList()->add_handler( DDS_RESPONSE, BESDDSResponseHandler::DDSResponseBuilder ) ;
00074 
00075     BESDEBUG( "dap", "    adding " << DDX_RESPONSE << " response handler" << endl )
00076     BESResponseHandlerList::TheList()->add_handler( DDX_RESPONSE, BESDDXResponseHandler::DDXResponseBuilder ) ;
00077 
00078     BESDEBUG( "dap", "    adding " << DATA_RESPONSE << " response handler" << endl )
00079     BESResponseHandlerList::TheList()->add_handler( DATA_RESPONSE, BESDataResponseHandler::DataResponseBuilder ) ;
00080 
00081     BESDEBUG( "dap", "    adding " << CATALOG_RESPONSE << " response handler" << endl )
00082     BESResponseHandlerList::TheList()->add_handler( CATALOG_RESPONSE, BESCatalogResponseHandler::CatalogResponseBuilder ) ;
00083 
00084     BESDEBUG( "dap", "Initializing DAP Basic Transmitters:" << endl )
00085     BESTransmitter *t = BESReturnManager::TheManager()->find_transmitter( BASIC_TRANSMITTER ) ;
00086     if( t )
00087     {
00088         BESDEBUG( "dap", "    adding " << DAS_TRANSMITTER << endl )
00089         t->add_method( DAS_TRANSMITTER, BESDapTransmit::send_basic_das ) ;
00090 
00091         BESDEBUG( "dap", "    adding " << DDS_TRANSMITTER << endl )
00092         t->add_method( DDS_TRANSMITTER, BESDapTransmit::send_basic_dds ) ;
00093 
00094         BESDEBUG( "dap", "    adding " << DDX_TRANSMITTER << endl )
00095         t->add_method( DDX_TRANSMITTER, BESDapTransmit::send_basic_ddx ) ;
00096 
00097         BESDEBUG( "dap", "    adding " << DATA_TRANSMITTER << endl )
00098         t->add_method( DATA_TRANSMITTER, BESDapTransmit::send_basic_data ) ;
00099     }
00100     else
00101     {
00102         string err = (string)"Unable to initialize basic transmitter "
00103                      + "with dap transmit functions" ;
00104         throw BESException( err, __FILE__, __LINE__ ) ;
00105     }
00106 
00107     BESDEBUG( "dap", "Initializing DAP HTTP Transmitters:" << endl )
00108     t = BESReturnManager::TheManager()->find_transmitter( HTTP_TRANSMITTER ) ;
00109     if( t )
00110     {
00111         BESDEBUG( "dap", "    adding " << DAS_TRANSMITTER << endl )
00112         t->add_method( DAS_TRANSMITTER, BESDapTransmit::send_http_das ) ;
00113 
00114         BESDEBUG( "dap", "    adding " << DDS_TRANSMITTER << endl )
00115         t->add_method( DDS_TRANSMITTER, BESDapTransmit::send_http_dds ) ;
00116 
00117         BESDEBUG( "dap", "    adding " << DDX_TRANSMITTER << endl )
00118         t->add_method( DDX_TRANSMITTER, BESDapTransmit::send_http_ddx ) ;
00119 
00120         BESDEBUG( "dap", "    adding " << DATA_TRANSMITTER << endl )
00121         t->add_method( DATA_TRANSMITTER, BESDapTransmit::send_http_data ) ;
00122     }
00123     else
00124     {
00125         string err = (string)"Unable to initialize http transmitter "
00126                      + "with dap transmit functions" ;
00127         throw BESException( err, __FILE__, __LINE__ ) ;
00128     }
00129 
00130     BESDEBUG( "dap", "    adding dap exception handler" << endl )
00131     BESExceptionManager::TheEHM()->add_ehm_callback( BESDapHandlerException::handleException ) ;
00132 
00133     BESDEBUG( "dap", "    adding dap debug context" << endl )
00134     BESDebug::Register( "dap" ) ;
00135 
00136     BESDEBUG( "dap", "Done Initializing DAP Modules:" << endl )
00137 }
00138 
00139 void
00140 BESDapModule::terminate( const string &modname )
00141 {
00142     BESDEBUG( "dap", "Removing DAP Modules:" << endl )
00143 
00144     BESResponseHandlerList::TheList()->remove_handler( DAS_RESPONSE ) ;
00145     BESResponseHandlerList::TheList()->remove_handler( DDS_RESPONSE ) ;
00146     BESResponseHandlerList::TheList()->remove_handler( DDX_RESPONSE ) ;
00147     BESResponseHandlerList::TheList()->remove_handler( DATA_RESPONSE ) ;
00148     BESResponseHandlerList::TheList()->remove_handler( CATALOG_RESPONSE ) ;
00149 
00150     BESDEBUG( "dap", "Done Removing DAP Modules:" << endl )
00151 }
00152 
00159 void
00160 BESDapModule::dump( ostream &strm ) const
00161 {
00162     strm << BESIndent::LMarg << "BESDapModule::dump - ("
00163                              << (void *)this << ")" << endl ;
00164 }
00165 
00166 extern "C"
00167 {
00168     BESAbstractModule *maker()
00169     {
00170         return new BESDapModule ;
00171     }
00172 }
00173 

Generated on Fri Nov 30 12:06:46 2007 for OPeNDAP Back End Server (BES) by  doxygen 1.5.1