12.6. Fabric8 Karaf 블루프린트 지원 추가
fabric8-karaf-blueprint 는 Aries PropertyEvaluator 및 fabric8-karaf-core 의 속성 자리 표시자를 사용하여 블루프린트 XML 파일의 자리 표시자를 해결합니다.
절차
사용자 정의 Karaf 배포에 블루프린트 지원 기능을 포함하려면 프로젝트
pom.xml의startupFeatures섹션에fabric8-karaf-blueprint를 추가합니다.<startupFeatures> ... <feature>fabric8-karaf-blueprint</feature> ... </startupFeatures>
예제
fabric8 평가기는 ${env+service:MY_ENV_VAR} 과 같은 체인 평가기를 지원합니다. 환경 변수에 대해 MY_ENV_VAR 변수를 확인해야 합니다. 그런 다음 service function을 사용하여 결과를 해결합니다. 예를 들면 다음과 같습니다.
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.2.0"
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
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.3.0
http://aries.apache.org/schemas/blueprint-ext/blueprint-ext-1.3.xsd">
<ext:property-placeholder evaluator="fabric8" placeholder-prefix="$[" placeholder-suffix="]"/>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="userName" value="$[k8s:secret:$[env:ACTIVEMQ_SERVICE_NAME]/username]"/>
<property name="password" value="$[k8s:secret:$[env:ACTIVEMQ_SERVICE_NAME]/password]"/>
<property name="brokerURL" value="tcp://$[env+service:ACTIVEMQ_SERVICE_NAME]"/>
</bean>
</blueprint>중요
중첩된 속성 자리 표시자 대체에는 Aries Blueprint Core 1.7.0 이상이 필요합니다.