OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESDapModule.cc
Go to the documentation of this file.
1 // BESDapModule.cc
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 
32 #include <iostream>
33 
34 using std::endl ;
35 
36 #include "BESDapModule.h"
37 
38 #include "BESDapRequestHandler.h"
39 #include "BESRequestHandlerList.h"
40 
41 #include "BESDapNames.h"
42 #include "BESNames.h"
43 #include "BESResponseHandlerList.h"
44 
45 #include "BESDASResponseHandler.h"
46 #include "BESDDSResponseHandler.h"
47 #include "BESDataResponseHandler.h"
48 #include "BESDDXResponseHandler.h"
50 
52 
53 #include "BESServiceRegistry.h"
54 
55 #include "BESDapTransmit.h"
56 #include "BESTransmitter.h"
57 #include "BESReturnManager.h"
58 #include "BESTransmitterNames.h"
59 
60 #include "BESDebug.h"
61 #include "BESInternalFatalError.h"
62 #include "BESExceptionManager.h"
63 #include "BESDapError.h"
64 
65 void
66 BESDapModule::initialize( const string &modname )
67 {
68  BESDEBUG( "dap", "Initializing DAP Modules:" << endl ) ;
69 
70  BESDEBUG( "dap", " adding " << modname << " request handler" << endl ) ;
72 
73  BESDEBUG( "dap", " adding " << DAS_RESPONSE << " response handler" << endl ) ;
75 #if 0
76  BESDEBUG( "dap", " adding " << DMR_RESPONSE << " response handler" << endl ) ;
77  BESResponseHandlerList::TheList()->add_handler( DMR_RESPONSE, BESDMRResponseHandler::DMRResponseBuilder ) ;
78 #endif
79  BESDEBUG( "dap", " adding " << DDS_RESPONSE << " response handler" << endl ) ;
81 
82  BESDEBUG( "dap", " adding " << DDX_RESPONSE << " response handler" << endl ) ;
84 
85  BESDEBUG( "dap", " adding " << DATA_RESPONSE << " response handler" << endl ) ;
87 
88  BESDEBUG( "dap", " adding " << DATADDX_RESPONSE << " response handler" << endl ) ;
90 
91  BESDEBUG( "dap", " adding " << CATALOG_RESPONSE << " response handler" << endl ) ;
93 
94  BESDEBUG( "dap", "Adding " << OPENDAP_SERVICE << " services:" << endl ) ;
96  registry->add_service( OPENDAP_SERVICE ) ;
99 #if 0
100  registry->add_to_service( OPENDAP_SERVICE, DMR_SERVICE,
102 #endif
111 
112  BESDEBUG( "dap", "Initializing DAP Basic Transmitters:" << endl ) ;
114  new BESDapTransmit( ) ) ;
115 
116  BESDEBUG( "dap", " adding dap exception handler" << endl ) ;
118 
119  BESDEBUG( "dap", " adding dap debug context" << endl ) ;
120  BESDebug::Register( "dap" ) ;
121 
122  BESDEBUG( "dap", "Done Initializing DAP Modules:" << endl ) ;
123 }
124 
125 void
126 BESDapModule::terminate( const string &modname )
127 {
128  BESDEBUG( "dap", "Removing DAP Modules:" << endl ) ;
129 
131  // BESResponseHandlerList::TheList()->remove_handler( DMR_RESPONSE ) ;
137 
138  BESDEBUG( "dap", " removing " << OPENDAP_SERVICE << " services" << endl ) ;
140 
141  BESDEBUG( "dap", " removing dap Request Handler " << modname << endl ) ;
143  if( rh ) delete rh ;
144 
146 
147  BESDEBUG( "dap", "Done Removing DAP Modules:" << endl ) ;
148 }
149 
156 void
157 BESDapModule::dump( ostream &strm ) const
158 {
159  strm << BESIndent::LMarg << "BESDapModule::dump - ("
160  << (void *)this << ")" << endl ;
161 }
162 
163 extern "C"
164 {
166  {
167  return new BESDapModule ;
168  }
169 }
170 
#define DATA_SERVICE
Definition: BESDapNames.h:70
#define DDS_DESCRIPT
Definition: BESDapNames.h:61
virtual void initialize(const string &modname)
Definition: BESDapModule.cc:66
virtual bool del_transmitter(const string &name)
#define DAS_SERVICE
Definition: BESDapNames.h:55
static BESResponseHandler * DataDDXResponseBuilder(const string &name)
static BESResponseHandler * CatalogResponseBuilder(const string &name)
virtual bool add_handler(const string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
virtual void add_service(const string &name)
Add a service to the BES.
#define DDX_RESPONSE
Definition: BESDapNames.h:64
BESAbstractModule * maker()
#define OPENDAP_SERVICE
macros representing the default response objects handled
Definition: BESDapNames.h:51
The service registry allows modules to register services with the BES that they provide.
virtual void add_to_service(const string &service, const string &cmd, const string &cmd_descript, const string &format)
This function allows callers to add to a service that already exists.
virtual void add_ehm_callback(p_bes_ehm ehm)
Register an exception handler with the manager.
virtual void remove_service(const string &name)
remove a service from the BES
virtual bool add_transmitter(const string &name, BESTransmitter *transmitter)
static BESExceptionManager * TheEHM()
static BESResponseHandler * DDXResponseBuilder(const string &name)
#define DATADDX_RESPONSE
Definition: BESDapNames.h:74
static BESReturnManager * TheManager()
#define DDX_DESCRIPT
Definition: BESDapNames.h:66
#define DATA_DESCRIPT
Definition: BESDapNames.h:71
#define DATA_RESPONSE
Definition: BESDapNames.h:69
static BESServiceRegistry * TheRegistry()
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
#define DDX_SERVICE
Definition: BESDapNames.h:65
#define DATADDX_SERVICE
Definition: BESDapNames.h:75
virtual bool add_handler(const string &handler, p_response_handler handler_method)
add a response handler to the list
#define DAP2_FORMAT
Definition: BESDapNames.h:52
Represents a specific data type request handler.
#define DATADDX_DESCRIPT
Definition: BESDapNames.h:76
static BESRequestHandlerList * TheList()
#define DAS_DESCRIPT
Definition: BESDapNames.h:56
virtual bool remove_handler(const string &handler)
removes a response handler from the list
#define CATALOG_RESPONSE
Definition: BESNames.h:38
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
static int handleException(BESError &e, BESDataHandlerInterface &dhi)
handles exceptions if the error context is set to dap2
Definition: BESDapError.cc:119
virtual void dump(ostream &strm) const
dumps information about this object
static BESResponseHandler * DASResponseBuilder(const string &name)
virtual void terminate(const string &modname)
static BESResponseHandler * DDSResponseBuilder(const string &name)
#define DDS_SERVICE
Definition: BESDapNames.h:60
static void Register(const string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
static BESResponseHandler * DataResponseBuilder(const string &name)
#define DDS_RESPONSE
Definition: BESDapNames.h:59
#define DAS_RESPONSE
Definition: BESDapNames.h:54
static BESResponseHandlerList * TheList()
virtual BESRequestHandler * remove_handler(const string &handler_name)
remove and return the specified request handler