Announcement Announcement Module
Collapse
No announcement yet.
Control Bus bug with BenaFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Control Bus bug with BenaFactory

    Hello, Mark, Oleg & Dave
    I've caught some bugs in Control Bus components.

    1. If I using the <groovy:control-bus input-channel="controlBusChannel"/>, GroovyControlBusFactoryBean "scolded" me that I have some abstract beans. So, I think the code of ManagedBeansScriptVariableGenerator.generateScript Variables must be like:
    Code:
    for (String name : this.beanFactory.getBeanDefinitionNames()) {
          BeanDefinition def = this.beanFactory.getBeanDefinition(name); //THIS
          if (def.isAbstract()) continue;                  // AND THIS
          Object bean = this.beanFactory.getBean(name);
    2. I cant access to FactroyBeans directly from SpEL. For example:
    HTML Code:
    <transformer input-channel="refreshGlobalSettingsChannel" output-channel="controlBusChannel" expression="'@&amp;globalSettings.refresh()'"/>
    Because the SpEL doesn't understand sombol "&". No words...

    And some question out of thread:
    1. How can I access directly to BeanFactory(ApplicationContext) from SpEL?
    2. How can I make my singleton Beans refreshable?
    I've wrote some class:
    Code:
    @ManagedResource
    class RefreshableFactoryBean<T> implements FactoryBean<T>, InitializingBean {
    
        @Autowired
        BeanFactory beanFactory
    
        ExpressionFactoryBean delegate
    
        volatile T object
    
        Class<T> objectType
    
        String expressionString
    
        EvaluationContext evaluationContext
    
        @ManagedOperation
        void refresh() {
            if (delegate) object = delegate.object.getValue(evaluationContext)
        }
    
        boolean isSingleton() {
            return true
        }
    
        void afterPropertiesSet() {
            if (expressionString) {
                delegate = new ExpressionFactoryBean(expressionString)
                delegate.afterPropertiesSet()
                evaluationContext = new StandardEvaluationContext()
                evaluationContext.beanResolver = new BeanFactoryResolver(beanFactory)
            }
            refresh()
        }
    }
    But I hope there are some elegant solutions in the Spring...

    thanks in advance,
    Artem Bilan

    P.S. Sorry for mistake in the name of Thread. Disgraced...
    Last edited by Artem Bilan; Aug 25th, 2011, 03:38 PM.

  • #2
    Hello, guys
    I've fixed my task about Control Bus with additional component:
    Code:
     <transformer input-channel="refreshGlobalSettingsChannel" output-channel="controlBusChannel">
            <groovy:script>
                return '@controlBusManager.refreshBean("&amp;globalSettings")'
            </groovy:script>
        </transformer>

    Comment

    Working...
    X