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

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