Carsten Ziegeler wrote:
Leszek Gawron wrote:
Moreover the root context should be at least a
ConfigurableWebApplicationContext that should be registered properly in
servlet context. For now none of spring related servlet filters work
because they all rely on WebApplicationContextUtils [1] (and this one
throws not finding spring context in servlet context).
I had to move all META-INF/spring/*.xml to META-INF/springX/*.xml so
cocoon does not pick those automatically and build myself a separate web
application context with spring's ContextLoaderListener.
[1]
http://www.springframework.org/docs/api/org/springframework/web/context/support/WebApplicationContextUtils.html
The basic idea was that Cocoon is using its own hierarchy of bean
factories (application context) and if you want to use Spring you should
setup your application context through the usual spring stuff (with the
listener). In that case the cocoon bean factory will use that one as its
parent.
I dislike that idea a lot, because:
1. it is error prone. If the functionality works as you described I had
completely no idea of it. I accidentaly put ContextLoaderListener
declaration after CocoonServletListener
<listener>
<listener-class>org.apache.cocoon.servlet.CocoonServletListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.acegisecurity.ui.session.HttpSessionEventPublisher</listener-class>
</listener>
This innocent configuration creates two separate spring contexts (one
has totally no connection to another).
2. It's annoying. In order to load my web application context separately
(because of the filters not finding WebApplicationContext) I had to
split META-INF/spring into META-INF/spring and
META-INF/spring-via-contextloader
3. It narrows functionality. As my web application context Is the root
it cannot use cocoon's xml parser.
4. I simply cannot wrap my head around the fact that my domain services
context is the parent for cocoon's framework. It should be totally opposite.
Instead of:
my web application context
^
|
cocoon root bean factory
^
|
blocks' contexts
it should be:
my context + cocoon bean factory = root web application context
^
|
blocks' contexts
which is way clearer.
--
Leszek Gawron, IT Manager MobileBox sp. z o.o.
+48 (61) 855 06 67 http://www.mobilebox.pl
mobile: +48 (501) 720 812 fax: +48 (61) 853 29 65