@Test public void shouldAddActionWithoutParams() throws Exception { ArgumentCaptor<Channel> captor = ArgumentCaptor.forClass(Channel.class); processor.postProcessAfterInitialization(new TestActionWithoutParam(), null); verify(channelService).addOrUpdate(captor.capture()); assertChannel(captor.getValue()); }
@Override public Object postProcessAfterInitialization(final Object bean, final String beanName) { if (bean == null) { return null; } final Class<?> targetClass = getTargetClass(bean); final TaskChannel taskChannel = targetClass.getAnnotation(TaskChannel.class); if (taskChannel != null) { LOGGER.debug("The @TaskChannel annotation was found in {}", targetClass.getName()); doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { @Override public void doWith(Method method) throws IllegalAccessException { Method targetMethod = findMethod( targetClass, method.getName(), method.getParameterTypes() ); if (targetMethod != null) { TaskAction taskAction = targetMethod.getAnnotation(TaskAction.class); if (taskAction != null) { LOGGER.debug("The @TaskAction annotation was found in method: {}", targetMethod.getName()); String serviceInterface = getServiceInterface(targetClass); Channel channel = getChannel(taskChannel); addActionTaskEvent(channel, serviceInterface, targetMethod, taskAction); } } } }); } return bean; }
TaskAnnotationBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(final Object bean, final String beanName) { if (bean == null) { return null; } final Class<?> targetClass = getTargetClass(bean); final TaskChannel taskChannel = targetClass.getAnnotation(TaskChannel.class); if (taskChannel != null) { LOGGER.debug("The @TaskChannel annotation was found in {}", targetClass.getName()); doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { @Override public void doWith(Method method) throws IllegalAccessException { Method targetMethod = findMethod( targetClass, method.getName(), method.getParameterTypes() ); if (targetMethod != null) { TaskAction taskAction = targetMethod.getAnnotation(TaskAction.class); if (taskAction != null) { LOGGER.debug("The @TaskAction annotation was found in method: {}", targetMethod.getName()); String serviceInterface = getServiceInterface(targetClass); Channel channel = getChannel(taskChannel); addActionTaskEvent(channel, serviceInterface, targetMethod, taskAction); } } } }); } return bean; } }
TaskAnnotationBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(final Object bean, final String beanName) { if (bean == null) { return null; } final Class<?> targetClass = getTargetClass(bean); final TaskChannel taskChannel = targetClass.getAnnotation(TaskChannel.class); if (taskChannel != null) { LOGGER.debug("The @TaskChannel annotation was found in {}", targetClass.getName()); doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { @Override public void doWith(Method method) throws IllegalAccessException { Method targetMethod = findMethod( targetClass, method.getName(), method.getParameterTypes() ); if (targetMethod != null) { TaskAction taskAction = targetMethod.getAnnotation(TaskAction.class); if (taskAction != null) { LOGGER.debug("The @TaskAction annotation was found in method: {}", targetMethod.getName()); String serviceInterface = getServiceInterface(targetClass); Channel channel = getChannel(taskChannel); addActionTaskEvent(channel, serviceInterface, targetMethod, taskAction); } } } }); } return bean; } TaskAnnotationBeanPostProcessor(BundleContext bundleContext,
                                           ChannelService channelService); }
TaskAnnotationBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(final Object bean, final String beanName) { if (bean == null) { return null; } final Class<?> targetClass = getTargetClass(bean); final TaskChannel taskChannel = targetClass.getAnnotation(TaskChannel.class); if (taskChannel != null) { LOGGER.debug("The @TaskChannel annotation was found in {}", targetClass.getName()); doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { @Override public void doWith(Method method) throws IllegalAccessException { Method targetMethod = findMethod( targetClass, method.getName(), method.getParameterTypes() ); if (targetMethod != null) { TaskAction taskAction = targetMethod.getAnnotation(TaskAction.class); if (taskAction != null) { LOGGER.debug("The @TaskAction annotation was found in method: {}", targetMethod.getName()); String serviceInterface = getServiceInterface(targetClass); Channel channel = getChannel(taskChannel); addActionTaskEvent(channel, serviceInterface, targetMethod, taskAction); } } } }); } return bean; } TaskAnnotationBeanPostProcessor(BundleContext bundleContext,
                                           ChannelService channelService); void processAnnotations(ApplicationContext applicationContext); @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(final Object bean, final String beanName); }
TaskAnnotationBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(final Object bean, final String beanName) { if (bean == null) { return null; } final Class<?> targetClass = getTargetClass(bean); final TaskChannel taskChannel = targetClass.getAnnotation(TaskChannel.class); if (taskChannel != null) { LOGGER.debug("The @TaskChannel annotation was found in {}", targetClass.getName()); doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { @Override public void doWith(Method method) throws IllegalAccessException { Method targetMethod = findMethod( targetClass, method.getName(), method.getParameterTypes() ); if (targetMethod != null) { TaskAction taskAction = targetMethod.getAnnotation(TaskAction.class); if (taskAction != null) { LOGGER.debug("The @TaskAction annotation was found in method: {}", targetMethod.getName()); String serviceInterface = getServiceInterface(targetClass); Channel channel = getChannel(taskChannel); addActionTaskEvent(channel, serviceInterface, targetMethod, taskAction); } } } }); } return bean; } TaskAnnotationBeanPostProcessor(BundleContext bundleContext,
                                           ChannelService channelService); void processAnnotations(ApplicationContext applicationContext); @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(final Object bean, final String beanName);  }