Passing and using properties through annotations in Java

by a e s t h e t i c   Last Updated July 11, 2019 11:05 AM

I have a Java EE Application in which I have an Interceptor class like this

public class LogInterceptor {

    public Object logMethod(InvocationContext context) throws Exception {

Now when I want it to work I annotate the target method with @Logged. Please correct me if my perception of this is wrong.

Now to the question.

Is it possible to pass/bind a variable (and when, how?) throught the annotation like so:

@Logged(ctx = methodContext)
public void someMethod(MethodContext methodContext) {

and then a use it in LogInterceptor.logMethod() ?

Or are there other options to accomplish this?

Related Questions

Updated December 24, 2017 13:05 PM

Updated March 29, 2018 11:05 AM

Updated December 27, 2017 21:05 PM

Updated October 08, 2016 09:02 AM

Updated December 02, 2016 08:02 AM