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.

WrappedSession.java 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright 2000-2016 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.server;
  17. import java.io.Serializable;
  18. import java.util.Set;
  19. import javax.portlet.PortletSession;
  20. import javax.servlet.http.HttpSession;
  21. /**
  22. * A generic session, wrapping a more specific session implementation, e.g.
  23. * {@link HttpSession} or {@link PortletSession}.
  24. *
  25. *
  26. * @author Vaadin Ltd
  27. * @since 7.0.0
  28. */
  29. public interface WrappedSession extends Serializable {
  30. /**
  31. * Returns the maximum time interval, in seconds, that this session will be
  32. * kept open between client accesses.
  33. *
  34. * @return an integer specifying the number of seconds this session remains
  35. * open between client requests
  36. *
  37. * @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
  38. * @see javax.portlet.PortletSession#getMaxInactiveInterval()
  39. */
  40. public int getMaxInactiveInterval();
  41. /**
  42. * Gets an attribute from this session.
  43. *
  44. * @param name
  45. * the name of the attribute
  46. * @return the attribute value, or <code>null</code> if the attribute is not
  47. * defined in the session
  48. *
  49. * @see javax.servlet.http.HttpSession#getAttribute(String)
  50. * @see javax.portlet.PortletSession#getAttribute(String)
  51. */
  52. public Object getAttribute(String name);
  53. /**
  54. * Saves an attribute value in this session.
  55. *
  56. * @param name
  57. * the name of the attribute
  58. * @param value
  59. * the attribute value
  60. *
  61. * @see javax.servlet.http.HttpSession#setAttribute(String, Object)
  62. * @see javax.portlet.PortletSession#setAttribute(String, Object)
  63. */
  64. public void setAttribute(String name, Object value);
  65. /**
  66. * Gets the current set of attribute names stored in this session.
  67. *
  68. * @return an unmodifiable set of the current attribute names
  69. *
  70. * @see HttpSession#getAttributeNames()
  71. * @see PortletSession#getAttributeNames()
  72. */
  73. public Set<String> getAttributeNames();
  74. /**
  75. * Invalidates this session then unbinds any objects bound to it.
  76. *
  77. * @see HttpSession#invalidate()
  78. * @see PortletSession#invalidate()
  79. */
  80. public void invalidate();
  81. /**
  82. * Gets a string with a unique identifier for the session.
  83. *
  84. * @return a unique session id string
  85. *
  86. * @see HttpSession#getId()
  87. * @see PortletSession#getId()
  88. */
  89. public String getId();
  90. /**
  91. * Returns the time when this session was created, measured in milliseconds
  92. * since midnight January 1, 1970 GMT.
  93. *
  94. * @return a long specifying when this session was created, expressed in
  95. * milliseconds since 1/1/1970 GMT
  96. *
  97. * @throws IllegalStateException
  98. * if this method is called on an invalidated session
  99. * @see HttpSession#getCreationTime()
  100. * @see PortletSession#getCreationTime()
  101. */
  102. public long getCreationTime();
  103. /**
  104. * Returns the last time the client sent a request associated with this
  105. * session, as the number of milliseconds since midnight January 1, 1970
  106. * GMT, and marked by the time the container received the request.
  107. * <p>
  108. * Actions that your application takes, such as getting or setting a value
  109. * associated with the session, do not affect the access time.
  110. *
  111. * @return a long representing the last time the client sent a request
  112. * associated with this session, expressed in milliseconds since
  113. * 1/1/1970 GMT
  114. *
  115. * @throws IllegalStateException
  116. * if this method is called on an invalidated session
  117. *
  118. * @see HttpSession#getLastAccessedTime()
  119. * @see PortletSession#getLastAccessedTime()
  120. */
  121. public long getLastAccessedTime();
  122. /**
  123. * Returns true if the client does not yet know about the session or if the
  124. * client chooses not to join the session. For example, if the server used
  125. * only cookie-based sessions, and the client had disabled the use of
  126. * cookies, then a session would be new on each request.
  127. *
  128. * @return true if the server has created a session, but the client has not
  129. * yet joined
  130. * @throws IllegalStateException
  131. * if this method is called on an invalidated session
  132. * @see HttpSession#isNew()
  133. * @see PortletSession#isNew()
  134. */
  135. public boolean isNew();
  136. /**
  137. * Removes the object bound with the specified name from this session. If
  138. * the session does not have an object bound with the specified name, this
  139. * method does nothing.
  140. *
  141. * @param name
  142. * the name of the object to remove from this session
  143. * @throws IllegalStateException
  144. * if this method is called on an invalidated session
  145. * @see HttpSession#removeAttribute(String)
  146. * @see PortletSession#removeAttribute(String)
  147. */
  148. public void removeAttribute(String name);
  149. /**
  150. * Specifies the time, in seconds, between client requests before the
  151. * servlet container will invalidate this session. A negative time indicates
  152. * the session should never timeout.
  153. *
  154. * @param interval
  155. * An integer specifying the number of seconds
  156. * @see HttpSession#setMaxInactiveInterval(int)
  157. * @see PortletSession#setMaxInactiveInterval(int)
  158. */
  159. public void setMaxInactiveInterval(int interval);
  160. }