Question

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?

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top