Announcement Announcement Module
Collapse
No announcement yet.
Groovy Config for Spring 2.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Groovy Config for Spring 2.0

    I got the following to work:

    Code:
    package blog.solomon.crazybob;
    
    import blog.solomon.spring.config.ProgrammableConfigurer;
    
    class MyConfigrurer extends ProgrammableConfigurer {
        void configure() {
            // "tee" definition... notice that TeeImpl is not fully qualified ;)
            bean("tee", TeeImpl.class)
                .setLazyInit(true)
                .constructor("test")
    
            // "bar" definition... I used varargs in the constructor 
            // instead of multiple calls to constructor.generic()
            prototype("bar", BarImpl.class)
                .constructor( 5, ref("tee") )
    
            // "foo" definition... Use the a Groovy created map to define the properties.
            prototype("foo", Foo.class).properties([
                "i": "5",            
                "s": "test", 
                "bar": ref("bar"),   
                "copy": ref("bar")
            ])
        }
    }
    which should have the same functionality as Crazy Bob's email to the spring-dev email group

    This is all scripted in Groovy and accessible either vi programmatic means or via the following xml:

    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:lang-config="http://www.agiledevelopments.com/schema/lang_config"
           xsi:schemaLocation="
           http://www.agiledevelopments.com/schema/lang_config http://www.agiledevelopments.com/schema/lang_config/lang_config.xsd
           	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
           	">
        <lang-config:groovy-config script-source="/bean_config1.groovy" />
    
    </beans>
    The ProgrammableConfigurer is a wrapper around a GenericApplicationContext such as a StaticApplicationContext which has similar functionality as a BeanDefinitionRegistryBuilder.

    I wanted to get your thoughts on this implementation...
Working...
X