polishing

This commit is contained in:
Mark Fisher
2011-09-15 07:21:44 -04:00
parent 85378b6c03
commit 0acff625da

View File

@@ -17,9 +17,7 @@ import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.Lifecycle;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.Message;
@@ -78,7 +76,8 @@ public class GroovyControlBusFactoryBean extends AbstractSimpleMessageHandlerFac
private final ConfigurableListableBeanFactory beanFactory;
public ManagedBeansScriptVariableGenerator(BeanFactory beanFactory) {
this.beanFactory = (beanFactory instanceof ConfigurableListableBeanFactory) ? (ConfigurableListableBeanFactory) beanFactory : null;
this.beanFactory = (beanFactory instanceof ConfigurableListableBeanFactory)
? (ConfigurableListableBeanFactory) beanFactory : null;
}
public Map<String, Object> generateScriptVariables(Message<?> message) {
@@ -86,15 +85,14 @@ public class GroovyControlBusFactoryBean extends AbstractSimpleMessageHandlerFac
variables.put("headers", message.getHeaders());
if (this.beanFactory != null) {
for (String name : this.beanFactory.getBeanDefinitionNames()) {
BeanDefinition def = this.beanFactory.getBeanDefinition(name);
if (!def.isAbstract()){
if (!this.beanFactory.getBeanDefinition(name).isAbstract()) {
Object bean = this.beanFactory.getBean(name);
if (bean instanceof Lifecycle ||
bean instanceof CustomizableThreadCreator ||
(AnnotationUtils.findAnnotation(bean.getClass(), ManagedResource.class) != null)) {
variables.put(name, bean);
}
}
}
}
}
return variables;