第一步:获得rundata
// Get general RunData here...
// Perform turbine specific initialization below.
data = rundataService.getRunData(req, res, getServletConfig()); //获得rundata ,第一次不存在 采用默认的
// If this is the first invocation, perform some
// initialization. Certain services need RunData to initialize
// themselves.
if (firstDoGet)
{
init(data);
}
第二步:验证rundata,执行action
// set the session timeout if specified in turbine's properties
// file if this is a new session
if (data.getSession().isNew()) //是否是一个新的会话
{
int timeout = configuration.getInt(SESSION_TIMEOUT_KEY,
SESSION_TIMEOUT_DEFAULT);
if (timeout != SESSION_TIMEOUT_DEFAULT)
{
data.getSession().setMaxInactiveInterval(timeout);
}
}
//------------------------------------------------------------------------------------
// Fill in the screen and action variables.
data.setScreen(data.getParameters().getString(URIConstants.CGI_SCREEN_PARAM));
data.setAction(data.getParameters().getString(URIConstants.CGI_ACTION_PARAM));
// Special case for login and logout, this must happen before the
// session validator is executed in order either to allow a user to
// even login, or to ensure that the session validator gets to
// mandate its page selection policy for non-logged in users
// after the logout has taken place.
if (data.hasAction()) //判断是login 还是 logout 执行相应的action
{
String action = data.getAction();
log.debug("action = " + action);
if (action.equalsIgnoreCase(
configuration.getString(ACTION_LOGIN_KEY,
ACTION_LOGIN_DEFAULT)))
{
loginAction(data);
}
else if (action.equalsIgnoreCase(
configuration.getString(ACTION_LOGOUT_KEY,
ACTION_LOGOUT_DEFAULT)))
{
logoutAction(data);
}
}
//-------------------------------------------------------------------------------------
ActionLoader.getInstance().exec(
data, configuration.getString(ACTION_SESSION_VALIDATOR_KEY,
ACTION_SESSION_VALIDATOR_DEFAULT));//执行session验证
ActionLoader.getInstance().exec(
data, configuration.getString(ACTION_ACCESS_CONTROLLER_KEY,
ACTION_ACCESS_CONTROLLER_DEFAULT));//执行access controller
//--------------------------------------------------------------------------------------------
第三步:执行page
PageLoader.getInstance().exec(data, defaultPage);
第四步:响应页面
if (requestRedirected)
{
/***************/
}
if (!requestRedirected)
{/**********/}
第五步:封装RunDataService
try{/**********/}
catch(exception e ){/********/}
fainaly{
rundataService.putRunData(data);
}