开发者

How to append Strings while overriding annotations on MDB using AOP (ejb3-interceptors-aop.xml)?

开发者 https://www.devze.com 2023-04-02 05:07 出处:网络
I am trying to override the 开发者_StackOverflow中文版annotations on an MDB (deployed on Jboss) using the file 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>
0

精彩评论

暂无评论...
验证码 换一张
取 消