我有一个消息驱动 bean,它通过 GlassFish 3.1.1 应用程序服务器中的 JCA 资源适配器从 TCP 套接字上接收的数据中调用。sun-ejb-jar.xml 文件中的部署描述符指定了套接字的 URL 和端口。部署 MDB 时,我看到应用服务器执行资源适配器中的 endpointActivation() 方法,并使用 MessageEndpointFactory 和 ActivationSpec 作为参数。
当 URL 和端口在部署之前已知并且可以在 XML 文件中指定时,这可以正常工作,但是现在我需要能够在运行时在我的 EJB 代码中更改 TCP 套接字。我在 JCA 规范中找不到任何关于如何在运行时执行此操作的参考。
作为参考,我从 Oracle 的网站下载了规范。 J2EE 连接器架构规范版本 1.5
基本上,我想将以下填充 ActivationSpec 的 XML 代码移动到我的 EJB 代码中。
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>MyInboundSocketMDB</ejb-name>
<mdb-resource-adapter>
<resource-adapter-mid>jca-sockets-rar</resource-adapter-mid>
<activation-config>
<activation-config-property>
<activation-config-property-name>url</activation-config-property-name>
<activation-config-property-value>localhost</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>port</activation-config-property-name>
<activation-config-property-value>5006</activation-config-property-value>
</activation-config-property>
</activation-config>
</mdb-resource-adapter>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
感谢您的任何建议。