MessagingAnnotationPostProcessor avoids null target class (INT-239).

This commit is contained in:
Mark Fisher
2008-06-02 18:07:49 +00:00
parent c28a4bc448
commit 6fe0e44331
2 changed files with 11 additions and 10 deletions

View File

@@ -233,8 +233,8 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
}
public boolean preReceive(MessageChannel channel) {
if (logger.isDebugEnabled()) {
logger.debug("preReceive on channel '" + channel + "'");
if (logger.isTraceEnabled()) {
logger.trace("preReceive on channel '" + channel + "'");
}
for (ChannelInterceptor interceptor : interceptors) {
if (!interceptor.preReceive(channel)) {
@@ -245,9 +245,12 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
}
public void postReceive(Message<?> message, MessageChannel channel) {
if (logger.isDebugEnabled()) {
if (message != null && logger.isDebugEnabled()) {
logger.debug("postReceive on channel '" + channel + "', message: " + message);
}
else if (logger.isTraceEnabled()) {
logger.trace("postReceive on channel '" + channel + "', message is null");
}
for (ChannelInterceptor interceptor : interceptors) {
interceptor.postReceive(message, channel);
}

View File

@@ -49,7 +49,8 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Init
private volatile ClassLoader beanClassLoader;
private Map<Class<?>, AnnotationMethodPostProcessor> postProcessors = new HashMap<Class<?>, AnnotationMethodPostProcessor>();
private final Map<Class<?>, AnnotationMethodPostProcessor> postProcessors =
new HashMap<Class<?>, AnnotationMethodPostProcessor>();
public MessagingAnnotationPostProcessor(MessageBus messageBus) {
@@ -62,10 +63,6 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Init
this.beanClassLoader = beanClassLoader;
}
protected MessageBus getMessageBus() {
return this.messageBus;
}
public void afterPropertiesSet() {
this.postProcessors.put(MessageHandler.class, new HandlerAnnotationPostProcessor(this.messageBus, this.beanClassLoader));
this.postProcessors.put(Source.class, new SourceAnnotationPostProcessor(this.messageBus, this.beanClassLoader));
@@ -101,8 +98,9 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Init
return bean;
}
protected Class<?> getBeanClass(Object bean) {
return AopUtils.getTargetClass(bean);
private Class<?> getBeanClass(Object bean) {
Class<?> targetClass = AopUtils.getTargetClass(bean);
return (targetClass != null) ? targetClass : bean.getClass();
}
}