bes  Updated for version 3.20.6
BESWWWModule.cc
1 // BESWWWModule.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,2005 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 using std::endl;
37 using std::ostream;
38 using std::string;
39 
40 #include "BESWWWModule.h"
41 #include "BESDebug.h"
42 
43 #include "BESWWWNames.h"
44 #include "BESDapNames.h"
45 #include "BESResponseNames.h"
46 #include "BESResponseHandlerList.h"
47 #include "BESWWWResponseHandler.h"
48 
49 #include "BESWWWRequestHandler.h"
50 #include "BESRequestHandlerList.h"
51 
52 #include "BESDapService.h"
53 
54 #include "BESWWWTransmit.h"
55 #include "BESTransmitter.h"
56 #include "BESReturnManager.h"
57 #include "BESTransmitterNames.h"
58 
59 #include "BESXMLWWWGetCommand.h"
60 
61 void BESWWWModule::initialize(const string & modname)
62 {
63  BESDEBUG("www", "Initializing OPeNDAP WWW module " << modname << endl);
64 
65  BESRequestHandler *handler = new BESWWWRequestHandler(modname);
66  BESRequestHandlerList::TheList()->add_handler(modname, handler);
67 
68  BESResponseHandlerList::TheList()->add_handler(WWW_RESPONSE, BESWWWResponseHandler::WWWResponseBuilder);
69 
70  BESDapService::add_to_dap_service(WWW_SERVICE, "OPeNDAP HTML Form for data constraints and access");
71 
72  BESTransmitter *t = BESReturnManager::TheManager()->find_transmitter( DAP2_FORMAT);
73  if (t) {
74  t->add_method( WWW_TRANSMITTER, BESWWWTransmit::send_basic_form);
75  }
76 
77  BESXMLCommand::add_command( WWW_RESPONSE, BESXMLWWWGetCommand::CommandBuilder);
78 
79  BESDebug::Register("www");
80 
81  BESDEBUG("www", "Done Initializing OPeNDAP WWW module " << modname << endl);
82 }
83 
84 void BESWWWModule::terminate(const string & modname)
85 {
86  BESDEBUG("www", "Cleaning OPeNDAP WWW module " << modname << endl);
87 
88  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
89  if (rh) delete rh;
90 
91  BESResponseHandlerList::TheList()->remove_handler(WWW_RESPONSE);
92 
93  BESXMLCommand::del_command( WWW_RESPONSE);
94 
95  BESTransmitter *t = BESReturnManager::TheManager()->find_transmitter( DAP2_FORMAT);
96  if (t) {
97  t->remove_method(WWW_TRANSMITTER);
98  }
99 
100  t = BESReturnManager::TheManager()->find_transmitter( DAP2_FORMAT);
101  if (t) {
102  t->remove_method(WWW_TRANSMITTER);
103  }
104 
105  BESDEBUG("www", "Done Cleaning OPeNDAP WWW module " << modname << endl);
106 }
107 
114 void BESWWWModule::dump(ostream & strm) const
115 {
116  strm << BESIndent::LMarg << "BESWWWModule::dump - (" << (void *) this << ")" << endl;
117 }
118 
119 extern "C" BESAbstractModule *maker()
120 {
121  return new BESWWWModule;
122 }
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
BESAbstractModule
Definition: BESAbstractModule.h:40
BESDapService::add_to_dap_service
static void add_to_dap_service(const std::string &cmd, const std::string &desc)
static function to add commands to the dap service
Definition: BESDapService.cc:47
BESWWWModule
Definition: BESWWWModule.h:37
BESWWWRequestHandler
Definition: BESWWWRequestHandler.h:39
BESXMLCommand::add_command
static void add_command(const std::string &cmd_str, p_xmlcmd_builder cmd)
Add a command to the possible commands allowed by this BES.
Definition: BESXMLCommand.cc:86
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
BESTransmitter
Definition: BESTransmitter.h:47
BESWWWModule::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESWWWModule.cc:114
BESXMLCommand::del_command
static void del_command(const std::string &cmd_str)
Deletes the command called cmd_str from the list of possible commands.
Definition: BESXMLCommand.cc:96
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