Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Check the arguments for all annotated methods at runtime
- public class OnlyAScratchForAnPostProcessor {
- @Inject
- private ApplicationContext context;
- @Override
- public Object postProcessAfterInitialization(final Object bean,
- final String beanName) throws BeansException {
- ReflectionUtils.doWithMethods(bean.getClass(), new MethodCallback() {
- @Override
- public void doWith(Method method) throws IllegalArgumentException,
- IllegalAccessException {
- String expecedNameFromAnnotation = scanAnnotation(method);
- if(expecedNameFromAnnotation != null) {
- if(context.beanByName(expecedNameFromAnnotation) != null) {
- throw new RuntimeException("illegal configuration");
- }
- }
- }
- String scanAnnotation(Method method){...}
- }, ReflectionUtils.USER_DECLARED_METHODS);
- }
Add Comment
Please, Sign In to add comment