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.

DependencyFilter.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2000-2016 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.Serializable;
  18. import java.util.List;
  19. import com.vaadin.annotations.HtmlImport;
  20. import com.vaadin.annotations.JavaScript;
  21. import com.vaadin.annotations.StyleSheet;
  22. import com.vaadin.ui.Dependency;
  23. /**
  24. * Filter for dependencies loaded using {@link StyleSheet @StyleSheet},
  25. * {@link JavaScript @JavaScript} and {@link HtmlImport @HtmlImport}.
  26. *
  27. * @since 8.1
  28. */
  29. public interface DependencyFilter extends Serializable {
  30. /**
  31. * Filters the list of dependencies and returns a (possibly) updated
  32. * version.
  33. * <p>
  34. * Called whenever dependencies are about to be sent to the client side for
  35. * loading.
  36. *
  37. * @param dependencies
  38. * the collected dependencies, possibly already modified by other
  39. * filters
  40. * @param filterContext
  41. * context information, e.g about the target UI
  42. * @return a list of dependencies to load
  43. */
  44. public List<Dependency> filter(List<Dependency> dependencies,
  45. FilterContext filterContext);
  46. /**
  47. * Provides context information for the dependency filter operation.
  48. *
  49. * @since 8.1
  50. */
  51. public static class FilterContext implements Serializable {
  52. private VaadinSession session;
  53. /**
  54. * Creates a new context for the given session.
  55. *
  56. * @param session
  57. * the session which is loading dependencies
  58. */
  59. public FilterContext(VaadinSession session) {
  60. this.session = session;
  61. }
  62. /**
  63. * Gets the related Vaadin session.
  64. *
  65. * @return the Vaadin session
  66. */
  67. public VaadinSession getSession() {
  68. return session;
  69. }
  70. /**
  71. * Gets the related Vaadin service.
  72. *
  73. * @return the Vaadin service
  74. */
  75. public VaadinService getService() {
  76. return session.getService();
  77. }
  78. }
  79. }