|
|
|
|
|
| Re: Can I import and export services when I'm using Virgo Snaps? [message #974685 is a reply to message #973359] |
Wed, 07 November 2012 03:47  |
Markus Schmailzl Messages: 6 Registered: November 2012 |
Junior Member |
|
|
Hello,
I have found a solution to my problem by now. I have a Snap called de.project.bai.webapp.plugins.deviceManagement. The Snap uses
the two contexts /WEB-INF/webapp-context.xml and /WEB-INF/deviceManagement-servlet.xml.
In the Servlet there is a bean instanciated which is exported as an osgi service in the webapp-context.
In other snaps it is possible to use this service by importing it via <osgi:reference.
The host itself doenst provide another context beside the standard one.
Maybe someone can tell me whether this solution is a practical one for my use case and if I could run into any problems.
The use case is a pluggable webplattform where users can provide there own snaps. A snap should be able to provide services to other snaps and use services from snaps as well as providing some dynamic webpages with jsp.
Thanks
web.xml of Snap deviceManagement
<?xml ...>
<display-name>Base</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>base</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/webapp-context.xml
/WEB-INF/deviceManagement-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>base</servlet-name>
<url-pattern>/web/*</url-pattern>
</servlet-mapping>
</web-app>
webapp-contxt.xml from deviceManagement
<beans ...>
<osgi:service ref="deviceManager" interface="de.project.bai.webapp.plugins.deviceManagement.services.DeviceManager"></osgi:service>
</beans>
deviceManagement-servlet.xml from deviceManagement
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<context:component-scan base-package="de.project.bai.webapp.plugins.deviceManagement" />
<bean id="deviceManager" class="de.project.bai.webapp.plugins.deviceManagement.DeviceManagerImpl"/>
</beans>
|
|
|
Powered by
FUDForum. Page generated in 0.19609 seconds