Hi,
I think that it's not ideal how WebAppController processes static
resources like images. I have 2 things to point out:
1) Today I found (and fixed) a bug that images are first processed by
PortalRequestHandler, even if they should be processed by
StaticResourceRequestHandler. Please look at
https://issues.jboss.org/browse/GTNPORTAL-2338 for more details. This is
really not good because HTTP header "Cache-Control: no-cache" is
returned for every image, and so web browser needs to download images
for each HTTP request to portal. I fixed it by adding
StaticResourceRequestHandler before PortalRequestHandler into
navController configuration, so it should not be the issue anymore.
2) Second thing is not so bad but a bit more tricky. The piece of code
in WebAppController:
{code}
if (!started)
{
RequestLifeCycle.begin(ExoContainerContext.getCurrentContainer());
started = true;
}
.....
processed = handler.execute(new ControllerContext(this,
router, req, res, parameters));
.....
if (started)
{
RequestLifeCycle.end();
}
{code}
This means that we need to start RequestLifeCycle for processing of
every resource including static resource. And startup of some services
is quite expensive (like startup of OrganizationService requires startup
of Hibernate transaction). In other words, currently we are starting
Hibernate transaction for processing images and other static resources.
It's obvious that some handlers (PortalRequestHandler,
LegacyRequestHandler and probably some others) really need to start
RequestLifecycle, but some others like StaticResourceRequestHandler
don't need it. So how about postponing the RequestLifecycle.begin from
WebAppController to concrete handlers, which really need it? And use
some ThreadLocal variable or flag "started" on ControllerContext, so
that we can track if RequestLifeCycle.begin has been already started
(can be useful to avoid double-start if some resource needs to be
processed by more request handlers) ?
Any other suggestions for this?
Marek