2012-03-06 34 views
1

我正在嘗試編寫JCA資源適配器。在ra.xml我添加條目,如自定義屬性:JCA資源適配器如何讀取ra.xml中定義的自定義屬性

<config-property> 
    <config-property-name>UserName</config-property-name> 
    <config-property-type>java.lang.String</config-property-type> 
    <config-property-value></config-property-value> 
</config-property> 

當我加載在WebSphere這些條目下的RA的自定義屬性顯示的資源適配器。可以編輯並保存這些值,WebSphere將在重新啓動後重新加載它們。

然而,資源適配器本身如何讀取這些值?我猜它涉及到注入和註釋等,但我似乎無法找到任何簡單解釋它應該如何工作的內容。

感謝,

回答

1

如果你寫消息適配器可以檢查出jca-sockets項目。它包含一個清晰描述如何讀取配置屬性的示例。你應該在ra.xml描述符指定的ActivationSpec XML標籤:

 <activationspec> 
     <activationspec-class>bla.bla.bla.BlaActivationSpec</activationspec-class> 
     <required-config-property> 
      <description>Bla Activation property</description> 
      <config-property-name>bla</config-property-name> 
     </required-config-property> 
     </activationspec> 

bla.bla.bla.BlaActivationSpec是一個POJO類,提供了getter和setter屬性。

但似乎這種方法只適用於消息適配器,它是有趣的如何讀取出站適配器的屬性......現在我正試圖找出這一點。

+0

** UPD **:如果您正在編寫出站適配器,則可以在ManagedConnectionFactory實現中提供setter。在部署過程中,服務器將嘗試爲在ra.xml中定義的每個配置屬性查找setter。 – gkuzmin 2012-03-21 08:33:46