2

我正在尝试编写一个 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 会在重新启动后重新加载它们。

然而,资源适配器本身如何读取访问这些值?我猜它涉及注入和注释或其他东西,但我似乎找不到任何简单解释它应该如何工作的东西。

谢谢,

4

1 回答 1

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。

但似乎这种方法仅适用于消息适配器,有趣的是如何读取出站适配器的属性......现在我正在尝试找出这一点。

于 2012-03-13T10:39:03.297 回答