【问题标题】:Blueprint properties placeholder蓝图属性占位符
【发布时间】:2021-04-09 03:09:42
【问题描述】:

这是我的蓝图:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd                            http://camel.apache.org/schema/blueprint https://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
    <bean class="ph.edu.dlsu.esb.CogMockProcessor" id="CogMockProcessor"/>
    
    <cm:property-placeholder id="cogmock.properties"
        persistent-id="custom.properties" update-strategy="reload">
        <cm:default-properties>
            <cm:property name="cogmock.host" value="//localhost"/>
            <cm:property name="cogmock.port" value="8989"/>
            <cm:property name="cogmock.path"
                value="/external/grade/updatestudentgrade"/>
            <cm:property name="cogmock.protocol" value="http"/>
            <cm:property name="cogmock.OpenId.Token"
                value="9GC1hnEeNIWVbehmxxjUwkj1Wcx2Y-P7SgOUZvVUzkM"/>

        </cm:default-properties>
    </cm:property-placeholder>
    
    <camelContext id="_mockcontext" xmlns="http://camel.apache.org/schema/blueprint">
        <route id="_route1">
            <from id="_from1" uri="restlet:http://localhost:{{cogmock.port}}/external/grade/updatestudentgrade?restletMethod=POST">
                <description>Mock the Camu Change of Grade API</description>
            </from>
            <process id="_process1" ref="CogMockProcessor"/>
            <log id="_log1" message="I'm here"/>
        </route>
    </camelContext>
</blueprint>

这是我的 fuse-karaf/etc/custom.properties

#
# You can place any customized configuration here.
#
cogmock.protocol=http
cogmock.host=//localhost
cogmock.port=8989
cogmock.path=/external/grade/updatestudentgrade
cogmock.OpenId.Token=9GC1hnEeNIWVbehmxxjUwkj1Wcx2Y-P7SgOUZvVUzkM

它构建成功,但是当我 bundle:install -s ... 我得到:

Unable to start container for blueprint bundle CogMock/1.0.0.SNAPSHOT

如果我取出 {{cogmock.port}} 一切正常。

我错过了什么?

【问题讨论】:

  • 在 /etc 中尝试了 cogmock.cfg 并更改了 persistentId=cogmock 无济于事。

标签: properties apache-karaf blueprint


【解决方案1】:

update-strategy="reload" 只能在您使用 xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" 或更高版本时添加到您的蓝图 XML。它不适用于xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"

需要明确的是,persistent-id 属性表示 PID,它(在使用 etc/ 配置时)是从带有 *.cfg 扩展名的文件创建的。因此,如果您有 persistent-id="cogmock",则需要带有属性的 $FUSE_HOME/etc/cogmock.cfg 文件。

【讨论】:

  • 是的,这就是全部。 v1.1.0 与 v1.0.0!谢谢,我已经在 /etc 中设置了 cogmock.cfg 并匹配了 persistent-id="cogmock" 谢谢。
猜你喜欢
  • 1970-01-01
  • 2018-10-25
  • 2017-03-21
  • 1970-01-01
  • 2015-08-09
  • 2014-07-16
  • 1970-01-01
  • 1970-01-01
  • 2011-09-17
相关资源
最近更新 更多