use of org.motechproject.tasks.annotations.TaskAction in project motech by motech.
the class TaskAnnotationBeanPostProcessor method postProcessAfterInitialization.
@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;
}
Aggregations