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.

CommunicationManager.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright 2011 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 java.io.InputStream;
  18. import javax.servlet.ServletContext;
  19. import com.vaadin.ui.UI;
  20. /**
  21. * Application manager processes changes and paints for single application
  22. * instance.
  23. *
  24. * This class handles applications running as servlets.
  25. *
  26. * @see AbstractCommunicationManager
  27. *
  28. * @author Vaadin Ltd.
  29. * @since 5.0
  30. *
  31. * @deprecated might be refactored or removed before 7.0.0
  32. */
  33. @Deprecated
  34. @SuppressWarnings("serial")
  35. public class CommunicationManager extends AbstractCommunicationManager {
  36. /**
  37. * TODO New constructor - document me!
  38. *
  39. * @param session
  40. */
  41. public CommunicationManager(VaadinServiceSession session) {
  42. super(session);
  43. }
  44. @Override
  45. protected BootstrapHandler createBootstrapHandler() {
  46. return new BootstrapHandler() {
  47. @Override
  48. protected String getServiceUrl(BootstrapContext context) {
  49. String pathInfo = context.getRequest().getRequestPathInfo();
  50. if (pathInfo == null) {
  51. return null;
  52. } else {
  53. /*
  54. * Make a relative URL to the servlet by adding one ../ for
  55. * each path segment in pathInfo (i.e. the part of the
  56. * requested path that comes after the servlet mapping)
  57. */
  58. return VaadinServletService
  59. .getCancelingRelativePath(pathInfo);
  60. }
  61. }
  62. @Override
  63. public String getThemeName(BootstrapContext context) {
  64. String themeName = context.getRequest().getParameter(
  65. VaadinServlet.URL_PARAMETER_THEME);
  66. if (themeName == null) {
  67. themeName = super.getThemeName(context);
  68. }
  69. return themeName;
  70. }
  71. };
  72. }
  73. @Override
  74. protected InputStream getThemeResourceAsStream(UI uI, String themeName,
  75. String resource) {
  76. VaadinServletService service = (VaadinServletService) uI.getSession()
  77. .getService();
  78. ServletContext servletContext = service.getServlet()
  79. .getServletContext();
  80. return servletContext.getResourceAsStream("/"
  81. + VaadinServlet.THEME_DIRECTORY_PATH + themeName + "/"
  82. + resource);
  83. }
  84. }