Yes, something like this:
void findAnnotatedArguments(MethodInvocation methodInvocation) {
Method method = methodInvocation.getMethod(); checkArgument(
method.isAnnotationPresent(RequiresPermission.class),
"Unexpected method passed to the Interceptor: %s", method);
Object[] methodArguments = methodInvocation.getArguments(); Type[]
genericParameterTypes = method.getGenericParameterTypes();
Annotation[][] annotationsOfParameters =
method.getParameterAnnotations(); for (int i = 0; i <
annotationsOfParameters.length; i++) { Annotation[]
annotationsOfParameter = annotationsOfParameters[i];
for (Annotation annotation : annotationsOfParameter) {
if (Named.class.isInstance(annotation)) {
... do whatever you want
}
}
}
}
On Mon, May 7, 2012 at 12:09 PM, Carlos Alexandro Becker <[email protected]
> wrote:
> I'm taking a look at guice aop integration... and wonder something:
>
> If I have a named parameter like this:
>
> @RequiresPermission(permission = Permission.WRITE)
> public void needsWrite(@Named("test") User u, @Named("test2") String t) {
> System.out.println("I write something :) " + t);
> }
>
> Can I get these parameters by Named annotations in my method interceptor?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-guice/-/FjI8kHjOB9oJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.