Guest User

Untitled

a guest
Aug 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. Check the arguments for all annotated methods at runtime
  2. public class OnlyAScratchForAnPostProcessor {
  3.  
  4. @Inject
  5. private ApplicationContext context;
  6.  
  7.  
  8. @Override
  9. public Object postProcessAfterInitialization(final Object bean,
  10. final String beanName) throws BeansException {
  11.  
  12. ReflectionUtils.doWithMethods(bean.getClass(), new MethodCallback() {
  13.  
  14. @Override
  15. public void doWith(Method method) throws IllegalArgumentException,
  16. IllegalAccessException {
  17.  
  18. String expecedNameFromAnnotation = scanAnnotation(method);
  19. if(expecedNameFromAnnotation != null) {
  20. if(context.beanByName(expecedNameFromAnnotation) != null) {
  21. throw new RuntimeException("illegal configuration");
  22. }
  23. }
  24. }
  25.  
  26. String scanAnnotation(Method method){...}
  27.  
  28. }, ReflectionUtils.USER_DECLARED_METHODS);
  29.  
  30. }
Add Comment
Please, Sign In to add comment