You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2002/02/03 02:42:55 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp XSPRequestHelper.java
vgritsenko 02/02/02 17:42:55
Modified: src/java/org/apache/cocoon/components/language/markup/xsp
XSPRequestHelper.java
Log:
Move session code into XSPSessionHelper
Revision Changes Path
1.4 +1 -190 xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPRequestHelper.java
Index: XSPRequestHelper.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPRequestHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XSPRequestHelper.java 3 Feb 2002 01:15:16 -0000 1.3
+++ XSPRequestHelper.java 3 Feb 2002 01:42:55 -0000 1.4
@@ -26,7 +26,7 @@
* The <code>Request</code> object helper
*
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
- * @version CVS $Revision: 1.3 $ $Date: 2002/02/03 01:15:16 $
+ * @version CVS $Revision: 1.4 $ $Date: 2002/02/03 01:42:55 $
*/
public class XSPRequestHelper {
/**
@@ -486,194 +486,5 @@
uribuf.append(request.getRequestURI());
return uribuf.toString();
- }
-
- // =======================================================================
-
- /**
- * Sets the given session attribute value
- *
- * @param objectModel The Map objectModel
- * @param name The parameter name
- * @param content The parameter value
- */
- public static void setSessionAttribute(
- Map objectModel,
- String name,
- Object content
- )
- {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- Session session = request.getSession(false);
- session.setAttribute(name, content);
- }
-
- /**
- * Return the given session attribute value or a user-provided default if
- * none was specified.
- *
- * @param objectModel The Map objectModel
- * @param name The parameter name
- */
- public static Object getSessionAttribute(
- Map objectModel,
- String name) {
-
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- Session session = request.getSession(false);
- return session.getAttribute(name);
- }
-
- /**
- * Return the given session attribute value or a user-provided default if
- * none was specified.
- *
- * @param objectModel The Map objectModel
- * @param name The parameter name
- * @param defaultValue Value to substitute in absence of a parameter value
- */
- public static Object getSessionAttribute(
- Map objectModel,
- String name,
- Object defaultValue
- )
- {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- Session session = request.getSession(false);
- Object value = null;
-
- if (session != null) {
- value = session.getAttribute(name);
- }
-
- if (value == null) {
- value = defaultValue;
- }
-
- return value;
- }
-
- /**
- * Get the session attribute names.
- *
- * @param objectModel The Map objectModel
- */
- public static List getSessionAttributeNames (Map objectModel) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- ArrayList v = new ArrayList();
- Enumeration e = request.getSession().getAttributeNames();
-
- while (e.hasMoreElements()) {
- v.add(e.nextElement());
- }
- return v;
- }
-
- /**
- * Output the given session attribute value or a user-provided default if
- * none was specified.
- *
- * @param objectModel The Map objectModel
- * @param contentHandler The SAX content handler
- * @param name The parameter name
- * @param defaultValue Value to substitute in absence of a parameter value
- * @exception SAXException If a SAX error occurs
- */
- public static void getSessionAttribute(
- Map objectModel,
- ContentHandler contentHandler,
- String name,
- Object defaultValue)
- throws SAXException
- {
- AttributesImpl attr = new AttributesImpl();
- XSPObjectHelper.addAttribute(attr, "name", name);
-
- XSPObjectHelper.elementData(
- URI,
- PREFIX,
- contentHandler,
- "attribute",
- (String) getSessionAttribute(objectModel, name, defaultValue),
- attr
- );
- }
-
- /**
- * Get the session creation time
- *
- * @param objectModel The Map objectModel
- */
- public static long getSessionCreationTime (Map objectModel) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- return request.getSession().getCreationTime();
- }
-
- /**
- * Get the session id
- *
- * @param objectModel The Map objectModel
- */
- public static String getSessionId (Map objectModel) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- return request.getSession().getId();
- }
-
- /**
- * Get the session last accessed time
- *
- * @param objectModel The Map objectModel
- */
- public static long getSessionLastAccessedTime (Map objectModel) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- return request.getSession().getLastAccessedTime();
- }
-
- /**
- * Get the session max inactive interval
- *
- * @param objectModel The Map objectModel
- */
- public static long getSessionMaxInactiveInterval (Map objectModel) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- return request.getSession().getMaxInactiveInterval();
- }
-
- /**
- * Set the session max inactive interval
- * @param objectModel The Map objectModel
- * @param interval max inactive interval
- */
- public static void setSessionMaxInactiveInterval (Map objectModel, int interval) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- request.getSession().setMaxInactiveInterval(interval);
- }
-
- /**
- * Invalidate the session
- * @param objectModel The Map objectModel
- */
- public static void invalidateSession(Map objectModel) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- request.getSession().invalidate();
- }
-
- /**
- * Checks the isNew flag
- * @param objectModel The Map objectModel
- */
- public static boolean isSessionNew(Map objectModel) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- return request.getSession().isNew();
- }
-
- /**
- * Remove the specified attribute
- * @param objectModel The Map objectModel
- * @param name The parameter name
- */
- public static void removeSessionAttribute(Map objectModel, String name) {
- Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
- request.getSession().removeAttribute(name);
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org