bes  Updated for version 3.20.6
BESDapModule.cc
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"
49 #include "BESDataDDXResponseHandler.h"
50 #include "BESDMRResponseHandler.h"
51 #include "BESDap4ResponseHandler.h"
52 
53 #if 0
54 #include "BESCatalogResponseHandler.h"
55 #endif
56 
57 #include "BESServiceRegistry.h"
58 
59 #if 0
60 // These I added to test the Null AggregationServer code jhrg 1/30/15
61 #include "BESDapNullAggregationServer.h"
62 // Removed jhrg 3/17/15 #include "BESDapSequenceAggregationServer.h"
63 #include "BESAggFactory.h"
64 #endif
65 
66 #include "BESDapTransmit.h"
67 #include "BESTransmitter.h"
68 #include "BESReturnManager.h"
69 #include "BESTransmitterNames.h"
70 
71 #include "BESDebug.h"
72 #include "BESInternalFatalError.h"
73 #include "BESDapError.h"
74 
75 #include "DapFunctionUtils.h"
76 #include "ServerFunctionsList.h"
77 #include "ShowPathInfoResponseHandler.h"
78 
79 
80 void BESDapModule::initialize(const string &modname)
81 {
82  BESDEBUG("dap", "Initializing DAP Modules:" << endl);
83 
84  BESRequestHandlerList::TheList()->add_handler(modname, new BESDapRequestHandler(modname));
85  BESResponseHandlerList::TheList()->add_handler(DAS_RESPONSE, BESDASResponseHandler::DASResponseBuilder);
86  BESResponseHandlerList::TheList()->add_handler( DDS_RESPONSE, BESDDSResponseHandler::DDSResponseBuilder );
87  BESResponseHandlerList::TheList()->add_handler(DDX_RESPONSE, BESDDXResponseHandler::DDXResponseBuilder);
88  BESResponseHandlerList::TheList()->add_handler(DATA_RESPONSE, BESDataResponseHandler::DataResponseBuilder);
89  BESResponseHandlerList::TheList()->add_handler(DATADDX_RESPONSE, BESDataDDXResponseHandler::DataDDXResponseBuilder);
90  BESResponseHandlerList::TheList()->add_handler(DMR_RESPONSE, BESDMRResponseHandler::DMRResponseBuilder);
91  BESResponseHandlerList::TheList()->add_handler(DAP4DATA_RESPONSE, BESDap4ResponseHandler::Dap4ResponseBuilder);
92 
93 #if 0
94  BESDEBUG("dap", " adding " << CATALOG_RESPONSE << " response handler" << endl);
95  BESResponseHandlerList::TheList()->add_handler(CATALOG_RESPONSE, BESCatalogResponseHandler::CatalogResponseBuilder);
96 #endif
97 
98 
99  BESDEBUG("dap", "Adding " << OPENDAP_SERVICE << " services:" << endl);
100  BESServiceRegistry *registry = BESServiceRegistry::TheRegistry();
101  registry->add_service(OPENDAP_SERVICE);
102  registry->add_to_service(OPENDAP_SERVICE, DAS_SERVICE, DAS_DESCRIPT, DAP2_FORMAT);
103  registry->add_to_service(OPENDAP_SERVICE, DDS_SERVICE, DDS_DESCRIPT, DAP2_FORMAT);
104  registry->add_to_service(OPENDAP_SERVICE, DDX_SERVICE, DDX_DESCRIPT, DAP2_FORMAT);
105  registry->add_to_service(OPENDAP_SERVICE, DATA_SERVICE, DATA_DESCRIPT, DAP2_FORMAT);
106  registry->add_to_service(OPENDAP_SERVICE, DATADDX_SERVICE, DATADDX_DESCRIPT, DAP2_FORMAT);
107 
108  registry->add_to_service(OPENDAP_SERVICE, DMR_SERVICE, DMR_DESCRIPT, DAP2_FORMAT);
109  registry->add_to_service(OPENDAP_SERVICE, DAP4DATA_SERVICE, DAP4DATA_DESCRIPT, DAP2_FORMAT);
110 
111  BESDEBUG("dap", "Initializing DAP Basic Transmitters:" << endl);
112  BESReturnManager::TheManager()->add_transmitter(DAP2_FORMAT, new BESDapTransmit());
113  // TODO ?? BESReturnManager::TheManager()->add_transmitter( DAP4_FORMAT, new BESDapTransmit( ) );
114 
115  BESDEBUG("dap", " adding DAP Utility Function 'wrapitup'()" << endl);
116  WrapItUp *wiu = new WrapItUp();
117  libdap::ServerFunctionsList::TheList()->add_function(wiu);
118 
119  BESDEBUG("dap", " adding " << SHOW_PATH_INFO_RESPONSE << " response handler" << endl ) ;
120  BESResponseHandlerList::TheList()->add_handler( SHOW_PATH_INFO_RESPONSE, ShowPathInfoResponseHandler::ShowPathInfoResponseBuilder ) ;
121 
122  BESDEBUG("dap", " adding dap debug context" << endl);
123  BESDebug::Register("dap");
124 
125  BESDEBUG("dap", "Done Initializing DAP Modules:" << endl);
126 }
127 
128 void BESDapModule::terminate(const string &modname)
129 {
130  BESDEBUG("dap", "Removing DAP Modules:" << endl);
131 
132  BESResponseHandlerList::TheList()->remove_handler(DAS_RESPONSE);
133  BESResponseHandlerList::TheList()->remove_handler(DDS_RESPONSE);
134  BESResponseHandlerList::TheList()->remove_handler(DDX_RESPONSE);
135  BESResponseHandlerList::TheList()->remove_handler(DATA_RESPONSE);
136  BESResponseHandlerList::TheList()->remove_handler(DATADDX_RESPONSE);
137 
138  BESResponseHandlerList::TheList()->remove_handler(CATALOG_RESPONSE);
139 
140  BESResponseHandlerList::TheList()->remove_handler(DMR_RESPONSE);
141  BESResponseHandlerList::TheList()->remove_handler(DAP4DATA_RESPONSE);
142 
143 #if 0
144  BESResponseHandlerList::TheList()->remove_handler(CATALOG_RESPONSE);
145 #endif
146 
147  BESDEBUG("dap", " removing " << OPENDAP_SERVICE << " services" << endl);
148  BESServiceRegistry::TheRegistry()->remove_service(OPENDAP_SERVICE);
149 
150  BESDEBUG("dap", " removing dap Request Handler " << modname << endl);
151  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
152  if (rh) delete rh;
153 
154  BESReturnManager::TheManager()->del_transmitter(DAP2_FORMAT);
155  // TODO ?? BESReturnManager::TheManager()->del_transmitter( DAP4_FORMAT );
156 
157  BESDEBUG("dap", "Done Removing DAP Modules:" << endl);
158 }
159 
166 void BESDapModule::dump(ostream &strm) const
167 {
168  strm << BESIndent::LMarg << "BESDapModule::dump - (" << (void *) this << ")" << endl;
169 }
170 
171 extern "C" {
172 BESAbstractModule *maker()
173 {
174  return new BESDapModule;
175 }
176 }
177 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:74
BESRequestHandlerList::remove_handler
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Definition: BESRequestHandlerList.cc:76
BESServiceRegistry::add_to_service
virtual void add_to_service(const std::string &service, const std::string &cmd, const std::string &cmd_descript, const std::string &format)
This function allows callers to add to a service that already exists.
Definition: BESServiceRegistry.cc:90
WrapItUp
Definition: DapFunctionUtils.h:46
BESServiceRegistry
The service registry allows modules to register services with the BES that they provide.
Definition: BESServiceRegistry.h:56
BESAbstractModule
Definition: BESAbstractModule.h:40
BESServiceRegistry::remove_service
virtual void remove_service(const std::string &name)
remove a service from the BES
Definition: BESServiceRegistry.cc:182
BESResponseHandlerList::remove_handler
virtual bool remove_handler(const std::string &handler)
removes a response handler from the list
Definition: BESResponseHandlerList.cc:74
BESRequestHandlerList::add_handler
virtual bool add_handler(const std::string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
Definition: BESRequestHandlerList.cc:54
BESDebug::Register
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
BESDapModule
Definition: BESDapModule.h:37
BESDapModule::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESDapModule.cc:166
BESDapRequestHandler
Definition: BESDapRequestHandler.h:39
BESDapTransmit
Definition: BESDapTransmit.h:42
BESResponseHandlerList::add_handler
virtual bool add_handler(const std::string &handler, p_response_handler handler_method)
add a response handler to the list
Definition: BESResponseHandlerList.cc:55
BESServiceRegistry::add_service
virtual void add_service(const std::string &name)
Add a service to the BES.
Definition: BESServiceRegistry.cc:59