Reputation: 3103
I am using custom annotation with aspectj.
@TestLoggingAnnotation(setMessage = "I want to set value here")
public void get() {
String retString = null;
String message = "DEFAULT";
if (message == "DEFAULT") {
retString = "Default Logging";
} else {
retString = "Custom Logging";
}
}
The above is just simple and sample code. My requirement is that I want to pass the parameter value after resulting from method.
In my case I want set retString
value to setMessage
in custom parameter.
Upvotes: 6
Views: 7618
Reputation: 1853
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface TestLoggingAnnotation{
String setMessage ();
}
now use reflection to extract and set method param i doubt we can do this with local varibles.
Upvotes: 0
Reputation: 8663
As of now, annotations can only take compile constants and cant be assigned values at runtime, though their value can be used at runtime using @Retention.
Upvotes: 2