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