2

我正在使用 Apache Karaf、CXF 和 Aries 蓝图。

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

参考CXF 文档,我尝试创建返回服务的新实例的 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)]
4

1 回答 1

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

于 2019-05-15T09:33:04.060 回答