Results 1 to 2 of 2

Thread: Control Bus bug with BenaFactory

Threaded View

  1. #1
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    632

    Exclamation 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 Cleric; Aug 25th, 2011 at 03:38 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •