2016-10-14 9 views
0

私は青写真1でプロパティを定義し、2シェア2つの青写真

どちらの青写真が同じKaraf OSGIコンテナにロードされたが、別のバンドル内に存在することになる青写真では、デフォルトのプロパティとしてそれを使用しようとしています間のプロパティ。マニフェストには、必要な依存情報がすでに設定されています。上記で定義された「私の財産」を使用しようとしている

<blueprint 
    xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:osgix="http://www.springframework.org/schema/osgi-compendium" 
    xsi:schemaLocation=" 
     http://www.osgi.org/xmlns/blueprint/v1.0.0 
     https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> 

<!-- Properties for this blueprint --> 
<osgix:cm-properties id="sharedProperties" persistent-id="com.foo.project" update-strategy="reload" 
         xmlns="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"> 
    <default-properties> 
     <property name="shared-property" value="value"/> 
    </default-properties> 
</osgix:cm-properties> 

<bean id="myBean" 
     class="com.foo.MyClass"> 
    <property name="setting" value="{{shared-property}}"/> 
</bean> 

そして、私の他の青写真:ここ

は、私は別の青写真で再び使用するプロパティを定義して、私のBlueprint1です

<blueprint 
    xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:osgix="http://www.springframework.org/schema/osgi-compendium" 
    xmlns:ctx="http://www.springframework.org/schema/context" 
    xsi:schemaLocation=" 
     http://www.osgi.org/xmlns/blueprint/v1.0.0 
     https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> 

<!-- Load the properties from Blueprint1. Intent is to use property defined over there, here. --> 
<osgix:cm-properties id="sharedProperties" persistent-id="com.foo.project"/> 
<!-- Make properties defined in sharedProperties available using ${} syntax--> 
<ctx:property-placeholder properties-ref="sharedProperties" /> 

<!-- Properties for this blueprint --> 
<property-placeholder persistent-id="com.foo.project.blueprint2" update-strategy="reload" 
         xmlns="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" 
         placeholder-prefix="{{{" 
         placeholder-suffix="}}}"> 
    <default-properties> 
     <property name="my-property" value="${shared-property}"/> 
    </default-properties> 
</property-placeholder> 

<bean id="myBean" 
     class="com.foo.MyClass"> 
    <property name="setting" value="{{{my-property}}}"/> 
</bean> 

アイブ氏はこれをc感(多分ちょうど希望を)得ました訂正するために失われますが、少しはオフです。それが正しい場合、私の問題は、ネームスペースハンドラが不足している可能性があります。

答えて

1

"default-properties"タグを使用することで、値を再定義します。 2番目のプロジェクトから削除します。また、両方からdefault-propertiesを削除し、外部化されたcfgファイルを使用して、起動時に競合状態がないようにすることをお勧めします。

これを削除します。

<default-properties> 
    <property name="my-property" value="${shared-property}"/> 
</default-properties> 
関連する問題