Class PortletSessionWrapper
- java.lang.Object
-
- jakarta.portlet.filter.PortletSessionWrapper
-
- All Implemented Interfaces:
PortletSession
public class PortletSessionWrapper extends Object implements PortletSession
ThePortletSessionWrapperprovides a convenient implementation of thePortletSessioninterface that can be subclassed by developers. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request object.- Since:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description protected PortletSessionwrapped-
Fields inherited from interface jakarta.portlet.PortletSession
APPLICATION_SCOPE, PORTLET_SCOPE
-
-
Constructor Summary
Constructors Constructor Description PortletSessionWrapper(PortletSession wrapped)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetAttribute(String name)Returns the object bound with the specified name in this session under thePORTLET_SCOPE, ornullif no object is bound under the name in that scope.ObjectgetAttribute(String name, int scope)Returns the object bound with the specified name in this session, ornullif no object is bound under the name in the given scope.Map<String,Object>getAttributeMap()Returns aMapof the session attributes in the portlet session scope.Map<String,Object>getAttributeMap(int scope)Returns aMapof the session attributes in the given session scope.Enumeration<String>getAttributeNames()Returns anEnumerationof String objects containing the names of all the objects bound to this session under thePORTLET_SCOPE, or an emptyEnumerationif no attributes are available.Enumeration<String>getAttributeNames(int scope)Returns anEnumerationof String objects containing the names of all the objects bound to this session in the given scope, or an emptyEnumerationif no attributes are available in the given scope.longgetCreationTime()Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.StringgetId()Returns a string containing the unique identifier assigned to this session.longgetLastAccessedTime()Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT.intgetMaxInactiveInterval()Returns the maximum time interval, in seconds, for which the portlet container keeps this session open between client accesses.PortletContextgetPortletContext()Returns the portlet application context associated with this session.PortletSessiongetWrapped()Gets the wrapped object.voidinvalidate()Invalidates this session (all scopes) and unbinds any objects bound to it.booleanisNew()Returns true if the client does not yet know about the session or if the client chooses not to join the session.voidremoveAttribute(String name)Removes the object bound with the specified name under thePORTLET_SCOPEfrom this session.voidremoveAttribute(String name, int scope)Removes the object bound with the specified name and the given scope from this session.voidsetAttribute(String name, Object value)Binds an object to this session under thePORTLET_SCOPE, using the name specified.voidsetAttribute(String name, Object value, int scope)Binds an object to this session in the given scope, using the name specified.voidsetMaxInactiveInterval(int interval)Specifies the time, in seconds, between client requests, before the portlet container invalidates this session.voidsetWrapped(PortletSession wrapped)Sets the wrapped object.
-
-
-
Field Detail
-
wrapped
protected PortletSession wrapped
-
-
Constructor Detail
-
PortletSessionWrapper
public PortletSessionWrapper(PortletSession wrapped)
- Parameters:
wrapped- the wrapped object to set.- Throws:
IllegalArgumentException- if the PortletSession is null.
-
-
Method Detail
-
getWrapped
public PortletSession getWrapped()
Gets the wrapped object.- Returns:
- the wrapped object.
-
setWrapped
public void setWrapped(PortletSession wrapped)
Sets the wrapped object.- Parameters:
wrapped- the wrapped object to set.- Throws:
IllegalArgumentException- if the PortletSession is null.
-
getAttribute
public Object getAttribute(String name)
Description copied from interface:PortletSessionReturns the object bound with the specified name in this session under thePORTLET_SCOPE, ornullif no object is bound under the name in that scope.- Specified by:
getAttributein interfacePortletSession- Parameters:
name- a string specifying the name of the object- Returns:
- the object with the specified name for
the
PORTLET_SCOPE.
-
getAttribute
public Object getAttribute(String name, int scope)
Description copied from interface:PortletSessionReturns the object bound with the specified name in this session, ornullif no object is bound under the name in the given scope.- Specified by:
getAttributein interfacePortletSession- Parameters:
name- a string specifying the name of the objectscope- session scope of this attribute- Returns:
- the object with the specified name
-
getAttributeNames
public Enumeration<String> getAttributeNames()
Description copied from interface:PortletSessionReturns anEnumerationof String objects containing the names of all the objects bound to this session under thePORTLET_SCOPE, or an emptyEnumerationif no attributes are available.- Specified by:
getAttributeNamesin interfacePortletSession- Returns:
- an
EnumerationofStringobjects specifying the names of all the objects bound to this session, or an emptyEnumerationif no attributes are available.
-
getAttributeNames
public Enumeration<String> getAttributeNames(int scope)
Description copied from interface:PortletSessionReturns anEnumerationof String objects containing the names of all the objects bound to this session in the given scope, or an emptyEnumerationif no attributes are available in the given scope.- Specified by:
getAttributeNamesin interfacePortletSession- Parameters:
scope- session scope of the attribute names- Returns:
- an
EnumerationofStringobjects specifying the names of all the objects bound to this session, or an emptyEnumerationif no attributes are available in the given scope.
-
getCreationTime
public long getCreationTime()
Description copied from interface:PortletSessionReturns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.- Specified by:
getCreationTimein interfacePortletSession- Returns:
- a
longspecifying when this session was created, expressed in milliseconds since 1/1/1970 GMT
-
getId
public String getId()
Description copied from interface:PortletSessionReturns a string containing the unique identifier assigned to this session.- Specified by:
getIdin interfacePortletSession- Returns:
- a string specifying the identifier assigned to this session
-
getLastAccessedTime
public long getLastAccessedTime()
Description copied from interface:PortletSessionReturns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT.Actions that your portlet takes, such as getting or setting a value associated with the session, do not affect the access time.
- Specified by:
getLastAccessedTimein interfacePortletSession- Returns:
- a
longrepresenting the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT
-
getMaxInactiveInterval
public int getMaxInactiveInterval()
Description copied from interface:PortletSessionReturns the maximum time interval, in seconds, for which the portlet container keeps this session open between client accesses. After this interval, the portlet container invalidates the session. The maximum time interval can be set with thesetMaxInactiveIntervalmethod. A negative time indicates the session should never timeout.- Specified by:
getMaxInactiveIntervalin interfacePortletSession- Returns:
- an integer specifying the number of seconds this session remains open between client requests
- See Also:
PortletSession.setMaxInactiveInterval(int)
-
invalidate
public void invalidate()
Description copied from interface:PortletSessionInvalidates this session (all scopes) and unbinds any objects bound to it.Invalidating the portlet session will result in invalidating the underlying
HttpSession- Specified by:
invalidatein interfacePortletSession
-
isNew
public boolean isNew()
Description copied from interface:PortletSessionReturns true if the client does not yet know about the session or if the client chooses not to join the session.- Specified by:
isNewin interfacePortletSession- Returns:
trueif the server has created a session, but the client has not joined yet.
-
removeAttribute
public void removeAttribute(String name)
Description copied from interface:PortletSessionRemoves the object bound with the specified name under thePORTLET_SCOPEfrom this session. If the session does not have an object bound with the specified name, this method does nothing.- Specified by:
removeAttributein interfacePortletSession- Parameters:
name- the name of the object to be removed from this session in thePORTLET_SCOPE.
-
removeAttribute
public void removeAttribute(String name, int scope)
Description copied from interface:PortletSessionRemoves 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.- Specified by:
removeAttributein interfacePortletSession- Parameters:
name- the name of the object to be removed from this sessionscope- session scope of this attribute
-
setAttribute
public void setAttribute(String name, Object value)
Description copied from interface:PortletSessionBinds an object to this session under thePORTLET_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.After this method has been executed, and if the new object implements
HttpSessionBindingListener, the container callsHttpSessionBindingListener.valueBound. The container then notifies anyHttpSessionAttributeListenersin the web application.If an object was already bound to this session that implements
HttpSessionBindingListener, itsHttpSessionBindingListener.valueUnboundmethod is called.If the value is
null, this has the same effect as callingremoveAttribute().- Specified by:
setAttributein interfacePortletSession- Parameters:
name- the name to which the object is bound under thePORTLET_SCOPE; this cannot benull.value- the object to be bound
-
setAttribute
public void setAttribute(String name, Object value, int scope)
Description copied from interface:PortletSessionBinds 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.After this method has been executed, and if the new object implements
HttpSessionBindingListener, the container callsHttpSessionBindingListener.valueBound. The container then notifies anyHttpSessionAttributeListenersin the web application.If an object was already bound to this session that implements
HttpSessionBindingListener, itsHttpSessionBindingListener.valueUnboundmethod is called.If the value is
null, this has the same effect as callingremoveAttribute().- Specified by:
setAttributein interfacePortletSession- Parameters:
name- the name to which the object is bound; this cannot benull.value- the object to be boundscope- session scope of this attribute
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int interval)
Description copied from interface:PortletSessionSpecifies the time, in seconds, between client requests, before the portlet container invalidates this session. A negative time indicates the session should never timeout.- Specified by:
setMaxInactiveIntervalin interfacePortletSession- Parameters:
interval- An integer specifying the number of seconds
-
getPortletContext
public PortletContext getPortletContext()
Description copied from interface:PortletSessionReturns the portlet application context associated with this session.- Specified by:
getPortletContextin interfacePortletSession- Returns:
- the portlet application context
-
getAttributeMap
public Map<String,Object> getAttributeMap()
Description copied from interface:PortletSessionReturns aMapof the session attributes in the portlet session scope.The keys are of type
Stringand the values in the returnedMapare from typeObject.If no session attributes exist this method returns an empty
Map.- Specified by:
getAttributeMapin interfacePortletSession- Returns:
- an immutable
Mapcontaining the session attributes in the portlet session scope as keys and attribute values as map values, or an emptyMapif no session attributes exist. The keys in the map are of type String, the values of type Object.
-
getAttributeMap
public Map<String,Object> getAttributeMap(int scope)
Description copied from interface:PortletSessionReturns aMapof the session attributes in the given session scope.The keys are of type
Stringand the values in the returnedMapare from typeObject.If no session attributes exist this method returns an empty
Map.- Specified by:
getAttributeMapin interfacePortletSession- Parameters:
scope- session scope of this attribute- Returns:
- an immutable
Mapcontaining the session attributes in the given scope as keys and attribute values as map values, or an emptyMapif no session attributes exist. The keys in the map are of type String, the values of type Object.
-
-