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.7KB

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. /**
  11. * Annotation defining the server side connector that this ClientSideConnector
  12. * should connect to. The value must always by a class extending
  13. * {@link com.vaadin.terminal.gwt.server.ClientConnector}.
  14. * <p>
  15. * With this annotation client side Vaadin connector is marked to have a server
  16. * side counterpart. The value of the annotation is the class of server side
  17. * implementation.
  18. *
  19. * @since 7.0
  20. */
  21. @Retention(RetentionPolicy.RUNTIME)
  22. @Target(ElementType.TYPE)
  23. public @interface Connect {
  24. /**
  25. * @return the server side counterpart for the annotated component connector
  26. */
  27. Class<? extends Connector> value();
  28. /**
  29. * Depending on the used WidgetMap generator, these optional hints may be
  30. * used to define how the client side components are loaded by the browser.
  31. * The default is to eagerly load all widgets
  32. * {@link com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator},
  33. * but if the
  34. * {@link com.vaadin.terminal.gwt.widgetsetutils.WidgetMapGenerator} is used
  35. * by the widgetset, these load style hints are respected.
  36. * <p>
  37. * Lazy loading of a widget implementation means the client side component
  38. * is not included in the initial JavaScript application loaded when the
  39. * application starts. Instead the implementation is loaded to the client
  40. * when it is first needed. Lazy loaded widget can be achieved by giving
  41. * {@link LoadStyle#LAZY} value in {@link Connect} annotation.
  42. * <p>
  43. * Lazy loaded widgets don't stress the size and startup time of the client
  44. * side as much as eagerly loaded widgets. On the other hand there is a
  45. * slight latency when lazy loaded widgets are first used as the client side
  46. * needs to visit the server to fetch the client side implementation.
  47. * <p>
  48. * The {@link LoadStyle#DEFERRED} will also not stress the initially loaded
  49. * JavaScript file. If this load style is defined, the widget implementation
  50. * is preemptively loaded to the browser after the application is started
  51. * and the communication to server idles. This load style kind of combines
  52. * the best of both worlds.
  53. * <p>
  54. * Fine tunings to widget loading can also be made by overriding
  55. * {@link com.vaadin.terminal.gwt.widgetsetutils.WidgetMapGenerator} in the
  56. * GWT module. Tunings might be helpful if the end users have slow
  57. * connections and especially if they have high latency in their network.
  58. * The
  59. * {@link com.vaadin.terminal.gwt.widgetsetutils.CustomWidgetMapGenerator}
  60. * is an abstract generator implementation for easy customization. Vaadin
  61. * package also includes
  62. * {@link com.vaadin.terminal.gwt.widgetsetutils.LazyWidgetMapGenerator}
  63. * that makes as many widgets 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. }