Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Legitimate value for EJB annotation  RSS feed

 
vu lee
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value for an annotation must be a constant literal String.
@Distribution(policy="MyPolicy")
Instead of hard coding, I wanted to assign the value for policy attribute from a property file, but I got the compiler error. Is there a way to get around this? Thanks
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to assign the value for policy attribute from a property file


What would you achieve by that? Since the annotations are parsed at compile-time and not at runtime.
 
vu lee
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just want to find an alternative way instead of hardcoding the value.

Currently, if I want to modify the value, I must modifier the java file and run a build.

For ejb3, it is not a problem. For instance, to overwritten EJB transaction attribute, I could modify the xml file to set the new attribute value, knowing that whatever values in the xml file will overwrite those in annotation.

Though I tried different combinations, I could not get around this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!