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

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