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