mburbidg
Jun 11th, 2008, 04:39 PM
I have a web application written with Spring-MVC/Spring-DM. I'm been able to modularize it in many compelling ways. I've very pleased with the architecture! Spring-DM/OSGi is cool.
Now I'm trying to modularize the web portion of the application. I have created a bundle that implements a spring controller, lets call this my service bundle. It declares a SimpleUrlHandlerMapping bean and registers the controller in this bean. I would like to export that mapping bean to the war bundle.
Here's the SimpleUrlHandlerMapping bean that is declared in my service bundle.
<bean id="sampleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop key="/subtract">subtractController</prop>
</props>
</property>
</bean>
<osgi:service ref="sampleUrlMapping" auto-export="interfaces"/>
I can import that bean into my war by including the following import service in the context file for my war.
<osgi:reference id="sampleUrlMapping">
<osgi:interfaces>
<value>org.springframework.web.servlet.HandlerMapping</value>
<value>org.springframework.core.Ordered</value>
</osgi:interfaces>
</osgi:reference>
This actually works and is pretty cool. The sampleUrlMapping bean from my service bundle is automatically recognized and used to map url to the controller bean in my service bundle.
So then I took the next step. I don't want my war to actually have to be aware of each bundle that may export handler mappings. So I changed the above to the following:
<osgi:list id="handlerMappings">
<osgi:interfaces>
<value>org.springframework.web.servlet.HandlerMapping</value>
<value>org.springframework.core.Ordered</value>
</osgi:interfaces>
</osgi:list>
I can see in the debugger that the service was imported, but it is not recognized by my war/Spring-MVC as a handler mapping. The url mapped in my service bundle is not recognized.
This is so close to being way cool. Does anyone have any ideas how I could get this to work?
Thanks,
Michael-
Now I'm trying to modularize the web portion of the application. I have created a bundle that implements a spring controller, lets call this my service bundle. It declares a SimpleUrlHandlerMapping bean and registers the controller in this bean. I would like to export that mapping bean to the war bundle.
Here's the SimpleUrlHandlerMapping bean that is declared in my service bundle.
<bean id="sampleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop key="/subtract">subtractController</prop>
</props>
</property>
</bean>
<osgi:service ref="sampleUrlMapping" auto-export="interfaces"/>
I can import that bean into my war by including the following import service in the context file for my war.
<osgi:reference id="sampleUrlMapping">
<osgi:interfaces>
<value>org.springframework.web.servlet.HandlerMapping</value>
<value>org.springframework.core.Ordered</value>
</osgi:interfaces>
</osgi:reference>
This actually works and is pretty cool. The sampleUrlMapping bean from my service bundle is automatically recognized and used to map url to the controller bean in my service bundle.
So then I took the next step. I don't want my war to actually have to be aware of each bundle that may export handler mappings. So I changed the above to the following:
<osgi:list id="handlerMappings">
<osgi:interfaces>
<value>org.springframework.web.servlet.HandlerMapping</value>
<value>org.springframework.core.Ordered</value>
</osgi:interfaces>
</osgi:list>
I can see in the debugger that the service was imported, but it is not recognized by my war/Spring-MVC as a handler mapping. The url mapped in my service bundle is not recognized.
This is so close to being way cool. Does anyone have any ideas how I could get this to work?
Thanks,
Michael-