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.

VaadinServletConfiguration.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright 2000-2018 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.annotations;
  17. import java.lang.annotation.Documented;
  18. import java.lang.annotation.ElementType;
  19. import java.lang.annotation.Inherited;
  20. import java.lang.annotation.Retention;
  21. import java.lang.annotation.RetentionPolicy;
  22. import java.lang.annotation.Target;
  23. import com.vaadin.server.Constants;
  24. import com.vaadin.server.DefaultDeploymentConfiguration;
  25. import com.vaadin.server.DeploymentConfiguration;
  26. import com.vaadin.server.VaadinServlet;
  27. import com.vaadin.server.VaadinSession;
  28. import com.vaadin.ui.UI;
  29. /**
  30. * Annotation for configuring subclasses of {@link VaadinServlet}. For a
  31. * {@link VaadinServlet} class that has this annotation, the defined values are
  32. * read during initialization and will be available using
  33. * {@link DeploymentConfiguration#getApplicationOrSystemProperty(String, String)}
  34. * as well as from specific methods in {@link DeploymentConfiguration}. Init
  35. * params defined in <code>web.xml</code> or the <code>@WebServlet</code>
  36. * annotation take precedence over values defined in this annotation.
  37. *
  38. * @since 7.1
  39. * @author Vaadin Ltd
  40. */
  41. @Retention(RetentionPolicy.RUNTIME)
  42. @Target(ElementType.TYPE)
  43. @Inherited
  44. public @interface VaadinServletConfiguration {
  45. /**
  46. * Defines the init parameter name for methods in
  47. * {@link VaadinServletConfiguration}.
  48. *
  49. * @since 7.1
  50. * @author Vaadin Ltd
  51. */
  52. @Retention(RetentionPolicy.RUNTIME)
  53. @Target(ElementType.METHOD)
  54. @Documented
  55. public @interface InitParameterName {
  56. /**
  57. * The name of the init parameter that the annotated method controls.
  58. *
  59. * @return the parameter name
  60. */
  61. public String value();
  62. }
  63. /**
  64. * Whether Vaadin is in production mode.
  65. *
  66. * @return true if in production mode, false otherwise.
  67. *
  68. * @see DeploymentConfiguration#isProductionMode()
  69. */
  70. @InitParameterName(Constants.SERVLET_PARAMETER_PRODUCTION_MODE)
  71. public boolean productionMode();
  72. /**
  73. * Gets the default UI class to use for the servlet.
  74. *
  75. * @return the default UI class
  76. */
  77. @InitParameterName(VaadinSession.UI_PARAMETER)
  78. public Class<? extends UI> ui();
  79. /**
  80. * The time resources can be cached in the browser, in seconds. The default
  81. * value is 3600 seconds, i.e. one hour.
  82. *
  83. * @return the resource cache time
  84. *
  85. * @see DeploymentConfiguration#getResourceCacheTime()
  86. */
  87. @InitParameterName(Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME)
  88. public int resourceCacheTime() default DefaultDeploymentConfiguration.DEFAULT_RESOURCE_CACHE_TIME;
  89. /**
  90. * The number of seconds between heartbeat requests of a UI, or a
  91. * non-positive number if heartbeat is disabled. The default value is 300
  92. * seconds, i.e. 5 minutes.
  93. *
  94. * @return the time between heartbeats
  95. *
  96. * @see DeploymentConfiguration#getHeartbeatInterval()
  97. */
  98. @InitParameterName(Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL)
  99. public int heartbeatInterval() default DefaultDeploymentConfiguration.DEFAULT_HEARTBEAT_INTERVAL;
  100. /**
  101. * Whether a session should be closed when all its open UIs have been idle
  102. * for longer than its configured maximum inactivity time. The default value
  103. * is <code>false</code>.
  104. *
  105. * @return true if UIs and sessions receiving only heartbeat requests are
  106. * eventually closed; false if heartbeat requests extend UI and
  107. * session lifetime indefinitely
  108. *
  109. * @see DeploymentConfiguration#isCloseIdleSessions()
  110. */
  111. @InitParameterName(Constants.SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS)
  112. public boolean closeIdleSessions() default DefaultDeploymentConfiguration.DEFAULT_CLOSE_IDLE_SESSIONS;
  113. /**
  114. * The default widgetset to use for the servlet. The default value is
  115. * <code>""</code>, which will cause
  116. * <code>com.vaadin.DefaultWidgetSet</code> to be used unless overridden by
  117. * an init parameter or unless an automatically generated
  118. * <code>AppWidgetset</code> is used.
  119. *
  120. * @return the default widgetset name
  121. */
  122. @InitParameterName(VaadinServlet.PARAMETER_WIDGETSET)
  123. public String widgetset() default "";
  124. }