2

Apache Karaf、CXF、および Aries Blueprint を使用しています。

多数の JAX-RS サービスを定義するバンドルがあります。デフォルトでは、CXF はこれらのサービスをシングルトンにしますが、これはうまくいきません。各リクエストを処理するには、新しいインスタンスが必要です。

CXF ドキュメントを参照して、サービスの新しいインスタンスを返す JAX-RS ServiceFactories を作成しようとしました。ドキュメントには Spring の例があり、私は同等のブループリントを試みました。

<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 に答える