in src/java/org/apache/turbine/services/rundata/TurbineRunDataService.java [213:287]
public RunData getRunData(String key,
HttpServletRequest req,
HttpServletResponse res,
ServletConfig config)
throws TurbineException,
IllegalArgumentException
{
// The RunData object caches all the information that is needed for
// the execution lifetime of a single request. A RunData object
// is created/recycled for each and every request and is passed
// to each and every module. Since each thread has its own RunData
// object, it is not necessary to perform synchronization for
// the data within this object.
if (req == null || res == null || config == null)
{
throw new IllegalArgumentException("HttpServletRequest, "
+ "HttpServletResponse or ServletConfig was null.");
}
// Get the specified configuration.
String[] cfg = (String[]) configurations.get(key);
if (cfg == null)
{
throw new TurbineException("RunTime configuration '" + key + "' is undefined");
}
TurbineRunData data;
try
{
Class<?> runDataClazz = classCache.computeIfAbsent(cfg[0], this::classForName);
Class<?> parameterParserClazz = classCache.computeIfAbsent(cfg[1], this::classForName);
Class<?> cookieParserClazz = classCache.computeIfAbsent(cfg[2], this::classForName);
data = (TurbineRunData) pool.getInstance(runDataClazz);
@SuppressWarnings("unchecked") // ok
ParameterParser pp = parserService.getParser((Class<ParameterParser>)parameterParserClazz);
data.get(Turbine.class).put(ParameterParser.class, pp);
@SuppressWarnings("unchecked") // ok
CookieParser cp = parserService.getParser((Class<CookieParser>)cookieParserClazz);
data.get(Turbine.class).put(CookieParser.class, cp);
Locale locale = req.getLocale();
if (locale == null)
{
// get the default from the Turbine configuration
locale = data.getLocale();
}
// set the locale detected and propagate it to the parsers
data.setLocale(locale);
}
catch (PoolException pe)
{
throw new TurbineException("RunData configuration '" + key + "' is illegal caused a pool exception", pe);
}
catch (TurbineRuntimeException | ClassCastException | InstantiationException x)
{
throw new TurbineException("RunData configuration '" + key + "' is illegal", x);
}
// Set the request and response.
data.get(Turbine.class).put(HttpServletRequest.class, req);
data.get(Turbine.class).put(HttpServletResponse.class, res);
// Set the servlet configuration.
data.get(Turbine.class).put(ServletConfig.class, config);
data.get(Turbine.class).put(ServletContext.class, config.getServletContext());
// Set the ServerData.
data.get(Turbine.class).put(ServerData.class, new ServerData(req));
return data;
}