蓝图CXF serviceFactories:每个请求都需要一个实例

时间:2013-03-04 20:20:36

标签: osgi cxf apache-karaf blueprint-osgi aries

我正在使用Apache Karaf,CXF和Aries Blueprint。

我有一个定义了许多JAX-RS服务的包。默认情况下,CXF会将这些服务作为单例,但这对我不起作用。我需要一个新实例来处理每个请求。

引用CXF documentation,我试图创建返回服务新实例的JAX-RS ServiceFactories。该文档包含Spring的示例,我尝试使用Blueprint等效。

<reference id="groupService" interface="org.ozoneplatform.owf.server.service.api.GroupService"/>
<bean id="groups" class="org.ozoneplatform.owf.server.rest.GroupController" scope="prototype">
    <property name="service" ref="groupService"/>
</bean>
<bean id="groupFactory" class="org.apache.cxf.blueprint.jaxrs.BlueprintResourceFactory">
    <property name="beanId" value="groups" />
</bean>
<jaxrs:server id="ozoneplatform_cxf_endpoint"  address="/owf">
<jaxrs:serviceFactories>
    <ref bean="groupFactory" />
</jaxrs:serviceFactories>

蓝图无法开始提供错误

org.osgi.service.blueprint.container.ComponentDefinitionException: 
Error setting property: PropertyDescriptor <name: resourceProviders, getter: null, setter: [class org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setResourceProviders(interface java.util.List)]

1 个答案:

答案 0 :(得分:0)

您必须将BlueprintResourceFactory实例的“ blueprintContainer”属性定义为:

<bean id="groupFactory" class="org.apache.cxf.blueprint.jaxrs.BlueprintResourceFactory">
    <property name="beanId" value="groups" />
    <property name="blueprintContainer" ref="blueprintContainer"/>
</bean>

其中ref =“ blueprintContainer”是对顶级管理器的引用(请参见121.11 Blueprint Container