@Test public void foo() { SimpleMacroMacro result = (SimpleMacroMacro) processor.postProcessAfterInitialization(macro, "macroBean"); IMacroDescriptor descriptor = result.getDescriptor(); assertEquals(MACRO, descriptor.getMacroName()); assertEquals(INSERT_TEXT, descriptor.getInsertText()); assertTrue(descriptor.isCacheable()); result.createRunnable(); assertTrue(macro.createRunnableInvoked); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) { Macro annotation = bean.getClass().getAnnotation(Macro.class); if (annotation != null) { if (StringUtils.isBlank(annotation.name())) { throw new BeanDefinitionValidationException("no macro name specified in @" + Macro.class.getSimpleName() + " annotation for bean: " + beanName); } if (!(bean instanceof IMacro)) { if (bean instanceof ISimpleMacro) { return createMacro((ISimpleMacro) bean, annotation); } else if (bean instanceof IMacroRunnable) { @SuppressWarnings("unchecked") Class<? extends IMacroRunnable> clazz = (Class<? extends IMacroRunnable>) bean.getClass(); return createMacro(clazz, annotation); } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { return bean; } }
MacroBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) { Macro annotation = bean.getClass().getAnnotation(Macro.class); if (annotation != null) { if (StringUtils.isBlank(annotation.name())) { throw new BeanDefinitionValidationException("no macro name specified in @" + Macro.class.getSimpleName() + " annotation for bean: " + beanName); } if (!(bean instanceof IMacro)) { if (bean instanceof ISimpleMacro) { return createMacro((ISimpleMacro) bean, annotation); } else if (bean instanceof IMacroRunnable) { @SuppressWarnings("unchecked") Class<? extends IMacroRunnable> clazz = (Class<? extends IMacroRunnable>) bean.getClass(); return createMacro(clazz, annotation); } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { return bean; } } }
MacroBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) { Macro annotation = bean.getClass().getAnnotation(Macro.class); if (annotation != null) { if (StringUtils.isBlank(annotation.name())) { throw new BeanDefinitionValidationException("no macro name specified in @" + Macro.class.getSimpleName() + " annotation for bean: " + beanName); } if (!(bean instanceof IMacro)) { if (bean instanceof ISimpleMacro) { return createMacro((ISimpleMacro) bean, annotation); } else if (bean instanceof IMacroRunnable) { @SuppressWarnings("unchecked") Class<? extends IMacroRunnable> clazz = (Class<? extends IMacroRunnable>) bean.getClass(); return createMacro(clazz, annotation); } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { return bean; } }  }
MacroBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) { Macro annotation = bean.getClass().getAnnotation(Macro.class); if (annotation != null) { if (StringUtils.isBlank(annotation.name())) { throw new BeanDefinitionValidationException("no macro name specified in @" + Macro.class.getSimpleName() + " annotation for bean: " + beanName); } if (!(bean instanceof IMacro)) { if (bean instanceof ISimpleMacro) { return createMacro((ISimpleMacro) bean, annotation); } else if (bean instanceof IMacroRunnable) { @SuppressWarnings("unchecked") Class<? extends IMacroRunnable> clazz = (Class<? extends IMacroRunnable>) bean.getClass(); return createMacro(clazz, annotation); } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { return bean; } }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName); }
MacroBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) { Macro annotation = bean.getClass().getAnnotation(Macro.class); if (annotation != null) { if (StringUtils.isBlank(annotation.name())) { throw new BeanDefinitionValidationException("no macro name specified in @" + Macro.class.getSimpleName() + " annotation for bean: " + beanName); } if (!(bean instanceof IMacro)) { if (bean instanceof ISimpleMacro) { return createMacro((ISimpleMacro) bean, annotation); } else if (bean instanceof IMacroRunnable) { @SuppressWarnings("unchecked") Class<? extends IMacroRunnable> clazz = (Class<? extends IMacroRunnable>) bean.getClass(); return createMacro(clazz, annotation); } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { throw new BeanNotOfRequiredTypeException(beanName, ISimpleMacro.class, bean.getClass()); } } else { return bean; } }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName);  }