bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
GatewayModule.cc
1// GatewayModule.cc
2
3// -*- mode: c++; c-basic-offset:4 -*-
4
5// This file is part of gateway_module, A C++ module that can be loaded in to
6// the OPeNDAP Back-End Server (BES) and is able to handle remote requests.
7
8// Copyright (c) 2002,2003 OPeNDAP, Inc.
9// Author: Patrick West <pwest@ucar.edu>
10//
11// This library is free software; you can redistribute it and/or
12// modify it under the terms of the GNU Lesser General Public
13// License as published by the Free Software Foundation; either
14// version 2.1 of the License, or (at your option) any later version.
15//
16// This library is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19// Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public
22// License along with this library; if not, write to the Free Software
23// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24//
25// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
26
27#include "config.h"
28
29#include <iostream>
30#include <vector>
31
32#include <BESRequestHandlerList.h>
33#include <BESDebug.h>
34#include <BESResponseHandlerList.h>
35#include <BESContainerStorageList.h>
36
37#include "GatewayModule.h"
38#include "GatewayRequestHandler.h"
39#include "GatewayContainerStorage.h"
40#include "GatewayPathInfoResponseHandler.h"
41#include "GatewayPathInfoCommand.h"
42
43using namespace std;
44using namespace gateway;
45
46void GatewayModule::initialize(const string &modname)
47{
48 BESDEBUG(modname, "Initializing Gateway Module " << modname << endl);
49
50 BESDEBUG(modname, " adding " << modname << " request handler" << endl);
51 BESRequestHandlerList::TheList()->add_handler(modname, new GatewayRequestHandler(modname));
52
53 BESDEBUG(modname, " adding " << modname << " container storage" << endl);
54 BESContainerStorageList::TheList()->add_persistence(new GatewayContainerStorage(modname));
55
56 // BESDEBUG(modname, " initialize the gateway utilities and params" << endl);
57 // THis called used to set up HTTP cache proxies, etc now that's done in http - ndp 7/6/20
58 // GatewayUtils::Initialize();
59
60 BESDEBUG(modname, " adding Gateway debug context" << endl);
61 BESDebug::Register(modname);
62
63 BESDEBUG( modname, " adding " << SHOW_GATEWAY_PATH_INFO_RESPONSE_STR << " command" << endl ) ;
64 BESXMLCommand::add_command( SHOW_GATEWAY_PATH_INFO_RESPONSE_STR, GatewayPathInfoCommand::CommandBuilder ) ;
65
66 BESDEBUG(modname, " adding " << SHOW_GATEWAY_PATH_INFO_RESPONSE << " response handler" << endl ) ;
67 BESResponseHandlerList::TheList()->add_handler( SHOW_GATEWAY_PATH_INFO_RESPONSE, GatewayPathInfoResponseHandler::GatewayPathInfoResponseBuilder ) ;
68
69 BESDEBUG(modname, "Done Initializing Gateway Module " << modname << endl);
70}
71
72void GatewayModule::terminate(const string &modname)
73{
74 BESDEBUG(modname, "Cleaning Gateway module " << modname << endl);
75
76 BESResponseHandlerList::TheList()->remove_handler( SHOW_GATEWAY_PATH_INFO_RESPONSE) ;
77 BESXMLCommand::del_command( SHOW_GATEWAY_PATH_INFO_RESPONSE_STR) ;
78
79
80 BESDEBUG(modname, " removing " << modname << " request handler" << endl);
81 BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
82 if (rh)
83 delete rh;
84
85 BESContainerStorageList::TheList()->deref_persistence(modname);
86
87 // TERM_END
88 BESDEBUG(modname, "Done Cleaning Gateway module " << modname << endl);
89}
90
91void GatewayModule::dump(ostream &strm) const
92{
93 strm << BESIndent::LMarg << "GatewayModule::dump - (" << (void *) this << ")" << endl;
94}
95
96extern "C"
97BESAbstractModule *maker()
98{
99 return new GatewayModule;
100}
101
static void Register(const std::string &flagName)
register the specified debug flag
Definition BESDebug.h:126
static void del_command(const std::string &cmd_str)
Deletes the command called cmd_str from the list of possible commands.
static void add_command(const std::string &cmd_str, p_xmlcmd_builder cmd)
Add a command to the possible commands allowed by this BES.
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream