Achieve loose coupling for Interceptors using attributes #38050
Unanswered
git4rputuval
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You can use a For example:
And my interceptor looks like this:
The NonBinding member (type in my case) still needs to be specified on the interceptor, since it has no default value. However, it won't influence matching. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The purpose is to use Interceptor for my service and add an attribute (
serviceName
) to the custom ( interceptor) annotation, where the service name would be passed by every respective service annotated by this interceptor.However, this attribute name needs to be passed in the interceptor implementation and the service classes. The attribute can be passed in the service class as shown in the snapshot below.
But it cannot be passed in the interceptor implementation due to which we have a compilation problem as shown in snapshot below.

We do not want to hardcode or re-enter the service name in the Interceptor Implementation class since it defeats the purpose of an interceptor being used across the system. Instead it should extract the attribute value from the service annotated by the Interceptor and marked with the
serviceName
attribute.How do we resolve the compilation issue?
please find the attached zip to run the code n check for error or workaround for a solution
InterceptorIssue.zip
Beta Was this translation helpful? Give feedback.
All reactions