Skip to content

Commit

Permalink
Cleanup httpservice and webconsole and make use of bootstrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
saschazelzer committed Feb 6, 2017
1 parent 73a5ef3 commit 084e032
Show file tree
Hide file tree
Showing 101 changed files with 11,624 additions and 6,909 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
117 changes: 58 additions & 59 deletions httpservice/include/cppmicroservices/httpservice/HttpServlet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,73 +41,71 @@ class US_HttpService_EXPORT HttpServlet : public std::enable_shared_from_this<Ht
{
public:

static const std::string& PROP_CONTEXT_ROOT();
static const std::string PROP_CONTEXT_ROOT;

HttpServlet();

/**
* Called by the servlet container to indicate to a servlet that the
* servlet is being placed into service.
*
* <p>The servlet container calls the <code>init</code>
* method exactly once after instantiating the servlet.
* The <code>init</code> method must complete successfully
* before the servlet can receive any requests.
*
* <p>The servlet container cannot place the servlet into service
* if the <code>init</code> method
* <ol>
* <li>Throws a <code>ServletException</code>
* <li>Does not return within a time period defined by the Web server
* </ol>
*
*
* @param config a <code>ServletConfig</code> object
* containing the servlet's
* configuration and initialization parameters
*
* @exception ServletException if an exception has occurred that
* interferes with the servlet's normal
* operation
*
* @see UnavailableException
* @see #GetServletConfig
*
*/
* Called by the servlet container to indicate to a servlet that the
* servlet is being placed into service.
*
* The servlet container calls the <code>init</code>
* method exactly once after instantiating the servlet.
* The <code>init</code> method must complete successfully
* before the servlet can receive any requests.
*
* The servlet container cannot place the servlet into service
* if the <code>init</code> method
* <ol>
* <li>Throws a <code>ServletException</code>
* <li>Does not return within a time period defined by the Web server
* </ol>
*
*
* @param config a <code>ServletConfig</code> object
* containing the servlet's
* configuration and initialization parameters
*
* @exception ServletException if an exception has occurred that
* interferes with the servlet's normal
* operation
*
* @see UnavailableException
* @see #GetServletConfig
*
*/
virtual void Init(const ServletConfig& config);

/**
*
* Called by the servlet container to indicate to a servlet that the
* servlet is being taken out of service. This method is
* only called once all threads within the servlet's
* <code>service</code> method have exited or after a timeout
* period has passed. After the servlet container calls this
* method, it will not call the <code>service</code> method again
* on this servlet.
*
* <p>This method gives the servlet an opportunity
* to clean up any resources that are being held (for example, memory,
* file handles, threads) and make sure that any persistent state is
* synchronized with the servlet's current state in memory.
*
*/

*
* Called by the servlet container to indicate to a servlet that the
* servlet is being taken out of service. This method is
* only called once all threads within the servlet's
* <code>service</code> method have exited or after a timeout
* period has passed. After the servlet container calls this
* method, it will not call the <code>service</code> method again
* on this servlet.
*
* <p>This method gives the servlet an opportunity
* to clean up any resources that are being held (for example, memory,
* file handles, threads) and make sure that any persistent state is
* synchronized with the servlet's current state in memory.
*
*/
virtual void Destroy();

/**
*
* Returns a {@link ServletConfig} object, which contains
* initialization and startup parameters for this servlet.
* The <code>ServletConfig</code> object returned is the one
* passed to the <code>init</code> method.
*
* @return the <code>ServletConfig</code> object
* that initializes this servlet
*
* @see #Init
*
*/
* Returns a {@link ServletConfig} object, which contains
* initialization and startup parameters for this servlet.
* The <code>ServletConfig</code> object returned is the one
* passed to the <code>init</code> method.
*
* @return the <code>ServletConfig</code> object
* that initializes this servlet
*
* @see #Init
*
*/
ServletConfig GetServletConfig() const;

virtual void Service(HttpServletRequest& request, HttpServletResponse& response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/HttpConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/HttpOutputStreamBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/HttpOutputStreamBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
14 changes: 5 additions & 9 deletions httpservice/src/HttpServlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,7 +64,7 @@ class NoBodyOutputStreamBuffer : public HttpOutputStreamBuffer
assert(std::less_equal<char*>()(pptr(), epptr()));
++m_ContentLength;
// discard the character
pbump(static_cast<int>(pbase() - pptr()));
pbump(static_cast<int>(pbase() - pptr()));
return ch;
}
return traits_type::eof();
Expand Down Expand Up @@ -138,12 +139,7 @@ static void MaybeSetLastModified(HttpServletResponse& resp,
resp.SetDateHeader(HEADER_LASTMOD, lastModified);
}


const std::string& HttpServlet::PROP_CONTEXT_ROOT()
{
static const std::string s = "org.cppmicroservices.HttpServlet.contextRoot";
return s;
}
const std::string HttpServlet::PROP_CONTEXT_ROOT = "org.cppmicroservices.HttpServlet.contextRoot";

HttpServlet::HttpServlet()
: d(new HttpServletPrivate)
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/HttpServletPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/HttpServletRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/HttpServletRequestPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/HttpServletResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/HttpServletResponsePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/ServletConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions httpservice/src/ServletConfigPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
11 changes: 6 additions & 5 deletions httpservice/src/ServletContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Library: CppMicroServices
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics
Copyright (c) The CppMicroServices developers. See the COPYRIGHT
file at the top-level directory of this distribution and at
https://github.com/CppMicroServices/CppMicroServices/COPYRIGHT .
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -79,8 +80,8 @@ class ServletHandler : public CivetHandler

std::string uri = mg_req_info->local_uri;
std::string pathPrefix = request.d->m_ContextPath + request.d->m_ServletPath;
std::cout << "Checking path prefix: " << pathPrefix << std::endl;
std::cout << "Against uri: " << uri << std::endl;
//std::cout << "Checking path prefix: " << pathPrefix << std::endl;
//std::cout << "Against uri: " << uri << std::endl;
assert(pathPrefix.size() <= uri.size());
assert(uri.compare(0, pathPrefix.size(), pathPrefix) == 0);
if(uri.size() > pathPrefix.size())
Expand Down Expand Up @@ -188,7 +189,7 @@ std::string ServletContainerPrivate::GetMimeType(const ServletContext* /*context

std::shared_ptr<ServletHandler> ServletContainerPrivate::AddingService(const ServiceReference<HttpServlet>& reference)
{
Any contextRoot = reference.GetProperty(HttpServlet::PROP_CONTEXT_ROOT());
Any contextRoot = reference.GetProperty(HttpServlet::PROP_CONTEXT_ROOT);
if (contextRoot.Empty())
{
std::cout << "HttpServlet from " << reference.GetBundle().GetSymbolicName() << " is missing the context root property." << std::endl;
Expand Down
Loading

0 comments on commit 084e032

Please sign in to comment.