use of org.motechproject.tasks.annotations.TaskChannel 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;
}
use of org.motechproject.tasks.annotations.TaskChannel in project motech by motech.
the class TaskAnnotationBeanPostProcessor method getChannel.
private Channel getChannel(TaskChannel taskChannel) {
String displayName = taskChannel.channelName();
String moduleName = taskChannel.moduleName();
String moduleVersion = taskChannel.moduleVersion();
Channel channel = channelService.getChannel(moduleName);
if (channel == null) {
LOGGER.debug("Creating new channel: {} for module: {}", displayName, moduleName);
channel = new Channel(displayName, moduleName, moduleVersion);
} else {
LOGGER.debug("Channel: {} for module: {} was retrieved", displayName, moduleName);
}
return channel;
}
Aggregations