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.

Connect.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.shared.ui;
  5. import java.lang.annotation.ElementType;
  6. import java.lang.annotation.Retention;
  7. import java.lang.annotation.RetentionPolicy;
  8. import java.lang.annotation.Target;
  9. import com.vaadin.shared.Connector;
  10. import com.vaadin.terminal.gwt.server.ClientConnector;
  11. import com.vaadin.terminal.gwt.widgetsetutils.CustomWidgetMapGenerator;
  12. import com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator;
  13. import com.vaadin.terminal.gwt.widgetsetutils.LazyWidgetMapGenerator;
  14. import com.vaadin.terminal.gwt.widgetsetutils.WidgetMapGenerator;
  15. /**
  16. * Annotation defining the server side connector that this ClientSideConnector
  17. * should connect to. The value must always by a class extending
  18. * {@link ClientConnector}.
  19. * <p>
  20. * With this annotation client side Vaadin connector is marked to have a server
  21. * side counterpart. The value of the annotation is the class of server side
  22. * implementation.
  23. *
  24. * @since 7.0
  25. */
  26. @Retention(RetentionPolicy.RUNTIME)
  27. @Target(ElementType.TYPE)
  28. public @interface Connect {
  29. /**
  30. * @return the server side counterpart for the annotated component connector
  31. */
  32. Class<? extends Connector> value();
  33. /**
  34. * Depending on the used WidgetMap generator, these optional hints may be
  35. * used to define how the client side components are loaded by the browser.
  36. * The default is to eagerly load all widgets
  37. * {@link EagerWidgetMapGenerator}, but if the {@link WidgetMapGenerator} is
  38. * used by the widgetset, these load style hints are respected.
  39. * <p>
  40. * Lazy loading of a widget implementation means the client side component
  41. * is not included in the initial JavaScript application loaded when the
  42. * application starts. Instead the implementation is loaded to the client
  43. * when it is first needed. Lazy loaded widget can be achieved by giving
  44. * {@link LoadStyle#LAZY} value in {@link Connect} annotation.
  45. * <p>
  46. * Lazy loaded widgets don't stress the size and startup time of the client
  47. * side as much as eagerly loaded widgets. On the other hand there is a
  48. * slight latency when lazy loaded widgets are first used as the client side
  49. * needs to visit the server to fetch the client side implementation.
  50. * <p>
  51. * The {@link LoadStyle#DEFERRED} will also not stress the initially loaded
  52. * JavaScript file. If this load style is defined, the widget implementation
  53. * is preemptively loaded to the browser after the application is started
  54. * and the communication to server idles. This load style kind of combines
  55. * the best of both worlds.
  56. * <p>
  57. * Fine tunings to widget loading can also be made by overriding
  58. * {@link WidgetMapGenerator} in the GWT module. Tunings might be helpful if
  59. * the end users have slow connections and especially if they have high
  60. * latency in their network. The {@link CustomWidgetMapGenerator} is an
  61. * abstract generator implementation for easy customization. Vaadin package
  62. * also includes {@link LazyWidgetMapGenerator} that makes as many widgets
  63. * lazily loaded as possible.
  64. *
  65. * @since 6.4
  66. *
  67. * @return the hint for the widget set generator how the client side
  68. * implementation should be loaded to the browser
  69. */
  70. LoadStyle loadStyle() default LoadStyle.DEFERRED;
  71. public enum LoadStyle {
  72. /**
  73. * The widget is included in the initial JS sent to the client.
  74. */
  75. EAGER,
  76. /**
  77. * Not included in the initial set of widgets, but added to queue from
  78. * which it will be loaded when network is not busy or the
  79. * implementation is required.
  80. */
  81. DEFERRED,
  82. /**
  83. * Loaded to the client only if needed.
  84. */
  85. LAZY
  86. }
  87. }