Announcement Announcement Module
Collapse
No announcement yet.
FYI: Cross Factory bean lookup Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • FYI: Cross Factory bean lookup

    Hi,

    This is an FYI posting. For the lack of other place, posting it here.

    I've created a 'cross factory bean lookup' post processor for one of my projects. This makes it possible to reference beans defined in other 'non-parent' factories (currently, the factories have to be visible in the 'root' context, might be extended to any factory in the tree later).

    This makes it quite easy to 'plug' modules together providing each module has its own beanRefFactory.xml file(s) (so that each module can be configured separately through property files, and the jar file just 'dropped in' at the deployment time).

    eg:

    Code:
    test-beans.xml
    <beans>
      <bean id="configurer" class="com.artilekt.modules.spring.config.BeanNameResolutionConfigurer"/>
    
      <bean id="testBean4" class="com.artilekt.modules.spring.TestClass">
        <constructor-arg value="Test Bean4"/>
        <property name="linkedTestClass" ref="[email protected]"/>
      </bean>
    </beans>
    where testBeanService is a bean loaded by com.artilekt.modules.spring.test factory:

    Code:
    test-beanServiceRefFactory.xml
    <beans>
      <bean id="com.artilekt.modules.spring.test" lazy-init="true"
            class="org.springframework.context.support.ClassPathXmlApplicationContext">
        <constructor-arg>
          <list>
            <value>com/artilekt/modules/spring/test-beansService.xml</value>
          </list>
        </constructor-arg>
      </bean>
    </beans>
    
    test-beansService.xml
    <beans>
      <bean id="testBeanService" class="com.artilekt.modules.spring.TestClass">
        <constructor-arg value="Test Bean Service"/>
      </bean>
    </beans>
    
    
    Initialization code:
        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
            new String[]{"com/artilekt/modules/spring/test-beans.xml", "com/artilekt/modules/spring/test-beanServiceRefFactory.xml"});
    For source code, see:
    http://jetmailer.tigris.org/source/b...spring/config/

    For usage example code (mixed with Unit tests):
    http://jetmailer.tigris.org/source/b...odules/spring/

    Cheers.

    Vlad
Working...
X