diff options
author | Artur Signell <artur@vaadin.com> | 2015-09-25 17:21:29 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-09-29 08:00:06 +0000 |
commit | d27652c54ec99c6500c05a984eaa8c168ae1a7af (patch) | |
tree | f8c7108efdda8671680f280eac30802d30b234b9 /server/src/com/vaadin | |
parent | 0fbf5b9307ad56825ad73301215cb8ffdef79aa1 (diff) | |
download | vaadin-framework-d27652c54ec99c6500c05a984eaa8c168ae1a7af.tar.gz vaadin-framework-d27652c54ec99c6500c05a984eaa8c168ae1a7af.zip |
Add scoped PortletSession methods (#19007)
Change-Id: I33afb351e68d2dc9543db9e00d11c2320ab04862
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r-- | server/src/com/vaadin/server/WrappedPortletSession.java | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/server/src/com/vaadin/server/WrappedPortletSession.java b/server/src/com/vaadin/server/WrappedPortletSession.java index 37991aab39..a8eff75983 100644 --- a/server/src/com/vaadin/server/WrappedPortletSession.java +++ b/server/src/com/vaadin/server/WrappedPortletSession.java @@ -51,12 +51,75 @@ public class WrappedPortletSession implements WrappedSession { return session.getAttribute(name); } + /** + * Returns the object bound with the specified name in this session, or + * <code>null</code> if no object is bound under the name in the given + * scope. + * + * @param name + * a string specifying the name of the object + * @param scope + * session scope of this attribute + * + * @return the object with the specified name + * + * @exception java.lang.IllegalStateException + * if this method is called on an invalidated session, or the + * scope is unknown to the container. + * @exception java.lang.IllegalArgumentException + * if name is <code>null</code>. + * + * @see PortletSession#getAttribute(String, int) + * @see PortletSession#PORTLET_SCOPE + * @see PortletSession#APPLICATION_SCOPE + * + * @since + */ + public Object getAttribute(String name, int scope) { + return session.getAttribute(name, scope); + } + @Override public void setAttribute(String name, Object value) { session.setAttribute(name, value); } /** + * Binds an object to this session in the given scope, using the name + * specified. If an object of the same name in this scope is already bound + * to the session, that object is replaced. + * + * <p> + * If the value is <code>null</code>, this has the same effect as calling + * <code>removeAttribute()</code>. + * + * + * @param name + * the name to which the object is bound; this cannot be + * <code>null</code>. + * @param value + * the object to be bound + * @param scope + * session scope of this attribute + * + * @exception java.lang.IllegalStateException + * if this method is called on a session which has been + * invalidated + * @exception java.lang.IllegalArgumentException + * if name is <code>null</code> or scope is unknown to the + * container. + * + * @see PortletSession#setAttribute(String, Object, int) + * @see PortletSession#PORTLET_SCOPE + * @see PortletSession#APPLICATION_SCOPE + * + * @since + */ + public void setAttribute(String name, Object value, int scope) { + session.setAttribute(name, value, scope); + } + + /** * Gets the wrapped {@link PortletSession}. * * @return the wrapped portlet session @@ -70,6 +133,24 @@ public class WrappedPortletSession implements WrappedSession { return WrappedHttpSession.enumerationToSet(session.getAttributeNames()); } + /** + * Gets the current set of attribute names bound to this session in the + * given scope. + * + * @param scope + * session scope of the attribute names + * @return an unmodifiable set of the current attribute names in the given + * scope + * + * @see PortletSession#getAttributeNames() + * + * @since + */ + public Set<String> getAttributeNames(int scope) { + return WrappedHttpSession.enumerationToSet(session + .getAttributeNames(scope)); + } + @Override public void invalidate() { session.invalidate(); @@ -100,6 +181,31 @@ public class WrappedPortletSession implements WrappedSession { session.removeAttribute(name); } + /** + * Removes the object bound with the specified name and the given scope from + * this session. If the session does not have an object bound with the + * specified name, this method does nothing. + * + * @param name + * the name of the object to be removed from this session + * @param scope + * session scope of this attribute + * + * @exception java.lang.IllegalStateException + * if this method is called on a session which has been + * invalidated + * @exception java.lang.IllegalArgumentException + * if name is <code>null</code>. + * @see PortletSession#removeAttribute(String, int) + * @see PortletSession#PORTLET_SCOPE + * @see PortletSession#APPLICATION_SCOPE + * + * @since + */ + public void removeAttribute(String name, int scope) { + session.removeAttribute(name, scope); + } + @Override public void setMaxInactiveInterval(int interval) { session.setMaxInactiveInterval(interval); |