Portlet API 2

org.apache.jetspeed.portlet
Interface PortletSession


public interface PortletSession

The PortletSession holds the user-specific data that the portlet needs to personalize the one global portlet instance. Together with the portlet, the portlet session constitutes the virtual instance of the portlet.

See Also:
Portlet

Method Summary
 Object getAttribute(String name)
          Returns the value of the attribute with the given name, or null if no attribute with the given name exists.
 Enumeration getAttributeNames()
          Returns an enumeration of names of all attributes available to this session.
 long getCreationTime()
          Returns the point of time that this session was created.
 long getLastAccessedTime()
          Returns the point of time that this session was last accessed.
 User getUser()
          Returns the user object.
 void removeAttribute(String name)
          Removes the attribute with the given name.
 void setAttribute(String name, Object value)
          Associates an attribute with the given name and value with this session.
 

Method Detail

getUser

public User getUser()
Returns the user object. The user object contains useful information about the user and his or her preferences.
Returns:
the user profile

getCreationTime

public long getCreationTime()
Returns the point of time that this session was created. Essentially, this will also be the time when the user logged in. The time is returned as the number of milliseconds since January 1, 1970 GMT.
Returns:
the time of creation

getLastAccessedTime

public long getLastAccessedTime()
Returns the point of time that this session was last accessed. The time is returned as the number of milliseconds since January 1, 1970 GMT.
Returns:
the time of the last access

setAttribute

public void setAttribute(String name,
                         Object value)
Associates an attribute with the given name and value with this session. If a portlet needs to communicate information to embedded servlets or JSP, this methods can used carry the information along.

The portlet provider should take care that the the namespace of attribute names is not unnecessarily polluted. It is recommended to prefix all attributes the package and class name of the portlet that makes use of this method. The prefixing should probably be done by the portlet container.

Parameters:
name - the attribute name
value - the attribute value

getAttribute

public Object getAttribute(String name)
Returns the value of the attribute with the given name, or null if no attribute with the given name exists.
Parameters:
name - the attribute name
Returns:
the attribute value

getAttributeNames

public Enumeration getAttributeNames()
Returns an enumeration of names of all attributes available to this session. This method returns an empty enumeration if the session has no attributes available to it.
Returns:
an enumeration of attribute names

removeAttribute

public void removeAttribute(String name)
Removes the attribute with the given name.
Parameters:
name - the name of attribute to be removed

Portlet API 2