JBossESB でplaceholderを利用する
JBossESBでplaceholderってどう利用するんだろうと思って調べてみた。
するとこんなページを発見。
PropertiesService |JBoss Developer
どうやらJBossAS内にSystemPropertiesServiceなるものが存在し、それを「${JBOSS_HOME}/server/
この方法で実施しようと思ったんだけどさらに調べてみると
How to using propertyService to substitute para... |JBoss Developer
なるページを発見。
どうやらデプロイされたアプリケーションのロード順によってはproperties-service.xmlの設定が効かないことがあるらしいので、「${JBOSS_HOME}/server/
(ここに定義しておくと必ず「${JBOSS_HOME}/server/
JBossESBも「${JBOSS_HOME}/server/
ということで、今回はひとまず「${JBOSS_HOME}/server/
<mbean code="org.jboss.varia.property.SystemPropertiesService" name="me:service=MyProperties"> <attribute name="Properties"> test.value=Hello </attribute> </mbean>
<action name="SystemPrintln" class="org.jboss.soa.esb.actions.SystemPrintln"> <property name="message" value="${test.value}" /> </action>
これで無事JBossESBでplaceholderが扱えた。
<mbean code="org.jboss.varia.property.SystemPropertiesService" name="me:service=MyProperties"> <attribute name="URLList"> ./conf/xxx.properties, /home/hoge/conf/yyy.properties </attribute> </mbean>
のようにカンマ区切りでプロパティファイルを定義すると、外部ファイルから値を取得することもできる。
こっちの方が用途が多そうだな〜
【2012/05/30 追記】
このままだと
「${JBOSS_HOME}/server/
「${JBOSS_HOME}/server/
の2箇所にSystemPropertiesServiceが存在することとなり、JBoss起動時にエラーが発生する。
そのため、
「${JBOSS_HOME}/server/
に元々ある定義はコメントアウトするべき。