jcabi / jcabi-aspects

Collection of AspectJ Java Aspects to facilitate aspect-oriented programming patterns: logging, caching, validating, etc.
https://aspects.jcabi.com
Other
530 stars 150 forks source link

Specify annotation values from property file ala Spring #145

Open rquimosing opened 9 years ago

rquimosing commented 9 years ago

It would be helpful if jcabi-aspects supported pulling data from property files in its annotations, similar to Spring:

@Value("${systemProperties.myValue}")

Ex:

@RetryOnFailure(attempts=${systemProperties.myMethod.attempts}, delay=${systemProperties.delay})

I have this specific use-case where I don't want to hardcode values in the annotation.

dmarkov commented 9 years ago

@yegor256 please pay attention to this issue

yegor256 commented 9 years ago

@rquimosing I have a different idea. How about we make it possible to specify negative values there:

package foo.pkg;
class Hello {
  @RetryOnFailure(attempts=-1, delay=-1)
  void sendMeSomewhere() {
  }
}

When such a value is found, jcabi will try to load these properties:

foo.pkg.Hello.sendMeSomewhere.attempts
foo.pkg.Hello.sendMeSomewhere.delay

What do you think?

rquimosing commented 9 years ago

Hi Yegor,

Sorry for the late reply, I got your email on the weekend and was out most of the time. Sure, that'll work. Although I went with a different approach for my original problem, I can revisit it and use your library. Let me know when it gets in the release version.

Thanks! Reggie

On Sat, Sep 26, 2015 at 7:43 PM, Yegor Bugayenko notifications@github.com wrote:

@rquimosing https://github.com/rquimosing I have a different idea. How about we make it possible to specify negative values there:

package foo.pkg; class Hello { @RetryOnFailure(attempts=-1, delay=-1) void send() { } }

When such a value is found, jcabi will try to load these properties:

foo.pkg.Hello.send.attempts foo.pkg.Hello.send.delay

What do you think?

— Reply to this email directly or view it on GitHub https://github.com/jcabi/jcabi-aspects/issues/145#issuecomment-143513826 .

esaucastilloc commented 8 years ago

Hi yegor256,

I am starting to use your library and I came across with this suggestion regarding how to set the annotation values from a property. Have you included this feature in your latest release? Are you planning to include this in a next release?

Thanks