Theme is built on velocity variables and velocity variables are set in velocitycontext pool and these objects will change for each request.
Please check com.liferay.portal.velocity.VelocityVariables.java class how the objects are stored in velocityContext and this class will invoked for every reuqest.
VelocityVariables.java - line no: 444
List<NavItem> navItems = NavItem.fromLayouts(requestVars, layouts);
velocityContext.put("navItems", navItems);
navItems are prepared and set in the velocityContext.
If you want to store your own objects in velocitycontext and use with in the theme, then need to write hook and
In portal.properties
servlet.service.events.pre=your class implementation
Hope this will help you.
Thanks,
Venkat
Please sign in to flag this as inappropriate.