如何使用 AOP (ejb3-interceptors-aop.xml) 覆盖 MDB 上的注释时附加字符串?

发布于 2024-12-02 17:05:03 字数 750 浏览 2 评论 0原文

我试图使用文件 ejb3-interceptors-aop.xml 覆盖 MDB(部署在 Jboss 上)上的注释

注释的形式

@MessageDriven(mappedName = "jms/someName", activationConfig = {
... ,
@ActivationConfigProperty(propertyName = "messageSelector", propertyValue = ConstantStrings.CONST1
+ " = '"
+ ConstantStrings.CONST2
+ "'"
)})

为: 但是,当我在 XML 文件中使用它时:

<annotation expr="class(com.pkg.ClassName)">
     @javax.ejb.MessageDriven(mappedName = "jms/someName", activationConfig = { ... , @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = com.my.pkg.ConstantStrings.CONST1 + " = '" + com.my.pkg.ConstantStrings.CONST2 + "'")})
</annotation>

它会抛出一个词法错误: 遇到:“+”,之后:“”

知道如何解决这个问题吗?

I am trying to override the annotations on an MDB (deployed on Jboss) using the file ejb3-interceptors-aop.xml

The annotation is of the form:

@MessageDriven(mappedName = "jms/someName", activationConfig = {
... ,
@ActivationConfigProperty(propertyName = "messageSelector", propertyValue = ConstantStrings.CONST1
+ " = '"
+ ConstantStrings.CONST2
+ "'"
)})

However when i use this in the XML file as:

<annotation expr="class(com.pkg.ClassName)">
     @javax.ejb.MessageDriven(mappedName = "jms/someName", activationConfig = { ... , @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = com.my.pkg.ConstantStrings.CONST1 + " = '" + com.my.pkg.ConstantStrings.CONST2 + "'")})
</annotation>

It throws a lexical error: Encountered: "+" , after : ""

Any idea how I can work around this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北笙凉宸 2024-12-09 17:05:03

您缺少一个右括号。

@MessageDriven(
    mappedName = "jms/someName",
    activationConfig = {
        ... ,
        @ActivationConfigProperty(
            propertyName = "messageSelector",
            propertyValue = ConstantStrings.CONST1 
                            + " = '"
                            + ConstantStrings.CONST2
                            + "'"
        )
    }
) // this one

如果这只是错误的复制和粘贴并且错误仍然存​​在,请尝试使用单个静态变量而不是 xml 内的串联。在 java 类中使用串联。

public static final Sting MESSAGE_SELECTOR = CONST1 + " = '" + CONST2 + "'";

 

<annotation expr="class(com.pkg.ClassName)">
    @javax.ejb.MessageDriven(mappedName = "jms/someName", activationConfig = { ... , 
        @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = com.my.pkg.ConstantStrings.MESSAGE_SELECTOR)
    })
</annotation>

You are missing a closing parenthesis.

@MessageDriven(
    mappedName = "jms/someName",
    activationConfig = {
        ... ,
        @ActivationConfigProperty(
            propertyName = "messageSelector",
            propertyValue = ConstantStrings.CONST1 
                            + " = '"
                            + ConstantStrings.CONST2
                            + "'"
        )
    }
) // this one

If that was just bad copy&paste and the errors still exist, try using a single static variable instead of concatenation inside xml. Use concatenation inside the java class instead.

public static final Sting MESSAGE_SELECTOR = CONST1 + " = '" + CONST2 + "'";

<annotation expr="class(com.pkg.ClassName)">
    @javax.ejb.MessageDriven(mappedName = "jms/someName", activationConfig = { ... , 
        @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = com.my.pkg.ConstantStrings.MESSAGE_SELECTOR)
    })
</annotation>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文