Extending context of a web bundle via fragment [message #976842] |
Thu, 08 November 2012 17:17  |
Eclipse User |
|
|
|
Hi,
I would like to ask what is generally the best way to extend the spring context of a web-bundle by a fragment. The documentation instructs not to use WEB-INF\spring\*.xml contexts but rather use the web-framework to bootstrap the context:
http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/web.html
So I tried a contextConfigLocation <context-param> to configure a ContextLoaderListener. Here is the respective part of my web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/*Context.xml
</param-value>
</context-param>
<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
I found that this configuration of the contextConfigLocation does not find contexts in fragments. The fragment contexts are only found if they are specified with no wildcards. So this here would work:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/*Context.xml, /WEB-INF/SomeFragmentContextThatExists.xml
</param-value>
</context-param>
Of course this doesn't make sense since I don't know which fragments will be provided in my final configuration. After debugging into the code I found the following solution to the problem:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
osgibundle:/WEB-INF/*Context.xml
</param-value>
</context-param>
This configuration will also find all fragment contexts. Since according to the documentation fragments should seamlessly integrate with the host bundle I do not see a reason why "WEB-INF/*Context.xml" should not find all fragment contexts. Therefore I would consider this a bug.
Are there any experiences with this?
Regards,
Thorsten
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10783 seconds