You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VaadinServletRequest.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server;
  17. import javax.servlet.http.HttpServletRequest;
  18. import javax.servlet.http.HttpServletRequestWrapper;
  19. import javax.servlet.http.HttpSession;
  20. /**
  21. * Wrapper for {@link HttpServletRequest}.
  22. *
  23. * @author Vaadin Ltd.
  24. * @since 7.0
  25. *
  26. * @see VaadinRequest
  27. * @see VaadinServletResponse
  28. */
  29. public class VaadinServletRequest extends HttpServletRequestWrapper implements
  30. VaadinRequest {
  31. private final VaadinServletService vaadinService;
  32. /**
  33. * Wraps a http servlet request and associates with a vaadin service
  34. *
  35. * @param request
  36. * the http servlet request to wrap
  37. * @param vaadinService
  38. * the associated vaadin service
  39. */
  40. public VaadinServletRequest(HttpServletRequest request,
  41. VaadinServletService vaadinService) {
  42. super(request);
  43. this.vaadinService = vaadinService;
  44. }
  45. @Override
  46. public WrappedSession getWrappedSession() {
  47. return getWrappedSession(true);
  48. }
  49. @Override
  50. public WrappedSession getWrappedSession(boolean allowSessionCreation) {
  51. HttpSession session = getSession(allowSessionCreation);
  52. if (session != null) {
  53. return new WrappedHttpSession(session);
  54. } else {
  55. return null;
  56. }
  57. }
  58. /**
  59. * Gets the original, unwrapped HTTP servlet request.
  60. *
  61. * @return the servlet request
  62. */
  63. public HttpServletRequest getHttpServletRequest() {
  64. return this;
  65. }
  66. @Override
  67. public VaadinServletService getService() {
  68. return vaadinService;
  69. }
  70. }