//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE----------------------------
package org.huihoo.willow.session;

import org.huihoo.willow.Manager;
import org.huihoo.workflow.WorkflowSerializable;
import org.huihoo.workflow.server.WorkflowSession;


public abstract class AbstractSession implements WorkflowSession,WorkflowSerializable
{

	// ------------------------------------------------------------- Properties

	/**
	 * Set the creation time for this session.  This method is called by the
	 * Manager when an existing Session instance is reused.
	 *
	 * @param time The new creation time
	 */
	public abstract void setCreationTime(long time);

	/**
	 * Set the session identifier for this session.
	 *
	 * @param id The new session identifier
	 */
	public abstract void setId(String id);

	/**
	 * Return descriptive information about this Session implementation and
	 * the corresponding version number, in the format
	 * <code>&lt;description&gt;/&lt;version&gt;</code>.
	 */
	public abstract String getInfo();


	/**
	 * Return the Manager within which this Session is valid.
	 */
	public abstract Manager getManager();

	/**
	 * Set the Manager within which this Session is valid.
	 *
	 * @param manager The new Manager
	 */
	public abstract void setManager(Manager manager);

	/**
	 * Return the maximum time interval, in seconds, between client requests
	 * before the servlet container will invalidate the session.  A negative
	 * time indicates that the session should never time out.
	 */
	public abstract int getMaxInactiveInterval();

	/**
	 * Set the maximum time interval, in seconds, between client requests
	 * before the servlet container will invalidate the session.  A negative
	 * time indicates that the session should never time out.
	 *
	 * @param interval The new maximum interval
	 */
	public abstract void setMaxInactiveInterval(int interval);

	/**
	 * Set the <code>isNew</code> flag for this session.
	 *
	 * @param isNew The new value for the <code>isNew</code> flag
	 */
	public abstract void setNew(boolean isNew);
	
	/**
	 * Set the <code>isValid</code> flag for this session.
	 *
	 * @param isValid The new value for the <code>isValid</code> flag
	 */
	public abstract void setValid(boolean isValid);

	/**
	 * Return the <code>isValid</code> flag for this session.
	 */
	public abstract boolean isValid();

	// --------------------------------------------------------- Public Methods

	/**
	 * Update the accessed time information for this session.  This method
	 * should be called by the context when a request comes in for a particular
	 * session, even if the application does not reference it.
	 */
	public abstract void access();

	/**
	 * Perform the internal processing required to invalidate this session,
	 * without triggering an exception if the session has already expired.
	 */
	public abstract void expire();

	/**
	 * Release all object references, and initialize instance variables, in
	 * preparation for reuse of this object.
	 */
	public abstract void recycle();
}