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