How to append Strings while overriding annotations on MDB using AOP (ejb3-interceptors-aop.xml)?
I am trying to override the 开发者_StackOverflow中文版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?
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>
精彩评论