【问题标题】:Annotations args dynamic注释 args 动态
【发布时间】:2011-06-26 17:22:48
【问题描述】:

每个开发者的噩梦都是他/她的代码在最终包装中的适合程度......

EJB3.x 的问题是注释的使用,而无法使用新的参数集重新编译代码以使单元通过集成测试

例如:

@MessageDriven(activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/Messagess") })

问题是有多少 J2ee 容器保证队列 jms 框始终是“queue/Messagess”

那么命名可以是“queue/xyzabc”.....

如何在不重新编译代码的情况下在 EJB3.x 中配置这些参数...???

关于

卡提克

【问题讨论】:

    标签: java testing ejb-3.0 integration-testing


    【解决方案1】:

    在 XML 中使用activation-config-property。

    <message-driven>
      <ejb-name>YourMDBName</ejb-name>
      <activation-config>
        <activation-config-property>
          <activation-config-property-name>destination</activation-config-property-name>
          <activation-config-property-value>YourValue</activation-config-property-value>
        </activation-config-property>
      </activation-config>
    </message-driven>
    

    仅仅因为您使用带有注释的 EJB 3.x 来简化开发并不意味着使用 XML 覆盖注释配置数据是“错误的”。

    【讨论】:

    • 嗨>>易于开发并不意味着使用 XML 覆盖注释配置数据是“错误的”
    • 嗨>>易于开发并不意味着使用 XML 覆盖注释配置数据是“错误的”,而不是重新发明 Weel,我宁愿简化 Weel 的使用。我的意思是说,如果注释是杂乱的 XML 的替代品,并且简化了 EJB 流程……那么同样应该支持运行时配置。我肯定会离开 .. 开发人员会同意中间解决方案。 .
    • 没有标准化的“中间”解决方案:要么使用注释(不重新编译就无法更改)或使用 XML(更冗长)。
    猜你喜欢
    • 2016-06-05
    • 1970-01-01
    • 2016-08-30
    • 2013-10-02
    • 2014-03-31
    • 2019-05-06
    • 1970-01-01
    • 1970-01-01
    • 2019-09-25
    相关资源
    最近更新 更多