JCA资源适配器如何读取ra.xml中定义的自定义属性

时间:2012-03-06 09:45:14

标签: java websphere jca

我正在尝试编写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 个答案:

答案 0 :(得分: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。

但似乎这种方法仅适用于消息适配器,如何读取出站适配器的属性很有趣......现在我试图找到它。

相关问题