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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright 2000-2014 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.Retention;
  20. import java.lang.annotation.RetentionPolicy;
  21. import java.lang.annotation.Target;
  22. import com.vaadin.server.Constants;
  23. import com.vaadin.server.DefaultDeploymentConfiguration;
  24. import com.vaadin.server.DeploymentConfiguration;
  25. import com.vaadin.server.DeploymentConfiguration.LegacyProperyToStringMode;
  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. public @interface VaadinServletConfiguration {
  44. /**
  45. * Defines the init parameter name for methods in
  46. * {@link VaadinServletConfiguration}.
  47. *
  48. * @since 7.1
  49. * @author Vaadin Ltd
  50. */
  51. @Retention(RetentionPolicy.RUNTIME)
  52. @Target(ElementType.METHOD)
  53. @Documented
  54. public @interface InitParameterName {
  55. /**
  56. * The name of the init parameter that the annotated method controls.
  57. *
  58. * @return the parameter name
  59. */
  60. public String value();
  61. }
  62. /**
  63. * Whether Vaadin is in production mode.
  64. *
  65. * @return true if in production mode, false otherwise.
  66. *
  67. * @see DeploymentConfiguration#isProductionMode()
  68. */
  69. @InitParameterName(Constants.SERVLET_PARAMETER_PRODUCTION_MODE)
  70. public boolean productionMode();
  71. /**
  72. * Gets the default UI class to use for the servlet.
  73. *
  74. * @return the default UI class
  75. */
  76. @InitParameterName(VaadinSession.UI_PARAMETER)
  77. public Class<? extends UI> ui();
  78. /**
  79. * The time resources can be cached in the browser, in seconds. The default
  80. * value is 3600 seconds, i.e. one hour.
  81. *
  82. * @return the resource cache time
  83. *
  84. * @see DeploymentConfiguration#getResourceCacheTime()
  85. */
  86. @InitParameterName(Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME)
  87. public int resourceCacheTime() default DefaultDeploymentConfiguration.DEFAULT_RESOURCE_CACHE_TIME;
  88. /**
  89. * The number of seconds between heartbeat requests of a UI, or a
  90. * non-positive number if heartbeat is disabled. The default value is 300
  91. * seconds, i.e. 5 minutes.
  92. *
  93. * @return the time between heartbeats
  94. *
  95. * @see DeploymentConfiguration#getHeartbeatInterval()
  96. */
  97. @InitParameterName(Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL)
  98. public int heartbeatInterval() default DefaultDeploymentConfiguration.DEFAULT_HEARTBEAT_INTERVAL;
  99. /**
  100. * Whether a session should be closed when all its open UIs have been idle
  101. * for longer than its configured maximum inactivity time. The default value
  102. * is <code>false</code>.
  103. *
  104. * @return true if UIs and sessions receiving only heartbeat requests are
  105. * eventually closed; false if heartbeat requests extend UI and
  106. * session lifetime indefinitely
  107. *
  108. * @see DeploymentConfiguration#isCloseIdleSessions()
  109. */
  110. @InitParameterName(Constants.SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS)
  111. public boolean closeIdleSessions() default DefaultDeploymentConfiguration.DEFAULT_CLOSE_IDLE_SESSIONS;
  112. /**
  113. * The default widgetset to use for the servlet. The default value is
  114. * <code>com.vaadin.DefaultWidgetSet</code>.
  115. *
  116. * @return the default widgetset name
  117. */
  118. @InitParameterName(VaadinServlet.PARAMETER_WIDGETSET)
  119. public String widgetset() default VaadinServlet.DEFAULT_WIDGETSET;
  120. /**
  121. * The legacy Property.toString() mode used. The default value is
  122. * {@link LegacyProperyToStringMode#DISABLED}
  123. *
  124. * @return The Property.toString() mode in use.
  125. *
  126. * @deprecated as of 7.1, should only be used to ease migration
  127. */
  128. @Deprecated
  129. @InitParameterName(Constants.SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING)
  130. public LegacyProperyToStringMode legacyPropertyToStringMode() default LegacyProperyToStringMode.DISABLED;
  131. }