1
我有一个关于绑定和注释的问题。如何测试实现AbstractModule的类中的注释对象
我有下面的类:
public class MailFacadeImpl implements MailFacade {
private final PersonDao personDao;
@Inject
public MailFacadeImpl(@Mail PersonDao personDao) {
super();
this.personDao = personDao;
}
的PersonDao的标注有一个自定义的注释。 我希望能够在实现AbstractModule的类内部测试这个注解。
这里是一段代码:
bind(new TypeLiteral<SecurityRulesFactory<Person>>(){}).toProvider(FactoryProvider.newFactory(
new TypeLiteral<SecurityRulesFactory<Person>>(){}, new TypeLiteral<MailSecurityRulesCrdb>(){}));
我想有类似的财产以后:
if(PersonDAO is annotated with(Mail.class)){
bind(new TypeLiteral<SecurityRulesFactory<Person>>(){}).toProvider(FactoryProvider.newFactory(
new TypeLiteral<SecurityRulesFactory<Person>>(){}, new TypeLiteral<MailSecurityRulesCrdb>(){}));
}
你认为这是可能的吗?
thx对你有帮助:-) 祝你周末愉快!
我发现这个:personDao.class.isAnnotationPresent(Mail.class)。也许它有效。我会测试。 – AbstractMan 2010-11-26 09:34:45