2015-02-11 83 views
0

我想在osgi包中使用apache aries進行依賴注入。 這個bundle有一個在bundle激活器中註冊爲服務的servlet。 我們如何在藍圖配置xml中將servlet配置爲bean和/或服務?Apache白羊座和Servlet作爲osgi服務

回答

1

例如:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" 
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 
     http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 
     http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 
     http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0/blueprint-cm-1.0.0.xsd"> 

<bean id="whiteBoardServlet" class="org.ops4j.pax.web.extender.samples.whiteboard.internal.WhiteboardServlet"> 
    <argument type="java.lang.String" value="/whiteboard"/> 
</bean> 
<service id="whiteBoardServletService" ref="whiteBoardServlet" interface="javax.servlet.Servlet"> 
    <service-properties> 
     <entry key="alias" value="/whiteboard"/> 
    </service-properties> 
</service> 

更多細節可以在Pax Web Samples找到。

相關問題