[Question] Reverse lookup Guice created instance's type and annotation

23 views
Skip to first unread message

Yutian Wu

unread,
Apr 11, 2021, 3:02:41 PM4/11/21
to google-guice
This might be a very specific requirement, while I think it is rather common in an AOP implementation.

so I was using Guice AOP with a generic class, and I bind the class with TypeLiteral and Annotation.

```java
bind(new TypeLiteral<GenericClass<String>>(){}).annotatedWith(Annotation1.class).to(...)
bind(new TypeLiteral<GenericClass<String>>(){}).annotatedWith(Annotation2.class).to(...)
```

and then we used it directly in constructor injection.

now when I create an aspect on GenericClass, I want to know the current instance annotation and its generic type, is it possible to do so in Guice?

Reply all
Reply to author
Forward
0 new messages