CPPSERV


Home Projects Jobs Clientele Contact
CPPSERV Documentation Download TODO Mailing lists Bug tracker News RSS Feed Browse source

servletcontainer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Ilya A. Volynets-Evenbakh                       *
00003  *   ilya@total-knowledge.com                                              *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef CSERVIMPLSERVLETCONTAINER_H
00021 #define CSERVIMPLSERVLETCONTAINER_H
00022 
00023 #include <string>
00024 #include <ServletConfigImpl.h>
00025 #include <servlet/Servlet.h>
00026 #include <connection.h>
00027 #include <HttpSessionImpl.h>
00028 
00029 #include <servlet/RequestDispatcher.h>
00030 #include <servlet/HttpServlet.h>
00031 
00032 //Forward declarations
00033 namespace servlet {
00034 class Traceable;
00035 }
00036 
00037 namespace container {
00038 
00044 class ServletContainer: public servlet::RequestDispatcher
00045 {
00046 public:
00047     ServletContainer(servlet::Servlet*, container::ServletConfigImpl* conf,
00048         const std::string& path, size_t maxRequestSize, size_t maxFileSize,
00049         const std::string& mime, const std::string& enc, bool cache);
00050     ~ServletContainer();
00051 
00055     std::string getName() const
00056     {
00057         return getConfig()->getServletName();
00058     }
00059 
00063     const std::string& getPath() const
00064     {
00065         return m_path;
00066     }
00067 
00072     void init()
00073     {
00074         m_servlet->init(*m_conf);
00075     }
00076 
00081     void destroy()
00082     {
00083         m_servlet->destroy();
00084     }
00085 
00089     container::ServletConfigImpl* getConfig() {return m_conf;}
00090     const container::ServletConfigImpl* getConfig() const {return m_conf;}
00091     // RequestDispatcher implementation
00092     virtual void forward(servlet::ServletRequest& request, servlet::ServletResponse& response) const;
00093     virtual void include(servlet::ServletRequest& request, servlet::ServletResponse& response) const;
00094 private:
00095     servlet::Servlet* m_servlet;
00096     container::ServletConfigImpl* m_conf;
00097     std::string m_path;
00098     size_t m_maxRequestSize;
00099     size_t m_maxFileSize;
00100     std::string m_mime; 
00101     std::string m_enc; 
00102     bool m_cache;
00103 private:
00104     void invalidRequest(std::ostream& con, servlet::Traceable& e);
00105     void invalidRequest(std::ostream& con);
00106 protected:
00107     void service(Connection& con);
00108 private:
00109     friend class RequestHandler;
00110 };
00111 
00112 }
00113 
00114 #endif

SourceForge.net Logo