如何使用 AOP (ejb3-interceptors-aop.xml) 覆盖 MDB 上的注释时附加字符串?
我试图使用文件 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少一个右括号。
如果这只是错误的复制和粘贴并且错误仍然存在,请尝试使用单个静态变量而不是 xml 内的串联。在 java 类中使用串联。
public static final Sting MESSAGE_SELECTOR = CONST1 + " = '" + CONST2 + "'";
You are missing a closing parenthesis.
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 + "'";